Branch data Line data Source code
1 : : /* mergepostlist.h: merge postlists from different databases
2 : : *
3 : : * Copyright 1999,2000,2001 BrightStation PLC
4 : : * Copyright 2002 Ananova Ltd
5 : : * Copyright 2002,2003,2004,2005,2009 Olly Betts
6 : : * Copyright 2007 Lemur Consulting Ltd
7 : : *
8 : : * This program is free software; you can redistribute it and/or
9 : : * modify it under the terms of the GNU General Public License as
10 : : * published by the Free Software Foundation; either version 2 of the
11 : : * License, or (at your option) any later version.
12 : : *
13 : : * This program is distributed in the hope that it will be useful,
14 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 : : * GNU General Public License for more details.
17 : : *
18 : : * You should have received a copy of the GNU General Public License
19 : : * along with this program; if not, write to the Free Software
20 : : * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
21 : : * USA
22 : : */
23 : :
24 : : #ifndef OM_HGUARD_MERGEPOSTLIST_H
25 : : #define OM_HGUARD_MERGEPOSTLIST_H
26 : :
27 : : #include "postlist.h"
28 : :
29 : : class MultiMatch;
30 : : class ValueStreamDocument;
31 : :
32 : : /** A postlist comprising postlists from different databases merged together.
33 : : */
34 : : class MergePostList : public PostList {
35 : : private:
36 : : // Prevent copying
37 : : MergePostList(const MergePostList &);
38 : : MergePostList & operator=(const MergePostList &);
39 : :
40 : : Xapian::weight w_max;
41 : :
42 : : vector<PostList *> plists;
43 : :
44 : : int current;
45 : :
46 : : /** The object which is using this postlist to perform
47 : : * a match. This object needs to be notified when the
48 : : * tree changes such that the maximum weights need to be
49 : : * recalculated.
50 : : */
51 : : MultiMatch *matcher;
52 : :
53 : : /** Document proxy used for valuestream caching.
54 : : *
55 : : * We need to notify this when the subdatabase changes, as then the
56 : : * cached valuestreams need to be cleared as they will be for the
57 : : * wrong subdatabase.
58 : : */
59 : : ValueStreamDocument & vsdoc;
60 : :
61 : : Xapian::ErrorHandler * errorhandler;
62 : : public:
63 : : Xapian::termcount get_wdf() const;
64 : : Xapian::doccount get_termfreq_max() const;
65 : : Xapian::doccount get_termfreq_min() const;
66 : : Xapian::doccount get_termfreq_est() const;
67 : :
68 : : Xapian::docid get_docid() const;
69 : : Xapian::weight get_weight() const;
70 : : const string * get_collapse_key() const;
71 : :
72 : : Xapian::weight get_maxweight() const;
73 : :
74 : : Xapian::weight recalc_maxweight();
75 : :
76 : : PostList *next(Xapian::weight w_min);
77 : : PostList *skip_to(Xapian::docid did, Xapian::weight w_min);
78 : : bool at_end() const;
79 : :
80 : : string get_description() const;
81 : :
82 : : /** Return the document length of the document the current term
83 : : * comes from.
84 : : */
85 : : virtual Xapian::termcount get_doclength() const;
86 : :
87 : : Xapian::termcount count_matching_subqs() const;
88 : :
89 : 71275 : MergePostList(const std::vector<PostList *> & plists_,
90 : : MultiMatch *matcher_,
91 : : ValueStreamDocument & vsdoc_,
92 : : Xapian::ErrorHandler * errorhandler_)
93 : : : plists(plists_), current(-1), matcher(matcher_), vsdoc(vsdoc_),
94 : 71275 : errorhandler(errorhandler_) { }
95 : :
96 : : ~MergePostList();
97 : : };
98 : :
99 : : #endif /* OM_HGUARD_MERGEPOSTLIST_H */
|