xapian-core  2.0.0
empty_database.cc
Go to the documentation of this file.
1 
4 /* Copyright (C) 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  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, see
16  * <https://www.gnu.org/licenses/>.
17  */
18 
19 #include <config.h>
20 
21 #include "empty_database.h"
22 
23 #include "backends.h"
24 #include "omassert.h"
25 #include "xapian/error.h"
26 
27 #include <string_view>
28 
29 using namespace std;
30 
31 [[noreturn]]
32 static void no_subdatabases()
33 {
34  throw Xapian::InvalidOperationError("No subdatabases");
35 }
36 
39 {
40  return 0;
41 }
42 
43 void
45 {
46 }
47 
48 PostList*
50 {
51  return NULL;
52 }
53 
55 EmptyDatabase::open_leaf_post_list(string_view, bool) const
56 {
57  return NULL;
58 }
59 
60 TermList*
62 {
64 }
65 
66 TermList*
68 {
70 }
71 
72 TermList*
73 EmptyDatabase::open_allterms(string_view) const
74 {
75  return NULL;
76 }
77 
78 bool
80 {
81  return false;
82 }
83 
86 {
88 }
89 
92 {
93  return 0;
94 }
95 
98 {
99  return 0;
100 }
101 
104 {
105  return 0;
106 }
107 
108 void
110  Xapian::doccount* tf_ptr,
111  Xapian::termcount* cf_ptr) const
112 {
113  Assert(!term.empty());
114  (void)term;
115 
116  if (tf_ptr)
117  *tf_ptr = 0;
118  if (cf_ptr)
119  *cf_ptr = 0;
120 }
121 
124 {
125  return 0;
126 }
127 
128 string
130 {
131  return string();
132 }
133 
134 string
136 {
137  return string();
138 }
139 
142 {
143  return 0;
144 }
145 
148 {
149  return 0;
150 }
151 
154 {
155  Assert(!term.empty());
156  (void)term;
157  return 0;
158 }
159 
160 ValueList*
162 {
163  return NULL;
164 }
165 
168 {
169  Assert(did != 0);
170  (void)did;
171  no_subdatabases();
172 }
173 
176 {
177  Assert(did != 0);
178  (void)did;
179  no_subdatabases();
180 }
181 
184 {
185  Assert(did != 0);
186  (void)did;
187  no_subdatabases();
188 }
189 
192 {
193  Assert(did != 0);
194  (void)did;
195  no_subdatabases();
196 }
197 
198 bool
199 EmptyDatabase::term_exists(string_view) const
200 {
201  return false;
202 }
203 
204 TermList*
206 {
207  return NULL;
208 }
209 
210 TermList*
212 {
213  return NULL;
214 }
215 
218 {
219  return 0;
220 }
221 
222 TermList*
224 {
225  return NULL;
226 }
227 
228 TermList*
230 {
231  return NULL;
232 }
233 
234 string
235 EmptyDatabase::get_metadata(string_view) const
236 {
237  return string();
238 }
239 
240 TermList*
242 {
243  return NULL;
244 }
245 
246 void
248  std::string_view,
249  bool,
251 {
252  throw Xapian::InvalidOperationError("write_changesets_to_fd() with "
253  "no subdatabases");
254 }
255 
258 {
259  return 0;
260 }
261 
262 void
264 {
265  // This method should only be called on a single shard.
266  Assert(false);
267 }
268 
269 int
271 {
272  // This method should only be called on a single shard.
273  Assert(false);
274  return BACKEND_UNKNOWN;
275 }
276 
277 void
279 {
280  no_subdatabases();
281 }
282 
283 void
285 {
286 }
287 
288 void
290 {
291  no_subdatabases();
292 }
293 
296 {
297  no_subdatabases();
298 }
299 
300 void
302 {
303  no_subdatabases();
304 }
305 
306 void
308 {
309  no_subdatabases();
310 }
311 
312 void
314 {
315  no_subdatabases();
316 }
317 
320 {
321  no_subdatabases();
322 }
323 
324 void
326 {
327  no_subdatabases();
328 }
329 
332 {
333  no_subdatabases();
334 }
335 
336 void
337 EmptyDatabase::add_synonym(string_view, string_view) const
338 {
339  no_subdatabases();
340 }
341 
342 void
343 EmptyDatabase::remove_synonym(string_view, string_view) const
344 {
345  no_subdatabases();
346 }
347 
348 void
350 {
351  no_subdatabases();
352 }
353 
354 void
355 EmptyDatabase::set_metadata(string_view, string_view)
356 {
357  no_subdatabases();
358 }
359 
360 string
362 {
363  return string();
364 }
BACKEND_* constants.
@ BACKEND_UNKNOWN
Definition: backends.h:26
Xapian::termcount get_unique_terms(Xapian::docid did) const
Get the number of unique terms in document.
Xapian::totallength get_total_length() const
Return the total length of all documents in this database.
size_type size() const
Xapian::docid add_document(const Xapian::Document &doc)
Xapian::termcount get_doclength_upper_bound() const
Get an upper bound on the length of a document in this DB.
TermList * open_term_list_direct(Xapian::docid did) const
Like open_term_list() but without MultiTermList wrapper.
Xapian::doccount get_spelling_frequency(std::string_view word) const
Return the number of times word was added as a spelling.
TermList * open_term_list(Xapian::docid did) const
bool has_positions() const
Check whether this database contains any positional information.
TermList * open_metadata_keylist(std::string_view prefix) const
Open a termlist returning each metadata key.
PostList * open_post_list(std::string_view term) const
Return a PostList suitable for use in a PostingIterator.
Xapian::termcount get_wdf_upper_bound(std::string_view term) const
Get an upper bound on the wdf of term term.
void commit()
Commit pending modifications to the database.
Xapian::docid get_lastdocid() const
Return the last used document id of this (sub) database.
int get_backend_info(std::string *path) const
Get backend information about this database.
std::string get_description() const
Return a string describing this object.
void clear_synonyms(std::string_view term) const
Clear all synonyms for a term.
void remove_synonym(std::string_view term, std::string_view synonym) const
Remove a synonym for a term.
TermList * open_synonym_keylist(std::string_view prefix) const
Open a termlist returning each term which has synonyms.
void get_freqs(std::string_view term, Xapian::doccount *tf_ptr, Xapian::termcount *cf_ptr) const
Returns frequencies for a term.
void replace_document(Xapian::docid did, const Xapian::Document &doc)
bool term_exists(std::string_view term) const
PositionList * open_position_list(Xapian::docid did, std::string_view term) const
TermList * open_spelling_termlist(std::string_view word) const
Create a termlist tree from trigrams of word.
Xapian::doccount get_value_freq(Xapian::valueno slot) const
Return the frequency of a given value slot.
std::string get_metadata(std::string_view key) const
Get the metadata associated with a given key.
Xapian::rev get_revision() const
Get revision number of database (if meaningful).
TermList * open_synonym_termlist(std::string_view term) const
Open a termlist returning synonyms for a term.
void close()
Close the database.
void delete_document(Xapian::docid did)
Xapian::termcount get_wdfdocmax(Xapian::docid did) const
Get the max wdf in document.
TermList * open_allterms(std::string_view prefix) const
Xapian::termcount get_doclength(Xapian::docid did) const
ValueList * open_value_list(Xapian::valueno slot) const
Open a value stream.
void write_changesets_to_fd(int fd, std::string_view start_revision, bool need_whole_db, Xapian::ReplicationInfo *info)
Write a set of changesets to a file descriptor.
void cancel()
Cancel pending modifications to the database.
void begin_transaction(bool flushed)
Begin transaction.
std::string get_value_lower_bound(Xapian::valueno slot) const
Get a lower bound on the values stored in the given value slot.
void add_synonym(std::string_view term, std::string_view synonym) const
Add a synonym for a term.
void set_metadata(std::string_view key, std::string_view value)
Set the metadata associated with a given key.
Xapian::termcount get_doclength_lower_bound() const
Get a lower bound on the length of a document in this DB.
void invalidate_doc_object(Xapian::Document::Internal *obj) const
Notify the database that document is no longer valid.
std::string get_value_upper_bound(Xapian::valueno slot) const
Get an upper bound on the values stored in the given value slot.
Xapian::termcount remove_spelling(std::string_view word, Xapian::termcount freqdec) const
Remove a word from the spelling dictionary.
LeafPostList * open_leaf_post_list(std::string_view term, bool need_read_pos) const
Create a LeafPostList for use during a match.
Xapian::Document::Internal * open_document(Xapian::docid did, bool lazy) const
Open a handle on a document.
Xapian::doccount get_doccount() const
void add_spelling(std::string_view word, Xapian::termcount freqinc) const
Add a word to the spelling dictionary.
TermList * open_spelling_wordlist() const
Return a termlist which returns the words which are spelling correction targets.
Abstract base class for leaf postlists.
Definition: leafpostlist.h:40
Abstract base class for a document.
Class representing a document.
Definition: document.h:64
Abstract base class for postlists.
Definition: postlist.h:40
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
Abstract base class for value streams.
Definition: valuelist.h:31
string term
static void no_subdatabases()
Empty database internals.
Hierarchy of classes which Xapian can throw as exceptions.
unsigned XAPIAN_TERMCOUNT_BASE_TYPE termcount
A counts of terms.
Definition: types.h:64
XAPIAN_REVISION_TYPE rev
Revision number of a database.
Definition: types.h:108
unsigned valueno
The number for a value slot in a document.
Definition: types.h:90
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
XAPIAN_TOTALLENGTH_TYPE totallength
The total length of all documents in a database.
Definition: types.h:114
Various assertion macros.
#define Assert(COND)
Definition: omassert.h:122
Information about the steps involved in performing a replication.
Definition: replication.h:32