35 #include <string_view>
43 #define MAGIC_XOR_VALUE 96
48 if (last_term.empty())
return;
50 if (last_synonyms.empty()) {
55 for (
auto&& synonym : last_synonyms) {
61 last_synonyms.clear();
69 if (last_term !=
term) {
74 if (get_exact_entry(
term, tag)) {
75 const char*
p = tag.data();
76 const char* end =
p + tag.size();
83 last_synonyms.insert(
string(
p, len));
89 last_synonyms.emplace(synonym);
95 if (last_term !=
term) {
100 if (get_exact_entry(
term, tag)) {
101 const char*
p = tag.data();
102 const char* end =
p + tag.size();
109 last_synonyms.emplace(
p, len);
115 #ifdef __cpp_lib_associative_heterogeneous_erasure
116 last_synonyms.erase(synonym);
118 last_synonyms.erase(
string(synonym));
130 if (last_term ==
term) {
131 last_synonyms.clear();
141 vector<string> synonyms;
143 if (last_term ==
term) {
144 if (last_synonyms.empty())
return NULL;
146 synonyms.reserve(last_synonyms.size());
147 for (
auto&& i : last_synonyms) {
148 synonyms.push_back(i);
152 if (!get_exact_entry(
term, tag))
return NULL;
154 const char*
p = tag.data();
155 const char* end =
p + tag.size();
162 synonyms.push_back(
string(
p, len));
183 auto entry_count = database->synonym_table.get_approx_entry_count();
184 return clamp_cast<Xapian::termcount>(entry_count);
198 if (cursor->after_end()) {
200 if (cursor->find_entry_ge(prefix))
205 if (cursor->after_end() || !
startswith(cursor->current_key, prefix)) {
209 current_term = cursor->current_key;
218 if (cursor->after_end() && prefix >
term) {
225 if (cursor->find_entry_ge(
term)) {
231 if (cursor->after_end() || !
startswith(cursor->current_key, prefix)) {
235 current_term = cursor->current_key;
Cast a value to a type, clamping out of range values.
void clear_synonyms(std::string_view term)
Remove all synonyms for term.
void add_synonym(std::string_view term, std::string_view synonym)
Add a synonym for term.
void remove_synonym(std::string_view term, std::string_view synonym)
Remove a synonym for term.
TermList * open_termlist(std::string_view term) const
Open synonym termlist for a term.
TermList * skip_to(std::string_view term)
Advance to the first term which is >= term.
Xapian::doccount get_termfreq() const
Return the term frequency for the term at the current position.
~HoneySynonymTermList()
Destructor.
Xapian::termcount get_approx_size() const
Return approximate size of this termlist.
TermList * next()
Advance to the next term in the list.
This class stores a list of terms.
DatabaseCorruptError indicates database corruption was detected.
InvalidOperationError indicates the API was used in an invalid way.
Abstract base class for termlists.
#define LOGCALL(CATEGORY, TYPE, FUNC, PARAMS)
#define LOGCALL_DTOR(CATEGORY, CLASS)
Hierarchy of classes which Xapian can throw as exceptions.
Database using honey backend.
Synonym data for a honey database.
unsigned XAPIAN_TERMCOUNT_BASE_TYPE termcount
A counts of terms.
unsigned XAPIAN_DOCID_BASE_TYPE doccount
A count of documents.
Various handy string-related helpers.
bool startswith(std::string_view s, char pfx)
A vector-like container of terms which can be iterated.