43 #include "../flint_lock.h"
67 #include <sys/types.h>
93 #define MAX_SAFE_TERM_LENGTH 245
99 unsigned int block_size)
101 readonly(flags ==
Xapian::DB_READONLY_),
102 version_file(db_dir),
103 postlist_table(db_dir, readonly),
104 position_table(db_dir, readonly),
108 value_manager(&postlist_table, &termlist_table),
109 synonym_table(db_dir, readonly),
110 spelling_table(db_dir, readonly),
111 docdata_table(db_dir, readonly),
115 LOGCALL_CTOR(DB,
"GlassDatabase", glass_dir | flags | block_size);
123 if (block_size < 2048 || block_size > 65536 ||
124 (block_size & (block_size - 1)) != 0) {
128 int action = flags & Xapian::DB_ACTION_MASK_;
132 if (mkdir(
db_dir.c_str(), 0755) < 0) {
133 int mkdir_errno = errno;
148 db_dir +
"': a database already exists and I was told "
149 "not to overwrite it");
167 postlist_table(fd, version_file.get_offset(), readonly),
168 position_table(fd, version_file.get_offset(), readonly),
169 termlist_table(fd, version_file.get_offset(), readonly,
true),
170 value_manager(&postlist_table, &termlist_table),
171 synonym_table(fd, version_file.get_offset(), readonly),
172 spelling_table(fd, version_file.get_offset(), readonly),
173 docdata_table(fd, version_file.get_offset(), readonly),
188 LOGCALL(DB,
bool,
"GlassDatabase::database_exists", NO_ARGS);
196 LOGCALL_VOID(DB,
"GlassDatabase::create_and_open_tables", flags|block_size);
204 const string& tmpfile = v.
write(
rev, flags);
213 if (!v.
sync(tmpfile,
rev, flags)) {
223 LOGCALL(DB,
bool,
"GlassDatabase::open_tables", flags);
239 if (cur_rev && cur_rev ==
rev) {
296 string message = string(
"Couldn't open changeset ") +
302 const char *start = buf;
308 string message = string(
"Changeset at ") +
309 path +
" does not contain valid magic string";
314 unsigned int changes_version;
317 "changeset at " + path);
324 "changeset at " + path);
328 "changeset at " + path);
334 LOGCALL_VOID(DB,
"GlassDatabase::set_revision_number", flags|new_revision);
337 if (new_revision <=
rev &&
rev != 0) {
338 string m =
"New revision ";
339 m +=
str(new_revision);
340 m +=
" <= old revision ";
369 int saved_errno = errno;
370 (void)unlink(tmpfile.c_str());
388 const string & term = *t;
397 LOGCALL(DB,
bool,
"GlassDatabase::reopen", NO_ARGS);
418 LOGCALL_VOID(DB,
"GlassDatabase::get_database_write_lock", flags|creating);
427 string msg(
"No glass database found at path '");
440 #ifdef XAPIAN_HAS_REMOTE_BACKEND
451 static const char filenames[] =
461 const char * p = filenames;
463 size_t len = strlen(p);
464 filepath.replace(
db_dir.size() + 1, string::npos, p, len);
484 LOGCALL_VOID(DB,
"GlassDatabase::write_changesets_to_fd", fd |
revision | need_whole_db | info);
485 #ifdef XAPIAN_HAS_REMOTE_BACKEND
492 const char * rev_ptr =
revision.data();
493 const char * rev_end = rev_ptr +
revision.size();
494 if (!
unpack_uint(&rev_ptr, rev_end, &start_rev_num)) {
495 need_whole_db =
true;
511 if (whole_db_copies_left == 0) {
513 "Database changing too fast",
517 whole_db_copies_left--;
527 need_whole_db =
false;
539 if (info != NULL && start_rev_num == needed_rev_num)
553 need_whole_db =
true;
560 need_whole_db =
true;
569 string changes_name =
db_dir +
"/changes" +
str(start_rev_num);
571 if (fd_changes >= 0) {
577 &changeset_start_rev_num,
578 &changeset_end_rev_num);
579 if (changeset_start_rev_num != start_rev_num) {
582 if (changeset_start_rev_num >= changeset_end_rev_num) {
587 start_rev_num = changeset_end_rev_num;
590 if (start_rev_num >= needed_rev_num)
596 need_whole_db =
true;
611 const std::string & msg)
641 "and couldn't open at the old revision: " +
684 p =
changes.
start(new_revision, new_revision + 1, flags);
756 LOGCALL_VOID(DB,
"GlassDatabase::get_freqs", term | termfreq_ptr | collfreq_ptr);
771 LOGCALL(DB, std::string,
"GlassDatabase::get_value_lower_bound", slot);
778 LOGCALL(DB, std::string,
"GlassDatabase::get_value_upper_bound", slot);
806 LOGCALL(DB,
bool,
"GlassDatabase::term_exists", term);
870 const string& term)
const
894 return poslist.release();
915 if (!cursor)
return NULL;
936 if (!cursor)
return NULL;
944 LOGCALL(DB,
string,
"GlassDatabase::get_metadata", key);
945 string btree_key(
"\x00\xc0", 2);
955 LOGCALL(DB,
TermList*,
"GlassDatabase::open_metadata_keylist", prefix);
957 if (!cursor)
RETURN(NULL);
965 LOGCALL(DB,
string,
"GlassDatabase::get_revision_info", NO_ARGS);
974 LOGCALL(DB,
string,
"GlassDatabase::get_uuid", NO_ARGS);
1020 modify_shortcut_document(NULL),
1021 modify_shortcut_docid(0)
1023 LOGCALL_CTOR(DB,
"GlassWritableDatabase", dir | flags | block_size);
1025 const char *p = getenv(
"XAPIAN_FLUSH_THRESHOLD");
1080 LOGCALL_VOID(DB,
"GlassWritableDatabase::close", NO_ARGS);
1101 throw Xapian::DatabaseError(
"Run out of docids - you'll have to use copydatabase to eliminate any gaps before you can add more documents");
1128 string tname = *term;
1136 LOGLINE(DB,
"Calculated doclen for new document " << did <<
" as " << new_doclen);
1162 LOGCALL_VOID(DB,
"GlassWritableDatabase::delete_document", did);
1177 doc_really_existed =
true;
1180 if (!doc_really_existed) {
1196 while (!termlist.
at_end()) {
1227 LOGCALL_VOID(DB,
"GlassWritableDatabase::replace_document", did | document);
1251 bool modifying =
false;
1258 if (!document.
internal->modified()) {
1263 LOGLINE(DB,
"Detected potential document modification shortcut.");
1273 if (!modifying || document.
internal->terms_modified()) {
1274 bool pos_modified = !modifying ||
1275 document.
internal->term_positions_modified();
1289 string old_tname, new_tname;
1301 cmp = old_tname.compare(new_tname);
1310 new_doclen -= old_wdf;
1315 }
else if (cmp > 0) {
1318 new_doclen += new_wdf;
1327 }
else if (cmp == 0) {
1337 if (old_wdf != new_wdf) {
1338 new_doclen += new_wdf - old_wdf;
1350 LOGLINE(DB,
"Calculated doclen for replacement document " << did <<
" as " << new_doclen);
1357 if (new_doclen != old_doclen)
1362 if (!modifying || document.
internal->data_modified()) {
1367 if (!modifying || document.
internal->values_modified()) {
1428 LOGCALL_VOID(DB,
"GlassWritableDatabase::get_freqs", term | termfreq_ptr | collfreq_ptr);
1434 *termfreq_ptr += tf_delta;
1436 *collfreq_ptr += cf_delta;
1444 map<Xapian::valueno, ValueStats>::const_iterator i;
1453 LOGCALL(DB, std::string,
"GlassWritableDatabase::get_value_lower_bound", slot);
1454 map<Xapian::valueno, ValueStats>::const_iterator i;
1463 LOGCALL(DB, std::string,
"GlassWritableDatabase::get_value_upper_bound", slot);
1464 map<Xapian::valueno, ValueStats>::const_iterator i;
1473 LOGCALL(DB,
bool,
"GlassWritableDatabase::term_exists", tname);
1491 if (tname.empty()) {
1520 const string& term)
const
1533 const string& term)
const
1554 poslist->read_data(data);
1561 return poslist.release();
1567 LOGCALL(DB,
TermList*,
"GlassWritableDatabase::open_allterms", prefix);
1573 if (prefix.empty()) {
1623 const string & synonym)
const
1630 const string & synonym)
const
1644 LOGCALL_VOID(DB,
"GlassWritableDatabase::set_metadata", key | value);
1645 string btree_key(
"\x00\xc0", 2);
1647 if (value.empty()) {
static Xapian::Query query(Xapian::Query::op op, const string &t1=string(), const string &t2=string(), const string &t3=string(), const string &t4=string(), const string &t5=string(), const string &t6=string(), const string &t7=string(), const string &t8=string(), const string &t9=string(), const string &t10=string())
Wrapper around standard unique_ptr template.
#define CHANGES_MAGIC_STRING
#define REASONABLE_CHANGESET_SIZE
A PostList iterating all docids when they form a contiguous range.
void release()
Release the lock.
reason lock(bool exclusive, bool wait, std::string &explanation)
Attempt to obtain the lock.
bool test() const
Test if the lock is held.
void throw_databaselockerror(FlintLock::reason why, const std::string &db_dir, const std::string &explanation) const
Throw Xapian::DatabaseLockError.
GlassChanges * start(glass_revision_number_t old_rev, glass_revision_number_t rev, int flags)
glass_revision_number_t get_oldest_changeset() const
void set_oldest_changeset(glass_revision_number_t rev)
void commit(glass_revision_number_t new_rev, int flags)
A cursor pointing to a position in a Btree table, for reading several entries in order,...
A backend designed for efficient indexing and retrieval, using compressed posting lists and a btree s...
TermList * open_metadata_keylist(const std::string &prefix) const
Open a termlist returning each metadata key.
void get_used_docid_range(Xapian::docid &first, Xapian::docid &last) const
Find lowest and highest docids actually in use.
TermList * open_term_list(Xapian::docid did) const
Open a term list.
virtual void read_position_list(GlassPositionList *pos_list, Xapian::docid did, const string &term) const
friend class GlassPostList
TermList * open_allterms(const string &prefix) const
Open an allterms list.
Xapian::totallength get_total_length() const
Return the total length of all documents in this database.
bool locked() const
Return true if the database is open for writing.
void get_database_write_lock(int flags, bool creating)
Get a write lock on the database, or throw an Xapian::DatabaseLockError if failure.
std::string get_value_lower_bound(Xapian::valueno slot) const
Get a lower bound on the values stored in the given value slot.
std::string get_value_upper_bound(Xapian::valueno slot) const
Get an upper bound on the values stored in the given value slot.
glass_revision_number_t get_revision_number() const
Get an object holding the revision number which the tables are opened at.
string get_metadata(const string &key) const
Get the metadata associated with a given key.
void apply()
Apply any outstanding changes to the tables.
void readahead_for_query(const Xapian::Query &query)
void set_revision_number(int flags, glass_revision_number_t new_revision)
Set the revision number in the tables.
ValueList * open_value_list(Xapian::valueno slot) const
Open a value stream.
Xapian::termcount get_doclength_upper_bound() const
Get an upper bound on the length of a document in this DB.
GlassSpellingTable spelling_table
Table storing spelling correction data.
std::string db_dir
Directory to store databases in.
void cancel()
Cancel any outstanding changes to the tables.
void get_changeset_revisions(const string &path, glass_revision_number_t *startrev, glass_revision_number_t *endrev) const
Get the revision stored in a changeset.
PositionList * open_position_list(Xapian::docid did, const string &term) const
Open a position list for the given term in the given document.
GlassTermListTable termlist_table
Table storing term lists.
Xapian::termcount get_doclength(Xapian::docid did) const
Get the length of a given document.
GlassValueManager value_manager
Value manager.
string get_revision_info() const
Get a string describing the current revision of the database.
Xapian::docid get_lastdocid() const
Return the last used document id of this (sub) database.
void write_changesets_to_fd(int fd, const string &start_revision, bool need_whole_db, Xapian::ReplicationInfo *info)
Write a set of changesets to a file descriptor.
Xapian::Document::Internal * open_document(Xapian::docid did, bool lazy) const
Open a document.
void close()
Close all the tables permanently.
Xapian::doccount get_doccount() const
Virtual methods of Database::Internal.
string get_uuid() const
Get a UUID for the database.
void send_whole_database(RemoteConnection &conn, double end_time)
Send a set of messages which transfer the whole database.
friend class GlassAllTermsList
GlassChanges changes
Replication changesets.
FlintLock lock
Lock object.
TermList * open_synonym_termlist(const string &term) const
Open a termlist returning synonyms for a term.
Xapian::termcount get_wdf_upper_bound(const string &term) const
Get an upper bound on the wdf of term term.
GlassVersion version_file
The file describing the Glass database.
void create_and_open_tables(int flags, unsigned int blocksize)
Create new tables, and open them.
void get_freqs(const string &term, Xapian::doccount *termfreq_ptr, Xapian::termcount *collfreq_ptr) const
Returns frequencies for a term.
glass_revision_number_t get_next_revision_number() const
Get an object holding the next revision number which should be used in the tables.
bool readonly
Whether the database is readonly.
void request_document(Xapian::docid) const
Request and later collect a document from the database.
TermList * open_spelling_wordlist() const
Return a termlist which returns the words which are spelling correction targets.
virtual Xapian::termcount positionlist_count(Xapian::docid did, const string &term) const
void modifications_failed(glass_revision_number_t new_revision, const std::string &msg)
Called if a modifications fail.
GlassDatabase(const string &db_dir_, int flags=Xapian::DB_READONLY_, unsigned int block_size=0u)
Create and open a glass database.
bool term_exists(const string &tname) const
Check whether a given term is in the database.
friend class GlassAllDocsPostList
Xapian::termcount get_unique_terms(Xapian::docid did) const
Get the number of unique term in document.
virtual bool has_uncommitted_changes() const
Return true if there are uncommitted changes.
Xapian::doccount get_spelling_frequency(const string &word) const
Return the number of times word was added as a spelling.
TermList * open_synonym_keylist(const string &prefix) const
Open a termlist returning each term which has synonyms.
GlassPositionListTable position_table
Table storing position lists.
bool reopen()
Re-open tables to recover from an overwritten condition, or just get most up-to-date version.
TermList * open_spelling_termlist(const string &word) const
Create a termlist tree from trigrams of word.
GlassDocDataTable docdata_table
Table storing document data.
bool database_exists()
Return true if a database exists at the path specified for this database.
Xapian::termcount get_doclength_lower_bound() const
Get a lower bound on the length of a document in this DB.
LeafPostList * open_post_list(const string &tname) const
Open a posting list.
GlassPostListTable postlist_table
Table storing posting lists.
friend class GlassWritableDatabase
GlassSynonymTable synonym_table
Table storing synonym data.
bool open_tables(int flags)
Open all tables at most recent revision.
void throw_termlist_table_close_exception() const
friend class GlassTermList
Xapian::doccount get_value_freq(Xapian::valueno slot) const
Return the frequency of a given value slot.
bool has_positions() const
Check whether this database contains any positional information.
void replace_document_data(Xapian::docid did, const std::string &data)
Replace the document data for document did.
bool delete_document_data(Xapian::docid did)
Delete the document data for document did.
void readahead_for_document(Xapian::docid did) const
A document read from a GlassDatabase.
Xapian::termcount positionlist_count(const string &data) const
Return the number of entries in specified position list data.
A position list in a glass database.
bool read_data(const string &data)
Fill list with data, and move the position to the start.
void open(int flags_, const RootInfo &root_info, glass_revision_number_t rev)
bool document_exists(Xapian::docid did, Xapian::Internal::intrusive_ptr< const GlassDatabase > db) const
Check if document did exists.
static string make_key(const string &term, Xapian::docid did)
Compose a key from a termname and docid.
void get_used_docid_range(Xapian::docid &first, Xapian::docid &last) const
Xapian::termcount get_doclength(Xapian::docid did, Xapian::Internal::intrusive_ptr< const GlassDatabase > db) const
Returns the length of document did.
void get_freqs(const std::string &term, Xapian::doccount *termfreq_ptr, Xapian::termcount *collfreq_ptr, Xapian::termcount *wdfub_ptr=NULL) const
Returns frequencies for a term.
bool term_exists(const string &term) const
TermList * open_termlist(const std::string &word)
void cancel(const RootInfo &root_info, glass_revision_number_t rev)
Override methods of GlassTable.
bool is_modified() const
Override methods of GlassTable.
void merge_changes()
Merge in batched-up changes.
Xapian::termcount flush_db()
Returns updated wordfreq upper bound.
void remove_word(const std::string &word, Xapian::termcount freqdec)
void add_word(const std::string &word, Xapian::termcount freqinc)
Xapian::doccount get_word_frequency(const std::string &word) const
void set_wordfreq_upper_bound(Xapian::termcount ub)
void flush_db()
Override methods of GlassTable.
void clear_synonyms(const std::string &term)
Remove all synonyms for term.
void add_synonym(const std::string &term, const std::string &synonym)
Add a synonym for term.
void remove_synonym(const std::string &term, const std::string &synonym)
Remove a synonym for term.
bool is_modified() const
Override methods of GlassTable.
void cancel(const RootInfo &root_info, glass_revision_number_t rev)
Override methods of GlassTable.
TermList * open_termlist(const std::string &term)
Open synonym termlist for a term.
bool readahead_key(const string &key) const
void add(const std::string &key, const std::string &tag, bool already_compressed=false)
Add a key/tag pair to the table, replacing any existing pair with the same key.
void create_and_open(int flags_, const RootInfo &root_info)
Create a new empty btree structure on disk and open it at the initial revision.
void commit(glass_revision_number_t revision, RootInfo *root_info)
Commit any outstanding changes to the table.
bool del(const std::string &key)
Delete an entry from the table.
bool exists() const
Determine whether the btree exists on disk.
bool is_open() const
Return true if this table is open.
void flush_db()
Flush any outstanding changes to the DB file of the table.
bool empty() const
Return true if there are no entries in the table.
void open(int flags_, const RootInfo &root_info, glass_revision_number_t rev)
Open the btree.
bool is_modified() const
Determine whether the object contains uncommitted modifications.
void set_changes(GlassChanges *changes)
Set the GlassChanges object to write changed blocks to.
GlassCursor * cursor_get() const
Get a cursor for reading from the table.
void close(bool permanent=false)
Close the Btree.
void cancel(const RootInfo &root_info, glass_revision_number_t rev)
Cancel any outstanding changes.
static void throw_database_closed()
Throw an exception indicating that the database is closed.
bool get_exact_entry(const std::string &key, std::string &tag) const
Read an entry from the table, if and only if it is exactly that being asked for.
void set_termlist(Xapian::docid did, const Xapian::Document &doc, Xapian::termcount doclen)
Set the termlist data for document did.
void delete_termlist(Xapian::docid did)
Delete the termlist data for document did.
A TermList in a glass database.
Xapian::termcount get_doclength() const
Return the length of this document.
TermList * next()
Advance the current position to the next term in the termlist.
Xapian::termcount get_approx_size() const
Return approximate size of this termlist.
Xapian::termcount get_wdf() const
Return the wdf for the term at the current position.
bool at_end() const
Return true if the current position is past the last term in this list.
std::string get_termname() const
Return the termname at the current position.
Glass class for value streams.
void add_document(Xapian::docid did, const Xapian::Document &doc, std::map< Xapian::valueno, ValueStats > &value_stats)
void set_value_stats(std::map< Xapian::valueno, ValueStats > &value_stats)
Write the updated statistics to the table.
Xapian::doccount get_value_freq(Xapian::valueno slot) const
void replace_document(Xapian::docid did, const Xapian::Document &doc, std::map< Xapian::valueno, ValueStats > &value_stats)
std::string get_value_upper_bound(Xapian::valueno slot) const
std::string get_value_lower_bound(Xapian::valueno slot) const
void delete_document(Xapian::docid did, std::map< Xapian::valueno, ValueStats > &value_stats)
The GlassVersion class manages the revision files.
RootInfo * root_to_set(Glass::table_type tbl)
void set_oldest_changeset(glass_revision_number_t changeset) const
const RootInfo & get_root(Glass::table_type tbl) const
void check_wdf(Xapian::termcount wdf)
void add_document(Xapian::termcount doclen)
const std::string write(glass_revision_number_t new_rev, int flags)
Xapian::docid get_last_docid() const
glass_revision_number_t get_revision() const
void delete_document(Xapian::termcount doclen)
Xapian::termcount get_doclength_lower_bound() const
std::string get_uuid_string() const
Return UUID in the standard 36 character string format.
void set_spelling_wordfreq_upper_bound(Xapian::termcount ub)
void set_last_docid(Xapian::docid did)
glass_revision_number_t get_oldest_changeset() const
Xapian::termcount get_spelling_wordfreq_upper_bound() const
bool sync(const std::string &tmpfile, glass_revision_number_t new_rev, int flags)
Xapian::doccount get_doccount() const
void set_changes(GlassChanges *changes_)
Xapian::termcount get_wdf_upper_bound() const
Xapian::docid get_next_docid()
void create(unsigned blocksize)
Create the version file.
void read()
Read the version file and check it's a version we understand.
Xapian::totallength get_total_doclen() const
Xapian::termcount get_doclength_upper_bound() const
void flush_postlist_changes()
Flush any unflushed postlist changes, but don't commit them.
Xapian::docid add_document_(Xapian::docid did, const Xapian::Document &document)
void remove_synonym(const string &word, const string &synonym) const
Remove a synonym for a term.
void clear_synonyms(const string &word) const
Clear all synonyms for a term.
Xapian::termcount get_unique_terms(Xapian::docid did) const
Get the number of unique term in document.
LeafPostList * open_post_list(const string &tname) const
Open a posting list.
std::string get_value_upper_bound(Xapian::valueno slot) const
Get an upper bound on the values stored in the given value slot.
TermList * open_spelling_wordlist() const
Return a termlist which returns the words which are spelling correction targets.
TermList * open_allterms(const string &prefix) const
Open an allterms list.
void close()
Close all the tables permanently.
bool has_uncommitted_changes() const
Return true if there are uncommitted changes.
ValueList * open_value_list(Xapian::valueno slot) const
Open a value stream.
void set_metadata(const string &key, const string &value)
Set the metadata associated with a given key.
void commit()
Implementation of virtual methods: see Database::Internal for details.
bool term_exists(const string &tname) const
Check whether a given term is in the database.
void add_synonym(const string &word, const string &synonym) const
Add a synonym for a term.
void replace_document(Xapian::docid did, const Xapian::Document &document)
Replace a given document in the database.
void delete_document(Xapian::docid did)
Delete a document in the database.
void invalidate_doc_object(Xapian::Document::Internal *obj) const
Notify the database that document is no longer valid.
map< Xapian::valueno, ValueStats > value_stats
void apply()
Apply changes.
void cancel()
Cancel pending modifications to the database.
void add_spelling(const string &word, Xapian::termcount freqinc) const
Add a word to the spelling dictionary.
void get_freqs(const string &term, Xapian::doccount *termfreq_ptr, Xapian::termcount *collfreq_ptr) const
Returns frequencies for a term.
std::string get_value_lower_bound(Xapian::valueno slot) const
Get a lower bound on the values stored in the given value slot.
Xapian::Document::Internal * modify_shortcut_document
A pointer to the last document which was returned by open_document(), or NULL if there is no such val...
Xapian::termcount get_doclength(Xapian::docid did) const
Virtual methods of Database::Internal.
void check_flush_threshold()
Check if we should autoflush.
PositionList * open_position_list(Xapian::docid did, const string &term) const
Open a position list for the given term in the given document.
Xapian::doccount flush_threshold
If change_count reaches this threshold we automatically flush.
Xapian::docid add_document(const Xapian::Document &document)
Add a new document to the database.
Xapian::termcount positionlist_count(Xapian::docid did, const string &term) const
TermList * open_synonym_keylist(const string &prefix) const
Open a termlist returning each term which has synonyms.
Xapian::docid modify_shortcut_docid
The document ID for the last document returned by open_document().
Xapian::Document::Internal * open_document(Xapian::docid did, bool lazy) const
Open a document.
bool has_positions() const
Check whether this database contains any positional information.
Xapian::doccount get_value_freq(Xapian::valueno slot) const
Return the frequency of a given value slot.
void read_position_list(GlassPositionList *pos_list, Xapian::docid did, const string &term) const
void remove_spelling(const string &word, Xapian::termcount freqdec) const
Remove a word from the spelling dictionary.
Xapian::doccount change_count
The number of documents added, deleted, or replaced since the last flush.
bool get_positionlist(Xapian::docid did, const std::string &term, std::string &s) const
bool get_deltas(const std::string &term, Xapian::termcount_diff &tf_delta, Xapian::termcount_diff &cf_delta) const
void delete_doclength(Xapian::docid did)
void remove_posting(Xapian::docid did, const std::string &term, Xapian::doccount wdf)
void update_posting(Xapian::docid did, const std::string &term, Xapian::termcount old_wdf, Xapian::termcount new_wdf)
void set_positionlist(Xapian::docid did, const std::string &term, const std::string &s)
void delete_positionlist(Xapian::docid did, const std::string &term)
bool has_positions(const GlassPositionListTable &position_table) const
void flush_post_lists(GlassPostListTable &table, const std::string &pfx)
Flush postlist changes for all terms which start with pfx.
void flush_post_list(GlassPostListTable &table, const std::string &term)
Flush postlist changes for term.
bool get_doclength(Xapian::docid did, Xapian::termcount &doclen) const
void set_doclength(Xapian::docid did, Xapian::termcount doclen, bool add)
void flush_doclengths(GlassPostListTable &table)
Flush document length changes.
void add_posting(Xapian::docid did, const std::string &term, Xapian::doccount wdf)
void flush_pos_lists(GlassPositionListTable &table)
Flush position changes.
void flush(GlassPostListTable &table)
Flush all postlist table changes.
Abstract base class for leaf postlists.
A RemoteConnection object provides a bidirectional connection to another RemoteConnection object on a...
void send_message(char type, const std::string &s, double end_time)
Send a message.
void send_file(char type, int fd, double end_time)
Send the contents of a file as a message.
DatabaseCreateError indicates a failure to create a database.
DatabaseError indicates some sort of database related error.
Indicates an attempt to access a database not present.
void dtor_called()
Internal method to perform cleanup when a writable database is destroyed with uncommitted changes.
bool transaction_active() const
A document in the database, possibly plus modifications.
A handle representing a document in a Xapian database.
std::string get_data() const
Get data stored in the document.
TermIterator termlist_end() const
Equivalent end iterator for termlist_begin().
TermIterator termlist_begin() const
Start iterating the terms in this document.
Xapian::Internal::intrusive_ptr< Internal > internal
All exceptions thrown by Xapian are subclasses of Xapian::Error.
const std::string & get_msg() const
Message giving details of the error, intended for human consumption.
std::string get_description() const
Return a string describing this object.
Indicates an attempt to use a feature which is unavailable.
A smart pointer that uses intrusive reference counting.
InvalidArgumentError indicates an invalid parameter value was passed to the API.
InvalidOperationError indicates the API was used in an invalid way.
Abstract base class for iterating term positions in a document.
Class representing a query.
const TermIterator get_unique_terms_begin() const
Begin iterator for unique terms in the query object.
Abstract base class for termlists.
Class for iterating over a list of terms.
Xapian::termcount get_wdf() const
Return the wdf for the term at the current position.
Abstract base class for value streams.
Constants in the Xapian namespace.
Iterate all document ids when they form a contiguous range.
#define LOGCALL(CATEGORY, TYPE, FUNC, PARAMS)
#define LOGCALL_CTOR(CATEGORY, CLASS, PARAMS)
#define LOGCALL_VOID(CATEGORY, FUNC, PARAMS)
#define LOGCALL_DTOR(CATEGORY, CLASS)
Hierarchy of classes which Xapian can throw as exceptions.
Wrapper class around a file descriptor to avoid leaks.
Utility functions for testing files.
bool dir_exists(const char *path)
Test if a directory exists.
A PostList which iterates over all documents in a GlassDatabase.
A termlist containing all terms in a glass database.
#define MAX_SAFE_TERM_LENGTH
C++ class definition for glass database.
Definitions, types, etc for use inside glass.
#define GLASS_MAX_DOCID
The largest docid value supported by glass.
#define GLASS_DEFAULT_BLOCKSIZE
Default B-tree block size.
uint4 glass_revision_number_t
The revision number of a glass database.
#define GLASS_TABLE_EXTENSION
Glass table extension.
Subclass of GlassTable which holds document data.
A document read from a GlassDatabase.
A position list in a glass database.
Postlists in glass databases.
Internal definitions for glass database replication.
A termlist containing all words which are spelling targets.
A TermList in a glass database.
Glass class for value streams.
size_t io_read(int fd, char *p, size_t n, size_t min)
Read n bytes (or until EOF) into block pointed to by p from file descriptor fd.
Wrappers for low-level POSIX I/O routines.
length encoded as a string
std::string encode_length(T len)
Encode a length as a variable-length string.
double end_time(double timeout)
Return the end time for a timeout in timeout seconds.
string str(int value)
Convert int to std::string.
The Xapian namespace contains public interfaces for the Xapian library.
const int DB_CREATE
Create a new database.
int revision()
Report the revision of the library which the program is linked with.
const int DB_RETRY_LOCK
If the database is already locked, retry the lock.
XAPIAN_TERMCOUNT_BASE_TYPE termcount_diff
A signed difference between two counts of terms.
unsigned XAPIAN_TERMCOUNT_BASE_TYPE termcount
A counts of terms.
const int DB_OPEN
Open an existing database.
XAPIAN_REVISION_TYPE rev
Revision number of a database.
unsigned valueno
The number for a value slot in a document.
unsigned XAPIAN_DOCID_BASE_TYPE doccount
A count of documents.
const int DB_NO_TERMLIST
When creating a database, don't create a termlist table.
unsigned XAPIAN_DOCID_BASE_TYPE docid
A unique identifier for a document.
XAPIAN_TOTALLENGTH_TYPE totallength
The total length of all documents in a database.
const int DB_CREATE_OR_OVERWRITE
Create database if it doesn't already exist, or overwrite if it does.
Pack types into strings and unpack them again.
bool unpack_uint(const char **p, const char *end, U *result)
Decode an unsigned integer from a string.
void pack_uint(std::string &s, U value)
Append an encoded unsigned integer to a string.
Provides wrappers with POSIXy semantics.
RemoteConnection class used by the remote backend.
Replication support for Xapian databases.
Replication protocol version and message numbers.
#define MAX_DB_COPIES_PER_CONVERSATION
@ REPL_REPLY_END_OF_CHANGES
include <sys/stat.h> with portability enhancements
Convert types to std::string.
Various handy helpers which std::string really should provide.
#define CONST_STRLEN(S)
Returns the length of a string constant.
#define STRINGIZE(X)
The STRINGIZE macro converts its parameter into a string constant.
Information about the steps involved in performing a replication.
bool changed
True if and only if the replication corresponds to a change in the live version of the database.
int fullcopy_count
Number of times a full database copy was performed.
int changeset_count
Number of changesets applied.
Class for iterating over document values.