xapian-core  1.4.27
postlist.h
Go to the documentation of this file.
1 
4 /* Copyright (C) 2007,2008,2009,2011,2015,2017 Olly Betts
5  * Copyright (C) 2009 Lemur Consulting Ltd
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License as
9  * published by the Free Software Foundation; either version 2 of the
10  * License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20  */
21 
22 #ifndef XAPIAN_INCLUDED_POSTLIST_H
23 #define XAPIAN_INCLUDED_POSTLIST_H
24 
25 #include <string>
26 
27 #include "xapian/intrusive_ptr.h"
28 #include <xapian/types.h>
29 #include <xapian/postingiterator.h>
30 
31 #include "backends/positionlist.h"
32 #include "weight/weightinternal.h"
33 
34 class OrPositionList;
35 
39  void operator=(const Internal &);
40 
42  Internal(const Internal &);
43 
44  protected:
46  Internal() { }
47 
48  public:
52  virtual ~Internal();
53 
55  virtual Xapian::doccount get_termfreq_min() const = 0;
56 
58  virtual Xapian::doccount get_termfreq_max() const = 0;
59 
65  virtual Xapian::doccount get_termfreq_est() const = 0;
66 
74  const Xapian::Weight::Internal & stats) const;
75 
77  virtual double get_maxweight() const = 0;
78 
80  virtual Xapian::docid get_docid() const = 0;
81 
83  virtual Xapian::termcount get_doclength() const = 0;
84  /* FIXME: Once flint has been retired, we should probably strip out
85  * PostList::get_doclength() and just fetch it from the DB directly.
86  */
87 
89  virtual Xapian::termcount get_unique_terms() const = 0;
90 
95  virtual Xapian::termcount get_wdf() const;
96 
98  virtual double get_weight() const = 0;
99 
100  virtual const std::string * get_sort_key() const;
101 
108  virtual const std::string * get_collapse_key() const;
109 
111  virtual bool at_end() const = 0;
112 
121  virtual double recalc_maxweight() = 0;
122 
128  virtual PositionList * read_position_list();
129 
135  virtual PositionList * open_position_list() const;
136 
151  virtual Internal * next(double w_min) = 0;
152 
166  virtual Internal * skip_to(Xapian::docid did, double w_min) = 0;
167 
188  virtual Internal * check(Xapian::docid did, double w_min, bool &valid);
189 
194  Internal * next() { return next(0.0); }
195 
200  Internal * skip_to(Xapian::docid did) { return skip_to(did, 0.0); }
201 
203  virtual Xapian::termcount count_matching_subqs() const;
204 
206  virtual void gather_position_lists(OrPositionList* orposlist);
207 
209  virtual std::string get_description() const = 0;
210 };
211 
212 // In the external API headers, this class is Xapian::PostingIterator::Internal,
213 // but in the library code it's still known as "PostList" in most places.
215 
216 #endif // XAPIAN_INCLUDED_POSTLIST_H
Abstract base class for postlists.
Definition: postlist.h:37
typedefs for Xapian
void operator=(const Internal &)
Don&#39;t allow assignment.
virtual Xapian::docid get_docid() const =0
Return the current docid.
virtual void gather_position_lists(OrPositionList *orposlist)
Gather PositionList* objects for a subtree.
virtual Internal * skip_to(Xapian::docid did, double w_min)=0
Skip forward to the specified docid.
virtual double recalc_maxweight()=0
Recalculate the upper bound on what get_weight() can return.
Abstract base class for iterating term positions in a document.
virtual const std::string * get_collapse_key() const
If the collapse key is already known, return it.
Definition: postlist.cc:56
virtual Xapian::termcount get_unique_terms() const =0
Return the number of unique terms in the current document.
Xapian::PostingIterator::Internal PostList
Definition: postlist.h:214
virtual Internal * check(Xapian::docid did, double w_min, bool &valid)
Check if the specified docid occurs in this postlist.
unsigned XAPIAN_TERMCOUNT_BASE_TYPE termcount
A counts of terms.
Definition: types.h:72
virtual const std::string * get_sort_key() const
Definition: postlist.cc:50
virtual TermFreqs get_termfreq_est_using_stats(const Xapian::Weight::Internal &stats) const
Get an estimate for the termfreq and reltermfreq, given the stats.
Definition: postlist.cc:36
virtual Xapian::doccount get_termfreq_max() const =0
Get an upper bound on the number of documents indexed by this term.
virtual Xapian::doccount get_termfreq_est() const =0
Get an estimate of the number of documents indexed by this term.
Xapian::Weight::Internal class, holding database and term statistics.
virtual Xapian::doccount get_termfreq_min() const =0
Get a lower bound on the number of documents indexed by this term.
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
Internal * skip_to(Xapian::docid did)
Skip forward to the specified docid.
Definition: postlist.h:200
virtual PositionList * read_position_list()
Read the position list for the term in the current document and return a pointer to it (owned by the ...
Base class for objects managed by intrusive_ptr.
Definition: intrusive_ptr.h:49
virtual PositionList * open_position_list() const
Read the position list for the term in the current document and return a pointer to it (not owned by ...
Internal()
Only constructable as a base class for derived classes.
Definition: postlist.h:46
virtual ~Internal()
We have virtual methods and want to be able to delete derived classes using a pointer to the base cla...
Definition: postlist.cc:33
virtual double get_maxweight() const =0
Return an upper bound on what get_weight() can return.
The frequencies for a term.
virtual Xapian::termcount get_doclength() const =0
Return the length of current document.
virtual std::string get_description() const =0
Return a string description of this object.
unsigned XAPIAN_DOCID_BASE_TYPE doccount
A count of documents.
Definition: types.h:38
virtual Xapian::termcount count_matching_subqs() const
Count the number of leaf subqueries which match at the current position.
virtual bool at_end() const =0
Return true if the current position is past the last entry in this list.
Class for iterating over a list of document ids.
unsigned XAPIAN_DOCID_BASE_TYPE docid
A unique identifier for a document.
Definition: types.h:52
Abstract base class for iterating term positions in a document.
Definition: positionlist.h:31
virtual Xapian::termcount get_wdf() const
Return the wdf for the document at the current position.
Definition: postlist.cc:44
virtual double get_weight() const =0
Return the weight contribution for the current position.