38 const vector<PostList*>::const_iterator &terms_begin,
39 const vector<PostList*>::const_iterator &terms_end)
40 :
SelectPostList(source_), window(window_), terms(terms_begin, terms_end)
42 size_t n =
terms.size();
67 LOGCALL(MATCH,
bool,
"NearPostList::test_doc", NO_ARGS);
78 if (!poslists[0]->
next())
85 if (last - poslists[0]->get_position() <
window) {
86 if (
size_t(end - poslists) !=
terms.size()) {
99 if (pos > last) last = pos;
101 push_heap<PositionList **, Cmp>(
poslists, end,
Cmp());
114 pop_heap<PositionList **, Cmp>(
poslists, i,
Cmp());
117 pop_heap<PositionList **, Cmp>(
poslists, i,
Cmp());
118 if ((*--i)->get_position() == pos) {
122 if (newpos - end[-1]->get_position() >=
window) {
127 push_heap<PositionList **, Cmp>(
poslists, ++i,
Cmp());
130 pos = (*i)->get_position();
137 make_heap<PositionList **, Cmp>(
poslists, end,
Cmp());
140 pop_heap<PositionList **, Cmp>(
poslists, end,
Cmp());
143 last = max(last, end[-1]->get_position());
144 push_heap<PositionList **, Cmp>(
poslists, end,
Cmp());
192 vector<PostList *>::const_iterator i =
terms.begin();
194 while (++i !=
terms.end()) {
195 wdf = min(wdf, (*i)->get_wdf());
213 LOGCALL(MATCH,
TermFreqs,
"NearPostList::get_termfreq_est_using_stats", stats);
218 result.reltermfreq /= 2;
219 result.collfreq /= 2;
TermFreqs get_termfreq_est_using_stats(const Xapian::Weight::Internal &stats) const
Get an estimate for the termfreq and reltermfreq, given the stats.
Abstract base class for postlists.
Xapian::termcount get_wdf() const
Return the wdf for the document at the current position.
virtual bool next()=0
Advance to the next entry in the positionlist.
Abstract base class for iterating term positions in a document.
Convert types to std::string.
std::vector< PostList * > terms
Xapian::doccount termfreq
unsigned XAPIAN_TERMCOUNT_BASE_TYPE termcount
A counts of terms.
virtual bool skip_to(Xapian::termpos termpos)=0
Skip forward to the specified position.
bool test_doc()
Test if the current document contains the terms within the window.
virtual TermFreqs get_termfreq_est_using_stats(const Xapian::Weight::Internal &stats) const
Get an estimate for the termfreq and reltermfreq, given the stats.
bool operator()(const PostList *a, const PostList *b) const
virtual Xapian::doccount get_termfreq_est() const =0
Get an estimate of 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.
string str(int value)
Convert int to std::string.
NearPostList(PostList *source_, Xapian::termpos window_, const std::vector< PostList *>::const_iterator &terms_begin, const std::vector< PostList *>::const_iterator &terms_end)
Return docs containing terms within a specified window.
virtual Xapian::termpos get_position() const =0
Return the current position.
Xapian::doccount get_termfreq_est() const
Get an estimate of the number of documents indexed by this term.
A postlist parent class for classes which only return selected docs from a source postlist (e...
PostList * skip_to(Xapian::docid did, double w_min)
Skip forward to the specified docid.
The frequencies for a term.
virtual std::string get_description() const =0
Return a string description of this object.
unsigned XAPIAN_DOCID_BASE_TYPE doccount
A count of documents.
bool operator()(const PositionList *a, const PositionList *b) const
std::string get_description() const
Return a string description of this object.
unsigned XAPIAN_TERMPOS_BASE_TYPE termpos
A term position within a document or query.
Various assertion macros.
Abstract base class for iterating term positions in a document.
virtual Xapian::termcount get_wdf() const
Return the wdf for the document at the current position.
#define LOGCALL(CATEGORY, TYPE, FUNC, PARAMS)