1 /** @file externalpostlist.h
2  * @brief Return document ids from an external source.
3  */
4 /* Copyright 2008,2009 Olly Betts
5  * Copyright 2009 Lemur Consulting Ltd
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
20  */
21 
22 #ifndef XAPIAN_INCLUDED_EXTERNALPOSTLIST_H
23 #define XAPIAN_INCLUDED_EXTERNALPOSTLIST_H
24 
25 #include "postlist.h"
26 
27 namespace Xapian {
28     class PostingSource;
29 }
30 
31 class MultiMatch;
32 
33 class ExternalPostList : public PostList {
34     /// Disallow copying.
35     ExternalPostList(const ExternalPostList &);
36 
37     /// Disallow assignment.
38     void operator=(const ExternalPostList &);
39 
40     Xapian::PostingSource * source;
41     bool source_is_owned;
42 
43     Xapian::docid current;
44 
45     double factor;
46 
47     PostList * update_after_advance();
48 
49   public:
50     /** Constructor.
51      *
52      *  @param matcher	The matcher to notify when maximum weight changes.
53      */
54     ExternalPostList(const Xapian::Database & db,
55 		     Xapian::PostingSource *source_,
56 		     double factor_,
57 		     MultiMatch * matcher);
58 
59     ~ExternalPostList();
60 
61     Xapian::doccount get_termfreq_min() const;
62 
63     Xapian::doccount get_termfreq_est() const;
64 
65     Xapian::doccount get_termfreq_max() const;
66 
67     Xapian::weight get_maxweight() const;
68 
69     Xapian::docid get_docid() const;
70 
71     Xapian::weight get_weight() const;
72 
73     Xapian::termcount get_doclength() const;
74 
75     Xapian::weight recalc_maxweight();
76 
77     PositionList * read_position_list();
78 
79     PositionList * open_position_list() const;
80 
81     PostList * next(Xapian::weight w_min);
82 
83     PostList * skip_to(Xapian::docid, Xapian::weight w_min);
84 
85     PostList * check(Xapian::docid did, Xapian::weight w_min, bool &valid);
86 
87     bool at_end() const;
88 
89     Xapian::termcount count_matching_subqs() const;
90 
91     string get_description() const;
92 };
93 
94 #endif /* XAPIAN_INCLUDED_EXTERNALPOSTLIST_H */
95