1 /** @file multixorpostlist.h
2 * @brief N-way XOR postlist
4 /* Copyright (C) 2007,2009,2010,2011,2012,2017 Olly Betts
5 * Copyright (C) 2009 Lemur Consulting Ltd
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License as
9 * published by the Free Software Foundation; either version 2 of the
10 * License, or (at your option) any later version.
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.
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
22 #ifndef XAPIAN_INCLUDED_MULTIXORPOSTLIST_H
23 #define XAPIAN_INCLUDED_MULTIXORPOSTLIST_H
25 #include "api/postlist.h"
28 #include "postlisttree.h"
30 /// N-way XOR postlist.
31 class MultiXorPostList
: public PostList
{
32 /// Don't allow assignment.
33 void operator=(const MultiXorPostList
&);
35 /// Don't allow copying.
36 MultiXorPostList(const MultiXorPostList
&);
38 /// The current docid, or zero if we haven't started or are at_end.
41 /// The number of sub-postlists.
44 /// Array of pointers to sub-postlists.
47 /// The number of documents in the database.
48 Xapian::doccount db_size
;
50 /// Pointer to the matcher object, so we can report pruning.
51 PostListTree
*matcher
;
53 /// Erase a sub-postlist.
54 void erase_sublist(size_t i
) {
57 for (size_t j
= i
; j
< n_kids
; ++j
) {
58 plist
[j
] = plist
[j
+ 1];
60 matcher
->force_recalc();
64 /** Construct from 2 random-access iterators to a container of PostList*,
65 * a pointer to the matcher, and the document collection size.
67 template <class RandomItor
>
68 MultiXorPostList(RandomItor pl_begin
, RandomItor pl_end
,
69 PostListTree
* matcher_
, Xapian::doccount db_size_
)
70 : did(0), n_kids(pl_end
- pl_begin
), plist(NULL
),
71 db_size(db_size_
), matcher(matcher_
)
73 plist
= new PostList
* [n_kids
];
74 std::copy(pl_begin
, pl_end
, plist
);
79 Xapian::doccount
get_termfreq_min() const;
81 Xapian::doccount
get_termfreq_max() const;
83 Xapian::doccount
get_termfreq_est() const;
85 TermFreqs
get_termfreq_est_using_stats(
86 const Xapian::Weight::Internal
& stats
) const;
88 Xapian::docid
get_docid() const;
90 double get_weight(Xapian::termcount doclen
,
91 Xapian::termcount unique_terms
) const;
95 double recalc_maxweight();
97 PositionList
* read_position_list() {
101 PostList
* next(double w_min
);
103 PostList
* skip_to(Xapian::docid
, double w_min
);
105 std::string
get_description() const;
107 /** get_wdf() for MultiXorPostlists returns the sum of the wdfs of the
108 * sub postlists which match the current docid.
110 * The wdf isn't really meaningful in many situations, but if the lists
111 * are being combined as a synonym we want the sum of the wdfs, so we do
114 Xapian::termcount
get_wdf() const;
116 Xapian::termcount
count_matching_subqs() const;
119 #endif // XAPIAN_INCLUDED_MULTIXORPOSTLIST_H