[ci] Fix clang-santisers job for GHA change
[xapian.git] / xapian-core / matcher / andnotpostlist.h
blob3726e1bc8e958050386f1fa54a174a13b1e47272
1 /** @file
2 * @brief PostList class implementing Query::OP_AND_NOT
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_ANDNOTPOSTLIST_H
22 #define XAPIAN_INCLUDED_ANDNOTPOSTLIST_H
24 #include "wrapperpostlist.h"
26 class PostListTree;
28 /// PostList class implementing Query::OP_AND_NOT
29 class AndNotPostList : public WrapperPostList {
30 /// Right-hand side of OP_NOT.
31 PostList* r;
33 /// Current docid from r (or 0).
34 Xapian::docid r_did = 0;
36 public:
37 AndNotPostList(PostList* left, PostList* right, Xapian::doccount db_size)
38 : WrapperPostList(left), r(right)
40 // We shortcut an empty shard and avoid creating a postlist tree for
41 // it.
42 Assert(db_size);
43 // We calculate the estimate assuming independence. With this
44 // assumption, the estimate is the product of the estimates for the
45 // sub-postlists (for the right side this is inverted by subtracting
46 // from db_size), divided by db_size.
47 double result = pl->get_termfreq();
48 result = (result * (db_size - r->get_termfreq())) / db_size;
49 termfreq = static_cast<Xapian::doccount>(result + 0.5);
52 ~AndNotPostList() { delete r; }
54 PostList* next(double w_min);
56 PostList* skip_to(Xapian::docid did, double w_min);
58 PostList* check(Xapian::docid did, double w_min, bool& valid);
60 std::string get_description() const;
63 #endif // XAPIAN_INCLUDED_ANDNOTPOSTLIST_H