Fix @file doc comments which don't match filename
[xapian.git] / xapian-core / backends / multi / multi_database.h
blobb2b2dc4233c715f033adf32874abd621c55730d6
1 /** @file multi_database.h
2 * @brief Sharded database backend
3 */
4 /* Copyright 2017 Olly Betts
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.
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.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21 #ifndef XAPIAN_INCLUDED_MULTI_DATABASE_H
22 #define XAPIAN_INCLUDED_MULTI_DATABASE_H
24 #include "api/postlist.h"
25 #include "api/termlist.h"
26 #include "backends/databaseinternal.h"
27 #include "backends/valuelist.h"
29 class Matcher;
30 class ValueStreamDocument;
32 namespace Xapian {
33 struct ReplicationInfo;
36 /// Sharded database backend.
37 class MultiDatabase : public Xapian::Database::Internal {
38 friend class Matcher;
39 friend class ValueStreamDocument;
40 friend class Xapian::Database;
42 Xapian::SmallVectorI<Xapian::Database::Internal> shards;
44 public:
45 explicit MultiDatabase(size_type reserve_size, bool read_only)
46 : Xapian::Database::Internal(read_only ?
47 TRANSACTION_READONLY :
48 TRANSACTION_NONE),
49 shards(reserve_size) {}
51 size_type size() const;
53 void reserve(size_type new_size) { shards.reserve(new_size); }
55 void push_back(Xapian::Database::Internal* shard) {
56 shards.push_back(shard);
59 bool reopen();
61 void close();
63 PostList* open_post_list(const std::string& term) const;
65 LeafPostList* open_leaf_post_list(const std::string& term,
66 bool need_pos) const;
68 TermList* open_term_list(Xapian::docid did) const;
70 TermList* open_term_list_direct(Xapian::docid did) const;
72 TermList* open_allterms(const std::string& prefix) const;
74 bool has_positions() const;
76 PositionList* open_position_list(Xapian::docid did,
77 const std::string& term) const;
78 Xapian::doccount get_doccount() const;
80 Xapian::docid get_lastdocid() const;
82 Xapian::totallength get_total_length() const;
84 void get_freqs(const std::string& term,
85 Xapian::doccount* tf_ptr,
86 Xapian::termcount* cf_ptr) const;
88 Xapian::doccount get_value_freq(Xapian::valueno slot) const;
90 std::string get_value_lower_bound(Xapian::valueno slot) const;
92 std::string get_value_upper_bound(Xapian::valueno slot) const;
94 Xapian::termcount get_doclength_lower_bound() const;
96 Xapian::termcount get_doclength_upper_bound() const;
98 Xapian::termcount get_wdf_upper_bound(const std::string& term) const;
100 ValueList* open_value_list(Xapian::valueno slot) const;
102 Xapian::termcount get_doclength(Xapian::docid did) const;
104 Xapian::termcount get_unique_terms(Xapian::docid did) const;
106 Xapian::Document::Internal* open_document(Xapian::docid did,
107 bool lazy) const;
109 bool term_exists(const std::string& term) const;
111 void keep_alive();
113 TermList* open_spelling_termlist(const std::string& word) const;
115 TermList* open_spelling_wordlist() const;
117 Xapian::doccount get_spelling_frequency(const std::string& word) const;
119 TermList* open_synonym_termlist(const std::string& term) const;
121 TermList* open_synonym_keylist(const std::string& prefix) const;
123 std::string get_metadata(const std::string& key) const;
125 TermList* open_metadata_keylist(const std::string& prefix) const;
127 std::string get_uuid() const;
129 bool locked() const;
131 void write_changesets_to_fd(int fd,
132 const std::string& start_revision,
133 bool need_whole_db,
134 Xapian::ReplicationInfo* info);
136 void invalidate_doc_object(Xapian::Document::Internal* obj) const;
138 Xapian::rev get_revision() const;
140 int get_backend_info(std::string* path) const;
142 void commit();
144 void cancel();
146 void begin_transaction(bool flushed);
148 void end_transaction_(bool do_commit);
150 Xapian::docid add_document(const Xapian::Document& doc);
152 void delete_document(Xapian::docid did);
154 void delete_document(const std::string& term);
156 void replace_document(Xapian::docid did, const Xapian::Document& doc);
158 Xapian::docid replace_document(const std::string& term,
159 const Xapian::Document& doc);
161 void request_document(Xapian::docid did) const;
163 void add_spelling(const std::string& word, Xapian::termcount freqinc) const;
165 Xapian::termcount remove_spelling(const std::string& word,
166 Xapian::termcount freqdec) const;
168 void add_synonym(const std::string& term, const std::string& synonym) const;
170 void remove_synonym(const std::string& term,
171 const std::string& synonym) const;
173 void clear_synonyms(const std::string& term) const;
175 void set_metadata(const std::string& key, const std::string& value);
177 std::string get_description() const;
180 #endif // XAPIAN_INCLUDED_MULTI_DATABASE_H