xapian-core  2.0.0
andmaybepostlist.h
Go to the documentation of this file.
1 
4 /* Copyright 2017 Olly Betts
5  *
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.
10  *
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.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, see
18  * <https://www.gnu.org/licenses/>.
19  */
20 
21 #ifndef XAPIAN_INCLUDED_ANDMAYBEPOSTLIST_H
22 #define XAPIAN_INCLUDED_ANDMAYBEPOSTLIST_H
23 
24 #include "postlisttree.h"
25 #include "wrapperpostlist.h"
26 
31 
34 
37 
39  double pl_max;
40 
42  double r_max;
43 
45 
47  bool maybe_matches() const { return pl_did == r_did; }
48 
50  double w_min,
51  bool* valid_ptr = NULL);
52 
53  public:
55  : WrapperPostList(left), r(right), pltree(pltree_)
56  {}
57 
64  PostList* right,
65  double lmax,
66  double rmax,
67  PostListTree* pltree_)
68  : WrapperPostList(left), r(right), pl_max(lmax), r_max(rmax),
69  pltree(pltree_)
70  { }
71 
72  ~AndMaybePostList() { delete r; }
73 
74  Xapian::docid get_docid() const;
75 
76  double get_weight(Xapian::termcount doclen,
77  Xapian::termcount unique_terms,
78  Xapian::termcount wdfdocmax) const;
79 
80  double recalc_maxweight();
81 
82  PostList* next(double w_min);
83 
84  PostList* skip_to(Xapian::docid did, double w_min);
85 
86  PostList* check(Xapian::docid did, double w_min, bool& valid);
87 
88  std::string get_description() const;
89 
90  Xapian::termcount get_wdf() const;
91 
93 
94  void gather_position_lists(OrPositionList* orposlist);
95 };
96 
97 #endif // XAPIAN_INCLUDED_ANDMAYBEPOSTLIST_H
PostList class implementing Query::OP_AND_MAYBE.
Xapian::termcount get_wdf() const
Return the wdf for the document at the current position.
AndMaybePostList(PostList *left, PostList *right, double lmax, double rmax, PostListTree *pltree_)
Construct as decay product from OrPostList.
double pl_max
Current max weight from WrapperPostList's pl.
Xapian::docid r_did
Current docid from r (or 0).
PostList * skip_to(Xapian::docid did, double w_min)
Skip forward to the specified docid.
PostList * decay_to_and(Xapian::docid did, double w_min, bool *valid_ptr=NULL)
double recalc_maxweight()
Recalculate the upper bound on what get_weight() can return.
Xapian::docid get_docid() const
Return the current docid.
double get_weight(Xapian::termcount doclen, Xapian::termcount unique_terms, Xapian::termcount wdfdocmax) const
Return the weight contribution for the current position.
void gather_position_lists(OrPositionList *orposlist)
Gather PositionList* objects for a subtree.
PostListTree * pltree
Xapian::termcount count_matching_subqs() const
Count the number of leaf subqueries which match at the current position.
Xapian::docid pl_did
Current docid from WrapperPostList's pl.
double r_max
Current max weight from r.
std::string get_description() const
Return a string description of this object.
PostList * r
Right-hand side of OP_MAYBE.
PostList * check(Xapian::docid did, double w_min, bool &valid)
Check if the specified docid occurs in this postlist.
AndMaybePostList(PostList *left, PostList *right, PostListTree *pltree_)
bool maybe_matches() const
Does r match at the current position?
Base class for a PostList which wraps another PostList.
Abstract base class for postlists.
Definition: postlist.h:40
PostList * next()
Advance the current position to the next document in the postlist.
Definition: postlist.h:168
unsigned XAPIAN_TERMCOUNT_BASE_TYPE termcount
A counts of terms.
Definition: types.h:64
unsigned XAPIAN_DOCID_BASE_TYPE docid
A unique identifier for a document.
Definition: types.h:51
Class for managing a tree of PostList objects.
Base class for a PostList which wraps another PostList.