Fix non-standard header guards
[xapian.git] / xapian-core / backends / empty_database.cc
blobc81e13899f1442fe761822e75356e698e0a56b15
1 /** @file empty_database.cc
2 * @brief Empty database internals
3 */
4 /* Copyright (C) 2017 Olly Betts
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.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 #include <config.h>
21 #include "empty_database.h"
23 #include "backends.h"
24 #include "omassert.h"
25 #include "xapian/error.h"
27 using namespace std;
29 [[noreturn]]
30 static void no_subdatabases()
32 throw Xapian::InvalidOperationError("No subdatabases");
35 EmptyDatabase::size_type
36 EmptyDatabase::size() const
38 return 0;
41 void
42 EmptyDatabase::close()
46 PostList*
47 EmptyDatabase::open_post_list(const string&) const
49 return NULL;
52 LeafPostList*
53 EmptyDatabase::open_leaf_post_list(const string&, bool) const
55 return NULL;
58 TermList*
59 EmptyDatabase::open_term_list(Xapian::docid) const
61 no_subdatabases();
62 return NULL;
65 TermList*
66 EmptyDatabase::open_term_list_direct(Xapian::docid) const
68 no_subdatabases();
69 return NULL;
72 TermList*
73 EmptyDatabase::open_allterms(const string&) const
75 return NULL;
78 bool
79 EmptyDatabase::has_positions() const
81 return false;
84 PositionList*
85 EmptyDatabase::open_position_list(Xapian::docid, const string&) const
87 no_subdatabases();
88 return NULL;
91 Xapian::doccount
92 EmptyDatabase::get_doccount() const
94 return 0;
97 Xapian::docid
98 EmptyDatabase::get_lastdocid() const
100 return 0;
103 Xapian::totallength
104 EmptyDatabase::get_total_length() const
106 return 0;
109 void
110 EmptyDatabase::get_freqs(const string& term,
111 Xapian::doccount* tf_ptr,
112 Xapian::termcount* cf_ptr) const
114 Assert(!term.empty());
115 (void)term;
117 if (tf_ptr)
118 *tf_ptr = 0;
119 if (cf_ptr)
120 *cf_ptr = 0;
123 Xapian::doccount
124 EmptyDatabase::get_value_freq(Xapian::valueno) const
126 return 0;
129 string
130 EmptyDatabase::get_value_lower_bound(Xapian::valueno) const
132 return string();
135 string
136 EmptyDatabase::get_value_upper_bound(Xapian::valueno) const
138 return string();
141 Xapian::termcount
142 EmptyDatabase::get_doclength_lower_bound() const
144 return 0;
147 Xapian::termcount
148 EmptyDatabase::get_doclength_upper_bound() const
150 return 0;
153 Xapian::termcount
154 EmptyDatabase::get_wdf_upper_bound(const string& term) const
156 Assert(!term.empty());
157 (void)term;
158 return 0;
161 ValueList*
162 EmptyDatabase::open_value_list(Xapian::valueno) const
164 return NULL;
167 Xapian::termcount
168 EmptyDatabase::get_doclength(Xapian::docid did) const
170 Assert(did != 0);
171 (void)did;
172 no_subdatabases();
173 return 0;
176 Xapian::termcount
177 EmptyDatabase::get_unique_terms(Xapian::docid did) const
179 Assert(did != 0);
180 (void)did;
181 no_subdatabases();
182 return 0;
185 Xapian::Document::Internal*
186 EmptyDatabase::open_document(Xapian::docid did, bool) const
188 Assert(did != 0);
189 (void)did;
190 no_subdatabases();
191 return NULL;
194 bool
195 EmptyDatabase::term_exists(const string&) const
197 return false;
200 TermList*
201 EmptyDatabase::open_spelling_termlist(const string&) const
203 return NULL;
206 TermList*
207 EmptyDatabase::open_spelling_wordlist() const
209 return NULL;
212 Xapian::doccount
213 EmptyDatabase::get_spelling_frequency(const string&) const
215 return 0;
218 TermList*
219 EmptyDatabase::open_synonym_termlist(const string&) const
221 return NULL;
224 TermList*
225 EmptyDatabase::open_synonym_keylist(const string&) const
227 return NULL;
230 string
231 EmptyDatabase::get_metadata(const string&) const
233 return string();
236 TermList*
237 EmptyDatabase::open_metadata_keylist(const string&) const
239 return NULL;
242 void
243 EmptyDatabase::write_changesets_to_fd(int,
244 const std::string&,
245 bool,
246 Xapian::ReplicationInfo*)
248 throw Xapian::InvalidOperationError("write_changesets_to_fd() with "
249 "no subdatabases");
252 Xapian::rev
253 EmptyDatabase::get_revision() const
255 throw Xapian::InvalidOperationError("Database::get_revision() with "
256 "no subdatabases");
259 void
260 EmptyDatabase::invalidate_doc_object(Xapian::Document::Internal*) const
262 // This method should only be called on a single shard.
263 Assert(false);
267 EmptyDatabase::get_backend_info(string*) const
269 // This method should only be called on a single shard.
270 Assert(false);
271 return BACKEND_UNKNOWN;
274 void
275 EmptyDatabase::commit()
277 no_subdatabases();
280 void
281 EmptyDatabase::cancel()
285 void
286 EmptyDatabase::begin_transaction(bool)
288 no_subdatabases();
291 void
292 EmptyDatabase::end_transaction_(bool)
294 no_subdatabases();
297 Xapian::docid
298 EmptyDatabase::add_document(const Xapian::Document&)
300 no_subdatabases();
301 return 0;
304 void
305 EmptyDatabase::delete_document(Xapian::docid)
307 no_subdatabases();
310 void
311 EmptyDatabase::delete_document(const string&)
313 no_subdatabases();
316 void
317 EmptyDatabase::replace_document(Xapian::docid, const Xapian::Document&)
319 no_subdatabases();
322 Xapian::docid
323 EmptyDatabase::replace_document(const string&, const Xapian::Document&)
325 no_subdatabases();
326 return 0;
329 void
330 EmptyDatabase::add_spelling(const string&, Xapian::termcount) const
332 no_subdatabases();
335 Xapian::termcount
336 EmptyDatabase::remove_spelling(const string&, Xapian::termcount) const
338 no_subdatabases();
339 return 0;
342 void
343 EmptyDatabase::add_synonym(const string&, const string&) const
345 no_subdatabases();
348 void
349 EmptyDatabase::remove_synonym(const string&, const string&) const
351 no_subdatabases();
354 void
355 EmptyDatabase::clear_synonyms(const string&) const
357 no_subdatabases();
360 void
361 EmptyDatabase::set_metadata(const string&, const string&)
363 no_subdatabases();
366 string
367 EmptyDatabase::get_description() const
369 return string();