xapian-core  2.0.0
selectpostlist.h
Go to the documentation of this file.
1 
4 /* Copyright 2017-2022 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_SELECTPOSTLIST_H
22 #define XAPIAN_INCLUDED_SELECTPOSTLIST_H
23 
24 #include "wrapperpostlist.h"
25 
26 #include <cmath>
27 
28 class EstimateOp;
29 class PostListTree;
30 
34  double cached_weight = -HUGE_VAL;
35 
37 
39  bool vet(double w_min);
40 
41  protected:
44 
47 
50 
52  virtual bool test_doc() = 0;
53 
54  public:
56  EstimateOp* estimate_op_,
57  PostListTree* pltree_)
58  : WrapperPostList(pl_), pltree(pltree_), estimate_op(estimate_op_) {}
59 
61 
62  double get_weight(Xapian::termcount doclen,
63  Xapian::termcount unique_terms,
64  Xapian::termcount wdfdocmax) const;
65 
66  bool at_end() const;
67 
68  PostList* next(double w_min);
69 
70  PostList* skip_to(Xapian::docid did, double w_min);
71 
72  PostList* check(Xapian::docid did, double w_min, bool& valid);
73 };
74 
75 #endif // XAPIAN_INCLUDED_SELECTPOSTLIST_H
Class for estimating the total number of matching documents.
Definition: estimateop.h:64
Base class for classes which filter another PostList.
PostList * check(Xapian::docid did, double w_min, bool &valid)
Check if the specified docid occurs in this postlist.
bool vet(double w_min)
Check if the current document is suitable.
Xapian::doccount accepted
Number of times test_doc() returned true.
PostListTree * pltree
Xapian::doccount rejected
Number of times test_doc() returned false.
virtual bool test_doc()=0
Check if the current document should be selected.
double cached_weight
Used to avoid calculating the weight twice for a given document.
EstimateOp * estimate_op
Object to report accepted/rejected counts to.
SelectPostList(PostList *pl_, EstimateOp *estimate_op_, PostListTree *pltree_)
double get_weight(Xapian::termcount doclen, Xapian::termcount unique_terms, Xapian::termcount wdfdocmax) const
Return the weight contribution for the current position.
PostList * skip_to(Xapian::docid did, double w_min)
Skip forward to the specified docid.
bool at_end() const
Return true if the current position is past the last entry in this list.
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 doccount
A count of documents.
Definition: types.h:37
unsigned XAPIAN_DOCID_BASE_TYPE docid
A unique identifier for a document.
Definition: types.h:51
Base class for a PostList which wraps another PostList.