xapian-core  2.0.0
vectortermlist.cc
Go to the documentation of this file.
1 
4 /* Copyright (C) 2011,2015,2024 Olly Betts
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License as
8  * published by the Free Software Foundation; either version 2 of the
9  * License, or (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 "vectortermlist.h"
24 
25 #include "omassert.h"
26 #include "pack.h"
27 #include "xapian/error.h"
28 
29 using namespace std;
30 
33 {
34  return num_terms;
35 }
36 
39 {
40  // Check we've started but not reached the end.
41  Assert(p != data.data());
42  Assert(p != NULL);
43  return 1;
44 }
45 
48 {
49  throw Xapian::InvalidOperationError("VectorTermList::get_termfreq() not meaningful");
50 }
51 
52 TermList *
54 {
55  // Check we've not reached the end.
56  Assert(p != NULL);
57 
58  const char * end = data.data() + data.size();
59  if (p == end) {
60  return this;
61  }
62  if (!unpack_string(&p, end, current_term)) {
64  }
65 
66  return NULL;
67 }
68 
69 TermList*
71 {
72  // skip_to only makes sense for termlists which are in sorted order.
73  throw Xapian::InvalidOperationError("VectorTermList::skip_to() not meaningful");
74 }
75 
78 {
79  throw Xapian::InvalidOperationError("VectorTermList::positionlist_count() not meaningful");
80 }
81 
84 {
85  throw Xapian::InvalidOperationError("VectorTermList::positionlist_begin() not meaningful");
86 }
TermList * skip_to(std::string_view)
Skip forward to the specified term.
Xapian::termcount get_approx_size() const
Return approximate size of this termlist.
Xapian::doccount get_termfreq() const
Return the term frequency for the term at the current position.
Xapian::termcount get_wdf() const
Return the wdf for the term at the current position.
PositionList * positionlist_begin() const
Return PositionList for the current position.
Xapian::termcount positionlist_count() const
Return the length of the position list for the current position.
TermList * next()
Advance the current position to the next term in the termlist.
InvalidOperationError indicates the API was used in an invalid way.
Definition: error.h:271
Abstract base class for iterating term positions in a document.
Definition: positionlist.h:32
Abstract base class for termlists.
Definition: termlist.h:42
PositionList * p
Hierarchy of classes which Xapian can throw as exceptions.
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
void unpack_throw_serialisation_error(const char *p)
Throw appropriate SerialisationError.
Definition: pack.cc:29
Pack types into strings and unpack them again.
bool unpack_string(const char **p, const char *end, std::string &result)
Decode a std::string from a string.
Definition: pack.h:468
A vector-like container of terms which can be iterated.