Fix misordered commands in source
[xapian.git] / xapian-core / matcher / orpostlist.h
blob09beb41ab1166a7748200f8707d219aa508e3b2b
1 /** @file orpostlist.h
2 * @brief PostList class implementing Query::OP_OR
3 */
4 /* Copyright 2017 Olly Betts
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License as
8 * published by the Free Software Foundation; either version 2 of the
9 * License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21 #ifndef XAPIAN_INCLUDED_ORPOSTLIST_H
22 #define XAPIAN_INCLUDED_ORPOSTLIST_H
24 #include "api/postlist.h"
26 class PostListTree;
28 /// PostList class implementing Query::OP_OR
29 class OrPostList : public PostList {
30 /// Don't allow assignment.
31 void operator=(const OrPostList&) = delete;
33 /// Don't allow copying.
34 OrPostList(const OrPostList&) = delete;
36 /** Left side.
38 * We optimise assuming this side is more frequent, and so creators should
39 * try to set this side to the side with the higher estimated term
40 * frequency.
42 PostList* l;
44 /// Right side.
45 PostList* r;
47 Xapian::docid l_did = 0;
49 Xapian::docid r_did = 0;
51 double l_max = 0;
53 double r_max = 0;
55 /** Total number of documents in the database. */
56 Xapian::doccount db_size;
58 PostListTree* pltree;
60 PostList* decay_to_and(Xapian::docid did,
61 double w_min,
62 bool* valid_ptr = NULL);
64 PostList* decay_to_andmaybe(PostList* left,
65 PostList* right,
66 Xapian::docid did,
67 double w_min,
68 bool* valid_ptr = NULL);
70 public:
71 OrPostList(PostList* left, PostList* right,
72 PostListTree* pltree_, Xapian::doccount db_size_)
73 : l(left), r(right), db_size(db_size_), pltree(pltree_)
76 ~OrPostList() {
77 delete l;
78 delete r;
81 Xapian::doccount get_termfreq_min() const;
83 Xapian::doccount get_termfreq_max() const;
85 Xapian::doccount get_termfreq_est() const;
87 TermFreqs get_termfreq_est_using_stats(
88 const Xapian::Weight::Internal& stats) const;
90 Xapian::docid get_docid() const;
92 double get_weight(Xapian::termcount doclen,
93 Xapian::termcount unique_terms) const;
95 bool at_end() const;
97 double recalc_maxweight();
99 PostList* next(double w_min);
101 PostList* skip_to(Xapian::docid did, double w_min);
103 PostList* check(Xapian::docid did, double w_min, bool& valid);
105 std::string get_description() const;
107 Xapian::termcount get_wdf() const;
109 Xapian::termcount count_matching_subqs() const;
111 void gather_position_lists(OrPositionList* orposlist);
114 #endif // XAPIAN_INCLUDED_ORPOSTLIST_H