xapian-core  2.0.0
remote_keylist.cc
Go to the documentation of this file.
1 
4 /* Copyright (C) 2007,2008,2018,2020,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 "remote_keylist.h"
24 
25 #include "omassert.h"
26 #include "pack.h"
27 
28 using namespace std;
29 
32 {
33  // Very approximate! This is only used to build a balanced or tree, so
34  // at least we'll get an even tree by returning a constant answer.
35  return 1;
36 }
37 
40 {
41  // Not really meaningful.
42  return 0;
43 }
44 
45 TermList*
47 {
48  if (!p) {
49  p = data.data();
50  }
51  const char* p_end = data.data() + data.size();
52  if (p == p_end) {
53  return this;
54  }
55  current_term.resize(size_t(static_cast<unsigned char>(*p++)));
56  if (!unpack_string_append(&p, p_end, current_term)) {
58  }
59  return NULL;
60 }
61 
62 TermList*
63 RemoteKeyList::skip_to(std::string_view term)
64 {
65  if (!p) {
66  if (RemoteKeyList::next())
67  return this;
68  }
69  while (current_term < term) {
70  if (RemoteKeyList::next())
71  return this;
72  }
73  return NULL;
74 }
TermList * next()
Advance the current position to the next term in the termlist.
Xapian::doccount get_termfreq() const
Return the term frequency for the term at the current position.
Xapian::termcount get_approx_size() const
Return approximate size of this termlist.
TermList * skip_to(std::string_view term)
Skip forward to the specified term.
Abstract base class for termlists.
Definition: termlist.h:42
string term
PositionList * p
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.
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_append(const char **p, const char *end, std::string &result)
Decode a std::string from a string and append.
Definition: pack.h:493
Iterate keys in a remote database.