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");
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 '");
439 LOGCALL_VOID(DB,
"GlassDatabase::send_whole_database", conn | end_time);
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()) {
GlassVersion version_file
The file describing the Glass database.
bool reopen()
Re-open tables to recover from an overwritten condition, or just get most up-to-date version...
const RootInfo & get_root(Glass::table_type tbl) const
The Xapian namespace contains public interfaces for the Xapian library.
void delete_termlist(Xapian::docid did)
Delete the termlist data for document did.
void throw_databaselockerror(FlintLock::reason why, const std::string &db_dir, const std::string &explanation) const
Throw Xapian::DatabaseLockError.
void cancel()
Cancel pending modifications to the database.
void release()
Release the lock.
void commit()
Implementation of virtual methods: see Database::Internal for details.
Xapian::termcount get_doclength_upper_bound() const
A PostList which iterates over all documents in a GlassDatabase.
std::string get_termname() const
Return the termname at the current position.
Xapian::docid get_next_docid()
FlintLock lock
Lock object.
void set_value_stats(std::map< Xapian::valueno, ValueStats > &value_stats)
Write the updated statistics to the table.
void create(unsigned blocksize)
Create the version file.
void invalidate_doc_object(Xapian::Document::Internal *obj) const
Virtual methods of Database::Internal.
Xapian::termcount get_unique_terms(Xapian::docid did) const
Virtual methods of Database::Internal.
bool sync(const std::string &tmpfile, glass_revision_number_t new_rev, int flags)
A RemoteConnection object provides a bidirectional connection to another RemoteConnection object on a...
RemoteConnection class used by the remote backend.
Xapian::termcount positionlist_count(const string &data) const
Return the number of entries in specified position list data.
Xapian::termcount get_doclength() const
Return the length of this document.
void add_synonym(const std::string &term, const std::string &synonym)
Add a synonym for term.
GlassPositionListTable position_table
Table storing position lists.
length encoded as a string
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 throw_termlist_table_close_exception() const
XAPIAN_REVISION_TYPE rev
Revision number of a database.
bool delete_document_data(Xapian::docid did)
Delete the document data for document did.
A position list in a glass database.
void close()
Close all the tables permanently.
TermList * open_synonym_keylist(const string &prefix) const
Virtual methods of Database::Internal.
string get_uuid() const
Virtual methods of Database::Internal.
Xapian::docid get_lastdocid() const
Virtual methods of Database::Internal.
A PostList iterating all docids when they form a contiguous range.
friend class GlassAllTermsList
std::string db_dir
Directory to store databases in.
int fullcopy_count
Number of times a full database copy was performed.
bool get_positionlist(Xapian::docid did, const std::string &term, std::string &s) const
#define GLASS_MAX_DOCID
The largest docid value supported by glass.
bool has_positions(const GlassPositionListTable &position_table) const
TermList * open_metadata_keylist(const std::string &prefix) const
Virtual methods of Database::Internal.
const int DB_CREATE
Create a new database.
void flush_postlist_changes()
Flush any unflushed postlist changes, but don't commit them.
InvalidOperationError indicates the API was used in an invalid way.
void create_and_open_tables(int flags, unsigned int blocksize)
Create new tables, and open them.
bool transaction_active() const
std::string get_value_lower_bound(Xapian::valueno slot) const
Virtual methods of Database::Internal.
Xapian::docid add_document_(Xapian::docid did, const Xapian::Document &document)
Implementation of virtual methods: see Database::Internal for details.
void apply()
Apply any outstanding changes to the tables.
bool empty() const
Return true if there are no entries in the table.
GlassChanges changes
Replication changesets.
bool readahead_key(const string &key) const
void send_whole_database(RemoteConnection &conn, double end_time)
Send a set of messages which transfer the whole database.
Xapian::doccount get_doccount() const
Virtual methods of Database::Internal.
TermList * open_spelling_wordlist() const
Virtual methods of Database::Internal.
void merge_changes()
Merge in batched-up changes.
Internal definitions for glass database replication.
void delete_document(Xapian::docid did)
Implementation of virtual methods: see Database::Internal for details.
uint4 glass_revision_number_t
The revision number of a glass database.
Iterate all document ids when they form a contiguous range.
GlassSynonymTable synonym_table
Table storing synonym data.
std::string get_value_lower_bound(Xapian::valueno slot) const
Virtual methods of Database::Internal.
Glass class for value streams.
void set_metadata(const string &key, const string &value)
Virtual methods of Database::Internal.
XAPIAN_TOTALLENGTH_TYPE totallength
The total length of all documents in a database.
void write_changesets_to_fd(int fd, const string &start_revision, bool need_whole_db, Xapian::ReplicationInfo *info)
Virtual methods of Database::Internal.
Provides wrappers with POSIXy semantics.
LeafPostList * open_post_list(const string &tname) const
Virtual methods of Database::Internal.
void modifications_failed(glass_revision_number_t new_revision, const std::string &msg)
Called if a modifications fail.
friend class GlassPostList
Constants in the Xapian namespace.
The GlassVersion class manages the revision files.
Subclass of GlassTable which holds document data.
void send_file(char type, int fd, double end_time)
Send the contents of a file as a message.
const std::string & get_msg() const
Message giving details of the error, intended for human consumption.
#define LOGCALL_DTOR(CATEGORY, CLASS)
double end_time(double timeout)
Return the end time for a timeout in timeout seconds.
A termlist containing all terms in a glass database.
void delete_doclength(Xapian::docid did)
Xapian::Document::Internal * open_document(Xapian::docid did, bool lazy) const
Implementation of virtual methods: see Database::Internal for details.
A document in the database, possibly plus modifications.
#define STRINGIZE(X)
The STRINGIZE macro converts its parameter into a string constant.
#define LOGCALL_VOID(CATEGORY, FUNC, PARAMS)
Abstract base class for termlists.
Postlists in glass databases.
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...
Definitions, types, etc for use inside glass.
GlassWritableDatabase(const string &dir, int flags, int block_size)
Create and open a writable glass database.
Convert types to std::string.
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.
TermList * open_termlist(const std::string &term)
Open synonym termlist for a term.
Xapian::doccount change_count
The number of documents added, deleted, or replaced since the last flush.
int revision()
Report the revision of the library which the program is linked with.
glass_revision_number_t get_oldest_changeset() const
Abstract base class for leaf postlists.
Utility functions for testing files.
glass_revision_number_t get_next_revision_number() const
Get an object holding the next revision number which should be used in the tables.
A position list in a glass database.
std::string encode_length(T len)
Encode a length as a variable-length string.
A document read from a GlassDatabase.
Xapian::termcount get_doclength(Xapian::docid did, Xapian::Internal::intrusive_ptr< const GlassDatabase > db) const
Returns the length of document did.
TermIterator termlist_end() const
Equivalent end iterator for termlist_begin().
void check_wdf(Xapian::termcount wdf)
void get_database_write_lock(int flags, bool creating)
Get a write lock on the database, or throw an Xapian::DatabaseLockError if failure.
GlassDocDataTable docdata_table
Table storing document data.
friend class GlassAllDocsPostList
bool read_data(const string &data)
Fill list with data, and move the position to the start.
bool test() const
Test if the lock is held.
void commit(glass_revision_number_t new_rev, int flags)
include <sys/stat.h> with portability enhancements
const TermIterator get_unique_terms_begin() const
Begin iterator for unique terms in the query object.
bool locked() const
Return true if the database is open for writing.
void close()
Close all the tables permanently.
#define GLASS_TABLE_EXTENSION
Glass table extension.
Xapian::docid get_last_docid() const
void delete_positionlist(Xapian::docid did, const std::string &term)
Xapian::termcount get_approx_size() const
Return approximate size of this termlist.
#define REASONABLE_CHANGESET_SIZE
void remove_spelling(const string &word, Xapian::termcount freqdec) const
Virtual methods of Database::Internal.
#define CHANGES_MAGIC_STRING
virtual void read_position_list(GlassPositionList *pos_list, Xapian::docid did, const string &term) const
Virtual methods of Database::Internal.
void replace_document_data(Xapian::docid did, const std::string &data)
Replace the document data for document did.
Hierarchy of classes which Xapian can throw as exceptions.
Class for iterating over a list of terms.
map< Xapian::valueno, ValueStats > value_stats
Glass class for value streams.
unsigned XAPIAN_TERMCOUNT_BASE_TYPE termcount
A counts of terms.
Xapian::termcount get_wdf_upper_bound() const
void get_freqs(const string &term, Xapian::doccount *termfreq_ptr, Xapian::termcount *collfreq_ptr) const
Virtual methods of Database::Internal.
Xapian::doccount get_spelling_frequency(const string &word) const
Virtual methods of Database::Internal.
void flush_db()
Flush any outstanding changes to the DB file of the table.
InvalidArgumentError indicates an invalid parameter value was passed to the API.
A TermList in a glass database.
bool document_exists(Xapian::docid did, Xapian::Internal::intrusive_ptr< const GlassDatabase > db) const
Check if document did exists.
RootInfo * root_to_set(Glass::table_type tbl)
void readahead_for_document(Xapian::docid did) const
A termlist containing all words which are spelling targets.
void add_synonym(const string &word, const string &synonym) const
Virtual methods of Database::Internal.
Xapian::docid add_document(const Xapian::Document &document)
Implementation of virtual methods: see Database::Internal for details.
void flush_post_list(GlassPostListTable &table, const std::string &term)
Flush postlist changes for term.
static string make_key(const string &term, Xapian::docid did)
Compose a key from a termname and docid.
string get_metadata(const string &key) const
Virtual methods of Database::Internal.
void add_word(const std::string &word, Xapian::termcount freqinc)
void remove_synonym(const string &word, const string &synonym) const
Virtual methods of Database::Internal.
const int DB_OPEN
Open an existing database.
void close(bool permanent=false)
Close the Btree.
GlassPostListTable postlist_table
Table storing posting lists.
void readahead_for_query(const Xapian::Query &query)
Virtual methods of Database::Internal.
TermList * open_synonym_termlist(const string &term) const
Virtual methods of Database::Internal.
Xapian::termcount get_doclength(Xapian::docid did) const
Virtual methods of Database::Internal.
void set_changes(GlassChanges *changes_)
Indicates an attempt to use a feature which is unavailable.
bool is_modified() const
Determine whether the object contains uncommitted modifications.
ValueList * open_value_list(Xapian::valueno slot) const
Virtual methods of Database::Internal.
DatabaseCreateError indicates a failure to create a database.
void get_used_docid_range(Xapian::docid &first, Xapian::docid &last) const
Find lowest and highest docids actually in use.
void commit(glass_revision_number_t revision, RootInfo *root_info)
Commit any outstanding changes to the table.
PositionList * open_position_list(Xapian::docid did, const string &term) const
Virtual methods of Database::Internal.
bool get_doclength(Xapian::docid did, Xapian::termcount &doclen) const
void add_posting(Xapian::docid did, const std::string &term, Xapian::doccount wdf)
void read_position_list(GlassPositionList *pos_list, Xapian::docid did, const string &term) const
Virtual methods of Database::Internal.
void get_used_docid_range(Xapian::docid &first, Xapian::docid &last) const
void flush(GlassPostListTable &table)
Flush all postlist table changes.
LeafPostList * open_post_list(const string &tname) const
Virtual methods of Database::Internal.
void add_document(Xapian::termcount doclen)
Xapian::termcount flush_db()
Returns updated wordfreq upper bound.
void set_oldest_changeset(glass_revision_number_t rev)
Xapian::termcount get_doclength_lower_bound() const
bool has_positions() const
Virtual methods of Database::Internal.
string str(int value)
Convert int to std::string.
GlassTermListTable termlist_table
Table storing term lists.
Wrapper class around a file descriptor to avoid leaks.
TermList * open_allterms(const string &prefix) const
Virtual methods of Database::Internal.
Information about the steps involved in performing a replication.
int changeset_count
Number of changesets applied.
#define GLASS_DEFAULT_BLOCKSIZE
Default B-tree block size.
C++ class definition for glass database.
ValueList * open_value_list(Xapian::valueno slot) const
Virtual methods of Database::Internal.
Class for iterating over document values.
Xapian::doccount flush_threshold
If change_count reaches this threshold we automatically flush.
#define CONST_STRLEN(S)
Returns the length of a string constant.
void set_termlist(Xapian::docid did, const Xapian::Document &doc, Xapian::termcount doclen)
Set the termlist data for document did.
void set_positionlist(Xapian::docid did, const std::string &term, const std::string &s)
glass_revision_number_t get_revision_number() const
Get an object holding the revision number which the tables are opened at.
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.
bool open_tables(int flags)
Open all tables at most recent revision.
void set_wordfreq_upper_bound(Xapian::termcount ub)
GlassChanges * start(glass_revision_number_t old_rev, glass_revision_number_t rev, int flags)
void set_oldest_changeset(glass_revision_number_t changeset) const
static void throw_database_closed()
Throw an exception indicating that the database is closed.
void delete_document(Xapian::termcount doclen)
Indicates an attempt to access a database not present.
Xapian::termcount get_doclength_lower_bound() const
Virtual methods of Database::Internal.
bool at_end() const
Return true if the current position is past the last term in this list.
Xapian::termcount get_wdf() const
Return the wdf for the term at the current position.
TermList * open_termlist(const std::string &word)
void replace_document(Xapian::docid did, const Xapian::Document &document)
Implementation of virtual methods: see Database::Internal for details.
void set_spelling_wordfreq_upper_bound(Xapian::termcount ub)
Xapian::Internal::intrusive_ptr< Internal > internal
#define LOGCALL_CTOR(CATEGORY, CLASS, PARAMS)
void cancel()
Cancel any outstanding changes to the tables.
void read()
Read the version file and check it's a version we understand.
virtual bool has_uncommitted_changes() const
Return true if there are uncommitted changes.
void set_doclength(Xapian::docid did, Xapian::termcount doclen, bool add)
A backend designed for efficient indexing and retrieval, using compressed posting lists and a btree s...
bool is_open() const
Return true if this table is open.
bool dir_exists(const char *path)
Test if a directory exists.
bool changed
True if and only if the replication corresponds to a change in the live version of the database...
Xapian::docid modify_shortcut_docid
The document ID for the last document returned by open_document().
A cursor pointing to a position in a Btree table, for reading several entries in order, or finding approximate matches.
Xapian::termcount get_wdf() const
Return the wdf for the term at the current position.
void flush_pos_lists(GlassPositionListTable &table)
Flush position changes.
std::string get_description() const
Return a string describing this object.
void remove_word(const std::string &word, Xapian::termcount freqdec)
void get_freqs(const string &term, Xapian::doccount *termfreq_ptr, Xapian::termcount *collfreq_ptr) const
Virtual methods of Database::Internal.
void set_changes(GlassChanges *changes)
Set the GlassChanges object to write changed blocks to.
void open(int flags_, const RootInfo &root_info, glass_revision_number_t rev)
Open the btree.
bool has_positions() const
Virtual methods of Database::Internal.
bool is_modified() const
Override methods of GlassTable.
TermList * open_spelling_termlist(const string &word) const
Virtual methods of Database::Internal.
Abstract base class for value streams.
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())
Xapian::termcount get_wdf_upper_bound(const string &term) const
Virtual methods of Database::Internal.
void open(int flags_, const RootInfo &root_info, glass_revision_number_t rev)
void pack_uint(std::string &s, U value)
Append an encoded unsigned integer to a string.
friend class GlassTermList
TermList * open_spelling_wordlist() const
Virtual methods of Database::Internal.
bool term_exists(const string &tname) const
Virtual methods of Database::Internal.
XAPIAN_TERMCOUNT_BASE_TYPE termcount_diff
A signed difference between two counts of terms.
bool term_exists(const string &tname) const
Virtual methods of Database::Internal.
void request_document(Xapian::docid) const
Virtual methods of Database::Internal.
void set_revision_number(int flags, glass_revision_number_t new_revision)
Set the revision number in the tables.
void check_flush_threshold()
Check if we should autoflush.
Xapian::termcount positionlist_count(Xapian::docid did, const string &term) const
Virtual methods of Database::Internal.
void flush_db()
Override methods of GlassTable.
Replication protocol version and message numbers.
Xapian::doccount get_value_freq(Xapian::valueno slot) const
Virtual methods of Database::Internal.
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.
bool term_exists(const string &term) const
unsigned XAPIAN_DOCID_BASE_TYPE doccount
A count of documents.
std::string get_value_upper_bound(Xapian::valueno slot) const
Virtual methods of Database::Internal.
Xapian::doccount get_word_frequency(const std::string &word) const
void remove_synonym(const std::string &term, const std::string &synonym)
Remove a synonym for term.
glass_revision_number_t get_oldest_changeset() const
Replication support for Xapian databases.
Xapian::totallength get_total_doclen() const
void cancel(const RootInfo &root_info, glass_revision_number_t rev)
Override methods of GlassTable.
GlassDatabase(const string &db_dir_, int flags=Xapian::DB_READONLY_, unsigned int block_size=0u)
Create and open a glass database.
TermList * open_synonym_keylist(const string &prefix) const
Virtual methods of Database::Internal.
Xapian::termcount get_spelling_wordfreq_upper_bound() const
All exceptions thrown by Xapian are subclasses of Xapian::Error.
GlassCursor * cursor_get() const
Get a cursor for reading from the table.
void update_posting(Xapian::docid did, const std::string &term, Xapian::termcount old_wdf, Xapian::termcount new_wdf)
Pack types into strings and unpack them again.
unsigned valueno
The number for a value slot in a document.
void remove_posting(Xapian::docid did, const std::string &term, Xapian::doccount wdf)
Wrappers for low-level POSIX I/O routines.
Xapian::doccount get_value_freq(Xapian::valueno slot) const
Virtual methods of Database::Internal.
Various handy helpers which std::string really should provide.
bool unpack_uint(const char **p, const char *end, U *result)
Decode an unsigned integer from a string.
void dtor_called()
Internal method to perform cleanup when a writable database is destroyed with uncommitted changes...
PositionList * open_position_list(Xapian::docid did, const string &term) const
Virtual methods of Database::Internal.
#define MAX_DB_COPIES_PER_CONVERSATION
void add_spelling(const string &word, Xapian::termcount freqinc) const
Virtual methods of Database::Internal.
std::string get_value_upper_bound(Xapian::valueno slot) const
Virtual methods of Database::Internal.
const int DB_NO_TERMLIST
When creating a database, don't create a termlist table.
Xapian::termcount get_doclength(Xapian::docid did) const
Virtual methods of Database::Internal.
void send_message(char type, const std::string &s, double end_time)
Send a message.
bool database_exists()
Return true if a database exists at the path specified for this database.
void delete_document(Xapian::docid did, std::map< Xapian::valueno, ValueStats > &value_stats)
reason lock(bool exclusive, bool wait, std::string &explanation)
Attempt to obtain the lock.
Xapian::doccount get_value_freq(Xapian::valueno slot) const
TermList * next()
Advance the current position to the next term in the termlist.
const int DB_RETRY_LOCK
If the database is already locked, retry the lock.
void cancel(const RootInfo &root_info, glass_revision_number_t rev)
Cancel any outstanding changes.
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.
const int DB_CREATE_OR_OVERWRITE
Create database if it doesn't already exist, or overwrite if it does.
void flush_post_lists(GlassPostListTable &table, const std::string &pfx)
Flush postlist changes for all terms which start with pfx.
A TermList in a glass database.
unsigned XAPIAN_DOCID_BASE_TYPE docid
A unique identifier for a document.
Class representing a query.
DatabaseError indicates some sort of database related error.
std::string get_data() const
Get data stored in the document.
const std::string write(glass_revision_number_t new_rev, int flags)
Abstract base class for iterating term positions in a document.
TermList * open_term_list(Xapian::docid did) const
Virtual methods of Database::Internal.
void cancel(const RootInfo &root_info, glass_revision_number_t rev)
Override methods of GlassTable.
Xapian::totallength get_total_length() const
Virtual methods of Database::Internal.
glass_revision_number_t get_revision() const
void clear_synonyms(const string &word) const
Virtual methods of Database::Internal.
A smart pointer that uses intrusive reference counting.
bool exists() const
Determine whether the btree exists on disk.
Xapian::Document::Internal * open_document(Xapian::docid did, bool lazy) const
Virtual methods of Database::Internal.
std::string get_uuid_string() const
Return UUID in the standard 36 character string format.
TermList * open_allterms(const string &prefix) const
Virtual methods of Database::Internal.
bool has_uncommitted_changes() const
Return true if there are uncommitted changes.
void add_document(Xapian::docid did, const Xapian::Document &doc, std::map< Xapian::valueno, ValueStats > &value_stats)
A document read from a GlassDatabase.
void flush_doclengths(GlassPostListTable &table)
Flush document length changes.
void set_last_docid(Xapian::docid did)
virtual Xapian::termcount positionlist_count(Xapian::docid did, const string &term) const
Virtual methods of Database::Internal.
TermIterator termlist_begin() const
Start iterating the terms in this document.
GlassValueManager value_manager
Value manager.
std::string get_value_upper_bound(Xapian::valueno slot) const
GlassSpellingTable spelling_table
Table storing spelling correction data.
A handle representing a document in a Xapian database.
bool del(const std::string &key)
Delete an entry from the table.
std::string get_value_lower_bound(Xapian::valueno slot) const
Wrapper around standard unique_ptr template.
void replace_document(Xapian::docid did, const Xapian::Document &doc, std::map< Xapian::valueno, ValueStats > &value_stats)
#define LOGCALL(CATEGORY, TYPE, FUNC, PARAMS)
bool readonly
Whether the database is readonly.
bool get_deltas(const std::string &term, Xapian::termcount_diff &tf_delta, Xapian::termcount_diff &cf_delta) const
Xapian::doccount get_doccount() const
Xapian::termcount get_doclength_upper_bound() const
Virtual methods of Database::Internal.
string get_revision_info() const
Virtual methods of Database::Internal.
bool is_modified() const
Override methods of GlassTable.
void apply()
Apply changes.
#define MAX_SAFE_TERM_LENGTH
Xapian::termcount get_unique_terms(Xapian::docid did) const
Virtual methods of Database::Internal.
void clear_synonyms(const std::string &term)
Remove all synonyms for term.
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.