xapian-core  2.0.0
multi_postlist.h
Go to the documentation of this file.
1 
4 /* Copyright (C) 2007,2008,2009,2011,2015,2017,2020 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, see
19  * <https://www.gnu.org/licenses/>.
20  */
21 
22 #ifndef XAPIAN_INCLUDED_MULTI_POSTLIST_H
23 #define XAPIAN_INCLUDED_MULTI_POSTLIST_H
24 
25 #include <string>
26 
27 #include "backends/postlist.h"
28 #include "backends/positionlist.h"
29 
31 class MultiPostList : public PostList {
33  void operator=(const MultiPostList &) = delete;
34 
36  MultiPostList(const MultiPostList &) = delete;
37 
40 
43 
46 
48  Xapian::docid* docids = nullptr;
49 
50  public:
52  MultiPostList(Xapian::doccount n_shards_, PostList** postlists_)
53  : n_shards(n_shards_), postlists(postlists_)
54  {
55  try {
57  } catch (...) {
58  delete [] postlists;
59  throw;
60  }
61  // MultiPostList is only used by PostingIterator which should never
62  // read the termfreq so leave it uninitialised so that ubsan or
63  // valgrind can at least pick up unintended uses.
64 #if 0
65  termfreq = 0;
66  for (Xapian::doccount i = 0; i < n_shards_; ++i) {
68  }
69 #endif
70  }
71 
74 
76  Xapian::docid get_docid() const;
77 
79  Xapian::termcount get_wdf() const;
80 
82  double get_weight(Xapian::termcount doclen,
83  Xapian::termcount unique_terms,
84  Xapian::termcount wdfdocmax) const;
85 
87  bool at_end() const;
88 
90  double recalc_maxweight();
91 
94 
109  PostList* next(double w_min);
110 
124  PostList* skip_to(Xapian::docid, double w_min);
125 
126  // We don't implement check() because we're only used in a PostingIterator
127  // wrapper and that doesn't call check().
128  //
129  // Should that change, we could handle check() a bit more efficiently with
130  // some extra bookkeeping on operations after check(), because we know
131  // which subdatabase a given docid will be in, and so we only actually need
132  // to call check() on that subdatabase.
133 
135  std::string get_description() const;
136 };
137 
138 #endif // XAPIAN_INCLUDED_MULTI_POSTLIST_H
Class for merging PostList objects from subdatabases.
PostList ** postlists
Sub-postlists which we use as a heap.
bool at_end() const
Return true if the current position is past the last entry in this list.
std::string get_description() const
Return a string description of this object.
double get_weight(Xapian::termcount doclen, Xapian::termcount unique_terms, Xapian::termcount wdfdocmax) const
Return the weight contribution for the current position.
~MultiPostList()
Destructor.
PositionList * open_position_list() const
Read the position list for the term in the current document and.
Xapian::docid get_docid() const
Return the current docid.
MultiPostList(const MultiPostList &)=delete
Don't allow copying.
Xapian::doccount n_shards
Number of PostList* entries in postlists.
Xapian::termcount get_wdf() const
Return the wdf for the document at the current position.
double recalc_maxweight()
Recalculate the upper bound on what get_weight() can return.
void operator=(const MultiPostList &)=delete
Don't allow assignment.
Xapian::docid * docids
Heap of docids from the current positions of the postlists.
PostList * skip_to(Xapian::docid, double w_min)
Skip forward to the specified docid.
Xapian::doccount docids_size
Number of entries in docids;.
MultiPostList(Xapian::doccount n_shards_, PostList **postlists_)
Constructor.
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
Abstract base class for iterating term positions in a document.
Definition: positionlist.h:32
unsigned XAPIAN_TERMCOUNT_BASE_TYPE termcount
A counts of terms.
Definition: types.h:64
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
Abstract base class for iterating term positions in a document.
Abstract base class for postlists.