xapian-core  2.0.0
andnotpostlist.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_ANDNOTPOSTLIST_H
22 #define XAPIAN_INCLUDED_ANDNOTPOSTLIST_H
23 
24 #include "wrapperpostlist.h"
25 
26 class PostListTree;
27 
32 
35 
36  public:
38  : WrapperPostList(left), r(right)
39  {
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);
50  }
51 
52  ~AndNotPostList() { delete r; }
53 
54  PostList* next(double w_min);
55 
56  PostList* skip_to(Xapian::docid did, double w_min);
57 
58  PostList* check(Xapian::docid did, double w_min, bool& valid);
59 
60  std::string get_description() const;
61 };
62 
63 #endif // XAPIAN_INCLUDED_ANDNOTPOSTLIST_H
PostList class implementing Query::OP_AND_NOT.
PostList * r
Right-hand side of OP_NOT.
Xapian::docid r_did
Current docid from r (or 0).
AndNotPostList(PostList *left, PostList *right, Xapian::doccount db_size)
PostList * skip_to(Xapian::docid did, double w_min)
Skip forward to the specified docid.
std::string get_description() const
Return a string description of this object.
PostList * check(Xapian::docid did, double w_min, bool &valid)
Check if the specified docid occurs in this postlist.
Base class for a PostList which wraps another PostList.
Abstract base class for postlists.
Definition: postlist.h:40
Xapian::doccount get_termfreq() const
Get an estimate of the number of documents this PostList will return.
Definition: postlist.h:67
PostList * next()
Advance the current position to the next document in the postlist.
Definition: postlist.h:168
Xapian::doccount termfreq
Estimate of the number of documents this PostList will return.
Definition: postlist.h:52
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
#define Assert(COND)
Definition: omassert.h:122
Base class for a PostList which wraps another PostList.