xapian-core  2.0.0
empty_database.h
Go to the documentation of this file.
1 
4 /* Copyright 2017,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 #ifndef XAPIAN_INCLUDED_EMPTY_DATABASE_H
22 #define XAPIAN_INCLUDED_EMPTY_DATABASE_H
23 
25 
26 #include <string_view>
27 
30  public:
32 
33  size_type size() const;
34 
35  void close();
36 
37  PostList* open_post_list(std::string_view term) const;
38 
39  LeafPostList* open_leaf_post_list(std::string_view term,
40  bool need_read_pos) const;
41 
43 
45 
46  TermList* open_allterms(std::string_view prefix) const;
47 
48  bool has_positions() const;
49 
51  std::string_view term) const;
53 
55 
57 
58  void get_freqs(std::string_view term,
59  Xapian::doccount* tf_ptr,
60  Xapian::termcount* cf_ptr) const;
61 
63 
64  std::string get_value_lower_bound(Xapian::valueno slot) const;
65 
66  std::string get_value_upper_bound(Xapian::valueno slot) const;
67 
69 
71 
72  Xapian::termcount get_wdf_upper_bound(std::string_view term) const;
73 
75 
77 
79 
81 
83  bool lazy) const;
84 
85  bool term_exists(std::string_view term) const;
86 
87  TermList* open_spelling_termlist(std::string_view word) const;
88 
90 
91  Xapian::doccount get_spelling_frequency(std::string_view word) const;
92 
93  TermList* open_synonym_termlist(std::string_view term) const;
94 
95  TermList* open_synonym_keylist(std::string_view prefix) const;
96 
97  std::string get_metadata(std::string_view key) const;
98 
99  TermList* open_metadata_keylist(std::string_view prefix) const;
100 
101  void write_changesets_to_fd(int fd,
102  std::string_view start_revision,
103  bool need_whole_db,
105 
107 
108  Xapian::rev get_revision() const;
109 
110  int get_backend_info(std::string* path) const;
111 
112  void commit();
113 
114  void cancel();
115 
116  void begin_transaction(bool flushed);
117 
118  // No need to overload end_transaction() - the base class implementation
119  // will fail with InvalidOperationError "not in a transaction" which seems
120  // totally appropriate. We overload begin_transaction() because otherwise
121  // the transaction would start successfully whereas it's better to fail
122  // early.
123 
125 
126  void delete_document(Xapian::docid did);
127 
128  void delete_document(std::string_view term);
129 
130  void replace_document(Xapian::docid did, const Xapian::Document& doc);
131 
132  Xapian::docid replace_document(std::string_view term,
133  const Xapian::Document& doc);
134 
135  void add_spelling(std::string_view word, Xapian::termcount freqinc) const;
136 
137  Xapian::termcount remove_spelling(std::string_view word,
138  Xapian::termcount freqdec) const;
139 
140  void add_synonym(std::string_view term, std::string_view synonym) const;
141 
142  void remove_synonym(std::string_view term,
143  std::string_view synonym) const;
144 
145  void clear_synonyms(std::string_view term) const;
146 
147  void set_metadata(std::string_view key, std::string_view value);
148 
149  std::string get_description() const;
150 };
151 
152 #endif // XAPIAN_INCLUDED_EMPTY_DATABASE_H
Empty database internals.
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
Virtual base class for Database internals.
Internal(const Internal &)=delete
Don't allow copying.
Abstract base class for a document.
Class representing a document.
Definition: document.h:64
Abstract base class for postlists.
Definition: postlist.h:40
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
Virtual base class for Database internals.
The Xapian namespace contains public interfaces for the Xapian library.
Definition: compactor.cc:82
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
Information about the steps involved in performing a replication.
Definition: replication.h:32