xapian-core  2.0.0
multi_termlist.cc
Go to the documentation of this file.
1 
4 /* Copyright (C) 2007,2008,2009,2011,2017,2024 Olly Betts
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, see
18  * <https://www.gnu.org/licenses/>.
19  */
20 
21 #include <config.h>
22 
23 #include "multi_termlist.h"
24 
25 #include <xapian/database.h>
26 
28 #include "backends/multi.h"
29 #include "omassert.h"
30 
31 using namespace std;
32 
34  TermList* real_termlist_)
35  : real_termlist(real_termlist_), db(db_)
36 {
37 }
38 
40 {
41  delete real_termlist;
42 }
43 
46 {
48 }
49 
52 {
53  return real_termlist->get_wdf();
54 }
55 
58 {
59  Xapian::doccount result;
60  db->get_freqs(real_termlist->get_termname(), &result, NULL);
61  return result;
62 }
63 
64 TermList *
66 {
67  TermList* res = real_termlist->next();
68  if (res) {
69  // No more entries (prune shouldn't happen).
70  Assert(res == real_termlist);
71  return this;
72  }
74  return NULL;
75 }
76 
77 TermList*
78 MultiTermList::skip_to(std::string_view term)
79 {
81  if (res) {
82  // No more entries (prune shouldn't happen).
83  Assert(res == real_termlist);
84  return this;
85  }
87  return NULL;
88 }
89 
92 {
94 }
95 
98 {
100 }
Xapian::termcount get_approx_size() const
Return approximate size of this termlist.
Xapian::termcount get_wdf() const
Return the wdf for the term at the current position.
Xapian::termcount positionlist_count() const
Return the length of the position list for the current position.
Internal * next()
Advance the current position to the next term in the termlist.
Internal * skip_to(std::string_view term)
Skip forward to the specified term.
PositionList * positionlist_begin() const
Return a PositionIterator for the current position.
TermList * real_termlist
The TermList in the subdatabase.
Xapian::doccount get_termfreq() const
Return the term frequency for the term at the current position.
MultiTermList(const MultiTermList &)=delete
Don't allow copying.
intrusive_ptr_nonnull< const Xapian::Database::Internal > db
The multidatabase.
~MultiTermList()
Destructor.
Virtual base class for Database internals.
virtual void get_freqs(std::string_view term, doccount *termfreq_ptr, termcount *collfreq_ptr) const =0
Returns frequencies for a term.
Abstract base class for iterating term positions in a document.
Definition: positionlist.h:32
Abstract base class for termlists.
Definition: termlist.h:42
virtual Internal * skip_to(std::string_view term)=0
Skip forward to the specified term.
virtual PositionList * positionlist_begin() const =0
Return PositionList for the current position.
std::string current_term
The current term.
Definition: termlist.h:54
virtual Internal * next()=0
Advance the current position to the next term in the termlist.
const std::string & get_termname() const
Return the termname at the current position.
Definition: termlist.h:69
virtual Xapian::termcount positionlist_count() const =0
Return the length of the position list for the current position.
virtual Xapian::termcount get_approx_size() const =0
Return approximate size of this termlist.
virtual Xapian::termcount get_wdf() const =0
Return the wdf for the term at the current position.
An indexed database of documents.
string term
Virtual base class for Database internals.
Multi-database support functions.
Adapter class for a TermList in a multidatabase.
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
Various assertion macros.
#define Assert(COND)
Definition: omassert.h:122