xapian-core  1.4.26
andmaybepostlist.h
Go to the documentation of this file.
1 
7 /* Copyright 1999,2000,2001 BrightStation PLC
8  * Copyright 2002 Ananova Ltd
9  * Copyright 2003,2004,2009,2011,2017 Olly Betts
10  * Copyright 2009 Lemur Consulting Ltd
11  *
12  * This program is free software; you can redistribute it and/or
13  * modify it under the terms of the GNU General Public License as
14  * published by the Free Software Foundation; either version 2 of the
15  * License, or (at your option) any later version.
16  *
17  * This program is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20  * GNU General Public License for more details.
21  *
22  * You should have received a copy of the GNU General Public License
23  * along with this program; if not, write to the Free Software
24  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
25  * USA
26  */
27 
28 
29 #ifndef OM_HGUARD_ANDMAYBEPOSTLIST_H
30 #define OM_HGUARD_ANDMAYBEPOSTLIST_H
31 
32 #include "branchpostlist.h"
33 
55  private:
56  Xapian::doccount dbsize; // only need in case we decay to an AndPostList
58  double lmax, rmax;
59 
60  PostList * process_next_or_skip_to(double w_min, PostList *ret);
61  public:
65 
67  const Xapian::Weight::Internal & stats) const;
68 
69  Xapian::docid get_docid() const;
70  double get_weight() const;
71  double get_maxweight() const;
72 
73  double recalc_maxweight();
74 
75  PostList *next(double w_min);
76  PostList *skip_to(Xapian::docid did, double w_min);
77  bool at_end() const;
78 
79  std::string get_description() const;
80 
84  virtual Xapian::termcount get_doclength() const;
85 
86  virtual Xapian::termcount get_unique_terms() const;
87 
89  PostList *right_,
90  MultiMatch *matcher_,
91  Xapian::doccount dbsize_)
92  : BranchPostList(left_, right_, matcher_),
93  dbsize(dbsize_), lhead(0), rhead(0)
94  {
95  // lmax and rmax will get initialised by a recalc_maxweight
96  }
97 
100  PostList *right_,
101  MultiMatch *matcher_,
102  Xapian::doccount dbsize_,
103  Xapian::docid lhead_,
104  Xapian::docid rhead_)
105  : BranchPostList(left_, right_, matcher_),
106  dbsize(dbsize_), lhead(lhead_), rhead(rhead_)
107  {
108  // Initialise the maxweights from the kids so we can avoid forcing
109  // a full maxweight recalc
110  lmax = l->get_maxweight();
111  rmax = r->get_maxweight();
112  }
113 
117  PostList * sync_rhs(double w_min);
118 
123  Xapian::termcount get_wdf() const;
124 
126 
127  void gather_position_lists(OrPositionList* orposlist);
128 };
129 
130 #endif /* OM_HGUARD_ANDMAYBEPOSTLIST_H */
double recalc_maxweight()
Recalculate the upper bound on what get_weight() can return.
Abstract base class for postlists.
Definition: postlist.h:37
A postlist with weights modified by another postlist.
PostList * l
Left sub-postlist.
AndMaybePostList(PostList *left_, PostList *right_, MultiMatch *matcher_, Xapian::doccount dbsize_, Xapian::docid lhead_, Xapian::docid rhead_)
Constructor for use by decomposing OrPostList.
virtual Xapian::termcount get_unique_terms() const
Return the number of unique terms in the current document.
Xapian::doccount get_termfreq_min() const
Get a lower bound on the number of documents indexed by this term.
Base class for postlists which are generated by merging two sub-postlists.
PostList * sync_rhs(double w_min)
Synchronise the RHS to the LHS after construction.
virtual Xapian::termcount get_doclength() const
Return the document length of the document the current term comes from.
void gather_position_lists(OrPositionList *orposlist)
Gather PositionList* objects for a subtree.
unsigned XAPIAN_TERMCOUNT_BASE_TYPE termcount
A counts of terms.
Definition: types.h:72
Xapian::docid lhead
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.
virtual base class for branched types of postlist
Xapian::termcount get_wdf() const
get_wdf() for ANDMAYBE postlists returns the sum of the wdfs of the sub postlists which are at the cu...
Class to hold statistics for a given collection.
Internal * next()
Advance the current position to the next document in the postlist.
Definition: postlist.h:194
Xapian::doccount dbsize
PostList * process_next_or_skip_to(double w_min, PostList *ret)
AndMaybePostList(PostList *left_, PostList *right_, MultiMatch *matcher_, Xapian::doccount dbsize_)
double get_weight() const
Return the weight contribution for the current position.
virtual double get_maxweight() const =0
Return an upper bound on what get_weight() can return.
TermFreqs get_termfreq_est_using_stats(const Xapian::Weight::Internal &stats) const
Get an estimate for the termfreq and reltermfreq, given the stats.
Xapian::doccount get_termfreq_est() const
Get an estimate of the number of documents indexed by this term.
double get_maxweight() const
Return an upper bound on what get_weight() can return.
The frequencies for a term.
unsigned XAPIAN_DOCID_BASE_TYPE doccount
A count of documents.
Definition: types.h:38
PostList * r
Right sub-postlist.
Xapian::termcount count_matching_subqs() const
Count the number of leaf subqueries which match at the current position.
Xapian::docid get_docid() const
Return the current docid.
unsigned XAPIAN_DOCID_BASE_TYPE docid
A unique identifier for a document.
Definition: types.h:52
bool at_end() const
Return true if the current position is past the last entry in this list.
Xapian::doccount get_termfreq_max() const
Get an upper bound on the number of documents indexed by this term.
Xapian::docid rhead