2 * @brief Base class for classes which filter another PostList
4 /* Copyright 2017-2022 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_SELECTPOSTLIST_H
22 #define XAPIAN_INCLUDED_SELECTPOSTLIST_H
24 #include "wrapperpostlist.h"
31 /// Base class for classes which filter another PostList
32 class SelectPostList
: public WrapperPostList
{
33 /// Used to avoid calculating the weight twice for a given document.
34 double cached_weight
= -HUGE_VAL
;
38 /// Check if the current document is suitable.
39 bool vet(double w_min
);
42 /// Number of times test_doc() returned true.
43 Xapian::doccount accepted
= 0;
45 /// Number of times test_doc() returned false.
46 Xapian::doccount rejected
= 0;
48 /// Object to report accepted/rejected counts to.
49 EstimateOp
* estimate_op
;
51 /// Check if the current document should be selected.
52 virtual bool test_doc() = 0;
55 SelectPostList(PostList
* pl_
,
56 EstimateOp
* estimate_op_
,
57 PostListTree
* pltree_
)
58 : WrapperPostList(pl_
), pltree(pltree_
), estimate_op(estimate_op_
) {}
62 double get_weight(Xapian::termcount doclen
,
63 Xapian::termcount unique_terms
,
64 Xapian::termcount wdfdocmax
) const;
68 PostList
* next(double w_min
);
70 PostList
* skip_to(Xapian::docid did
, double w_min
);
72 PostList
* check(Xapian::docid did
, double w_min
, bool& valid
);
75 #endif // XAPIAN_INCLUDED_SELECTPOSTLIST_H