xapian-core  1.4.25
multixorpostlist.h
Go to the documentation of this file.
1 
4 /* Copyright (C) 2007,2009,2010,2011,2012 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_MULTIXORPOSTLIST_H
23 #define XAPIAN_INCLUDED_MULTIXORPOSTLIST_H
24 
25 #include "multimatch.h"
26 #include "api/postlist.h"
27 #include <algorithm>
28 
29 class MultiMatch;
30 
32 class MultiXorPostList : public PostList {
34  void operator=(const MultiXorPostList &);
35 
38 
41 
43  size_t n_kids;
44 
47 
49  double max_total;
50 
53 
56 
58  void erase_sublist(size_t i) {
59  delete plist[i];
60  --n_kids;
61  for (size_t j = i; j < n_kids; ++j) {
62  plist[j] = plist[j + 1];
63  }
64  matcher->recalc_maxweight();
65  }
66 
67  public:
71  template<class RandomItor>
72  MultiXorPostList(RandomItor pl_begin, RandomItor pl_end,
73  MultiMatch * matcher_, Xapian::doccount db_size_)
74  : did(0), n_kids(pl_end - pl_begin), plist(NULL),
75  max_total(0), db_size(db_size_), matcher(matcher_)
76  {
77  plist = new PostList * [n_kids];
78  std::copy(pl_begin, pl_end, plist);
79  }
80 
82 
84 
86 
88 
90  const Xapian::Weight::Internal & stats) const;
91 
92  double get_maxweight() const;
93 
94  Xapian::docid get_docid() const;
95 
97 
99 
100  double get_weight() const;
101 
102  bool at_end() const;
103 
104  double recalc_maxweight();
105 
107  return NULL;
108  }
109 
110  PostList* next(double w_min);
111 
112  PostList* skip_to(Xapian::docid, double w_min);
113 
114  std::string get_description() const;
115 
123  Xapian::termcount get_wdf() const;
124 
126 };
127 
128 #endif // XAPIAN_INCLUDED_MULTIXORPOSTLIST_H
double recalc_maxweight()
Recalculate the upper bound on what get_weight() can return.
Abstract base class for postlists.
Definition: postlist.h:37
bool at_end() const
Return true if the current position is past the last entry in this list.
Xapian::doccount get_termfreq_est() const
Get an estimate of the number of documents indexed by this term.
N-way XOR postlist.
class for performing a match
size_t n_kids
The number of sub-postlists.
Xapian::docid get_docid() const
Return the current docid.
Xapian::docid did
The current docid, or zero if we haven&#39;t started or are at_end.
Abstract base class for postlists.
MultiXorPostList(const MultiXorPostList &)
Don&#39;t allow copying.
void operator=(const MultiXorPostList &)
Don&#39;t allow assignment.
unsigned XAPIAN_TERMCOUNT_BASE_TYPE termcount
A counts of terms.
Definition: types.h:72
Xapian::termcount count_matching_subqs() const
Count the number of leaf subqueries which match at the current position.
MultiXorPostList(RandomItor pl_begin, RandomItor pl_end, MultiMatch *matcher_, Xapian::doccount db_size_)
Construct from 2 random-access iterators to a container of PostList*, a pointer to the matcher...
Xapian::doccount get_termfreq_max() const
Get an upper bound on the number of documents indexed by this term.
Xapian::doccount get_termfreq_min() const
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
void recalc_maxweight()
Called by postlists to indicate that they&#39;ve rearranged themselves and the maxweight now possible is ...
Definition: multimatch.h:136
void erase_sublist(size_t i)
Erase a sub-postlist.
PostList ** plist
Array of pointers to sub-postlists.
Xapian::doccount db_size
The number of documents in the database.
Xapian::termcount get_unique_terms() const
Return the number of unique terms in the current document.
double get_weight() const
Return the weight contribution for the current position.
double max_total
Total maximum weight the XOR could possibly return.
PositionList * read_position_list()
Read the position list for the term in the current document and return a pointer to it (owned by the ...
PostList * skip_to(Xapian::docid, double w_min)
Skip forward to the specified docid.
The frequencies for a term.
unsigned XAPIAN_DOCID_BASE_TYPE doccount
A count of documents.
Definition: types.h:38
Xapian::termcount get_doclength() const
Return the length of current document.
std::string get_description() const
Return a string description of this object.
MultiMatch * matcher
Pointer to the matcher object, so we can report pruning.
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
TermFreqs get_termfreq_est_using_stats(const Xapian::Weight::Internal &stats) const
Get an estimate for the termfreq and reltermfreq, given the stats.
Xapian::termcount get_wdf() const
get_wdf() for MultiXorPostlists returns the sum of the wdfs of the sub postlists which match the curr...
double get_maxweight() const
Return an upper bound on what get_weight() can return.