25 #ifndef OM_HGUARD_CHERT_DATABASE_H
26 #define OM_HGUARD_CHERT_DATABASE_H
39 #include "../flint_lock.h"
200 const std::string & msg);
245 ChertDatabase(
const string &db_dir_,
int action = Xapian::DB_READONLY_,
246 unsigned int block_size = 0u);
299 const string & start_revision,
325 const char * destdir,
326 const std::vector<Xapian::Database::Internal *> & sources,
327 const std::vector<Xapian::docid> & offset,
338 mutable map<string, pair<Xapian::termcount_diff, Xapian::termcount_diff> >
342 mutable map<Xapian::docid, Xapian::termcount>
doclens;
402 const string & tname,
417 const string & tname,
486 void add_synonym(
const string & word,
const string & synonym)
const;
487 void remove_synonym(
const string & word,
const string & synonym)
const;
490 void set_metadata(
const string & key,
const string & value);
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())
database class declarations
Chert class for database statistics.
A position list in a chert database.
Postlists in chert databases.
Records in chert databases.
Spelling correction data for a chert database.
Synonym data for a chert database.
Subclass of ChertTable which holds termlists.
Types used by chert backend and the Btree manager.
unsigned int chert_revision_number_t
A type used to store a revision number for a table.
A cursor pointing to a position in a Btree table, for reading several entries in order,...
Chert class for database statistics.
A backend designed for efficient indexing and retrieval, using compressed posting lists and a btree s...
bool readonly
Whether the database is readonly.
ChertTermListTable termlist_table
Table storing term lists.
Xapian::docid get_lastdocid() const
Return the last used document id of this (sub) database.
TermList * open_spelling_wordlist() const
Return a termlist which returns the words which are spelling correction targets.
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 db_dir
Directory to store databases in.
Xapian::doccount get_doccount() const
Virtual methods of Database::Internal.
Xapian::termcount get_doclength_upper_bound() const
Get an upper bound on the length of a document in this DB.
void open_tables(chert_revision_number_t revision)
Open tables at specified revision number.
ChertValueManager value_manager
Value manager.
PositionList * open_position_list(Xapian::docid did, const string &term) const
Open a position list for the given term in the given document.
chert_revision_number_t get_next_revision_number() const
Get an object holding the next revision number which should be used in the tables.
void get_used_docid_range(Xapian::docid &first, Xapian::docid &last) const
Find lowest and highest docids actually in use.
Xapian::doccount get_value_freq(Xapian::valueno slot) const
Return the frequency of a given value slot.
void set_revision_number(chert_revision_number_t new_revision)
Set the revision number in the tables.
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.
unsigned int max_changesets
The maximum number of changesets which should be kept in the database.
void get_changeset_revisions(const string &path, chert_revision_number_t *startrev, chert_revision_number_t *endrev) const
Get the revision stored in a changeset.
bool term_exists(const string &tname) const
Check whether a given term is in the database.
void get_freqs(const string &term, Xapian::doccount *termfreq_ptr, Xapian::termcount *collfreq_ptr) const
Returns frequencies for a term.
ChertDatabase(const string &db_dir_, int action=Xapian::DB_READONLY_, unsigned int block_size=0u)
Create and open a chert database.
TermList * open_allterms(const string &prefix) const
Open an allterms list.
void apply()
Apply any outstanding changes to the tables.
Xapian::Document::Internal * open_document(Xapian::docid did, bool lazy) const
Open a document.
Xapian::totallength get_total_length() const
Return the total length of all documents in this database.
TermList * open_synonym_termlist(const string &term) const
Open a termlist returning synonyms for a term.
TermList * open_spelling_termlist(const string &word) const
Create a termlist tree from trigrams of word.
TermList * open_term_list(Xapian::docid did) const
Open a term list.
ValueList * open_value_list(Xapian::valueno slot) const
Open a value stream.
FlintLock lock
Lock object.
void close()
Close all the tables permanently.
virtual bool has_uncommitted_changes() const
Return true if there are uncommitted changes.
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 get_doclength(Xapian::docid did) const
Get the length of a given document.
void request_document(Xapian::docid) const
Request and later collect a document from the database.
bool open_tables_consistent()
Open all tables at most recent consistent revision.
void cancel()
Cancel any outstanding changes to the tables.
string get_metadata(const string &key) const
Get the metadata associated with a given key.
ChertCursor * get_postlist_cursor() const
Get a postlist table cursor (used by ChertValueList).
string get_uuid() const
Get a UUID for the database.
TermList * open_metadata_keylist(const std::string &prefix) const
Open a termlist returning each metadata key.
ChertSynonymTable synonym_table
Table storing synonym data.
void readahead_for_query(const Xapian::Query &query)
void send_whole_database(RemoteConnection &conn, double end_time)
Send a set of messages which transfer the whole database.
bool database_exists()
Return true if a database exists at the path specified for this database.
ChertPostListTable postlist_table
Table storing posting lists.
Xapian::doccount get_spelling_frequency(const string &word) const
Return the number of times word was added as a spelling.
bool has_positions() const
Check whether this database contains any positional information.
void create_and_open_tables(unsigned int blocksize)
Create new tables, and open them.
std::string get_value_lower_bound(Xapian::valueno slot) const
Get a lower bound on the values stored in the given value slot.
Xapian::termcount get_doclength_lower_bound() const
Get a lower bound on the length of a document in this DB.
ChertPositionListTable position_table
Table storing position lists.
bool locked() const
Return true if the database is open for writing.
ChertVersion version_file
The file describing the Chert database.
bool reopen()
Re-open tables to recover from an overwritten condition, or just get most up-to-date version.
Xapian::termcount get_unique_terms(Xapian::docid did) const
Get the number of unique term in document.
string get_revision_info() const
Get a string describing the current revision of the database.
LeafPostList * open_post_list(const string &tname) const
Open a posting list.
void throw_termlist_table_close_exception() const
chert_revision_number_t get_revision_number() const
Get an object holding the revision number which the tables are opened at.
ChertRecordTable record_table
Table storing records.
ChertSpellingTable spelling_table
Table storing spelling correction data.
TermList * open_synonym_keylist(const string &prefix) const
Open a termlist returning each term which has synonyms.
ChertDatabaseStats stats
Database statistics.
Xapian::termcount get_wdf_upper_bound(const string &term) const
Get an upper bound on the wdf of term term.
int get_backend_info(string *path) const
Get backend information about this database.
static void compact(Xapian::Compactor *compactor, const char *destdir, const std::vector< Xapian::Database::Internal * > &sources, const std::vector< Xapian::docid > &offset, size_t block_size, Xapian::Compactor::compaction_level compaction, unsigned flags, Xapian::docid last_docid)
void modifications_failed(chert_revision_number_t old_revision, chert_revision_number_t new_revision, const std::string &msg)
Called if a modifications fail.
friend class ChertWritableDatabase
A postlist in a chert database.
Xapian::docid did
Document id we're currently at.
A record in a chert database.
ChertCursor * cursor_get() const
Get a cursor for reading from the table.
A TermList in a chert database.
The ChertVersion class manages the "iamchert" file.
A writable chert database.
TermList * open_spelling_wordlist() const
Return a termlist which returns the words which are spelling correction targets.
void replace_document(Xapian::docid did, const Xapian::Document &document)
Replace a given document in the database.
map< Xapian::docid, Xapian::termcount > doclens
Document lengths of new and modified documents which haven't been flushed yet.
void check_flush_threshold()
Check if we should autoflush.
void add_spelling(const string &word, Xapian::termcount freqinc) const
Add a word to the spelling dictionary.
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.
void clear_synonyms(const string &word) const
Clear all synonyms for a term.
map< string, pair< Xapian::termcount_diff, Xapian::termcount_diff > > freq_deltas
Unflushed changes to term frequencies and collection frequencies.
void cancel()
Cancel pending modifications to the database.
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...
bool term_exists(const string &tname) const
Check whether a given term is in the database.
Xapian::docid add_document_(Xapian::docid did, const Xapian::Document &document)
map< string, map< Xapian::docid, pair< char, Xapian::termcount > > > mod_plists
Modifications to posting lists.
void update_mod_plist(Xapian::docid did, const string &tname, char type, Xapian::termcount wdf)
Update the stored modifications to the postlists.
void flush_postlist_changes() const
Flush any unflushed postlist changes, but don't commit them.
void invalidate_doc_object(Xapian::Document::Internal *obj) const
Notify the database that document is no longer valid.
void insert_mod_plist(Xapian::docid did, const string &tname, Xapian::termcount wdf)
Insert modifications for a new document to the postlists.
void add_freq_delta(const string &tname, Xapian::termcount_diff tf_delta, Xapian::termcount_diff cf_delta)
Add or modify an entry in freq_deltas.
ValueList * open_value_list(Xapian::valueno slot) const
Open a value stream.
Xapian::doccount get_value_freq(Xapian::valueno slot) const
Return the frequency of a given value slot.
Xapian::Document::Internal * open_document(Xapian::docid did, bool lazy) const
Open a document.
bool has_uncommitted_changes() const
Return true if there are uncommitted changes.
void add_synonym(const string &word, const string &synonym) const
Add a synonym for a term.
void remove_spelling(const string &word, Xapian::termcount freqdec) const
Remove a word from the spelling dictionary.
Xapian::termcount get_unique_terms(Xapian::docid did) const
Get the number of unique term in document.
void apply()
Apply changes.
map< Xapian::valueno, ValueStats > value_stats
Xapian::termcount get_doclength(Xapian::docid did) const
Virtual methods of Database::Internal.
std::string get_value_lower_bound(Xapian::valueno slot) const
Get a lower bound on the values stored in the given value slot.
TermList * open_allterms(const string &prefix) const
Open an allterms list.
void get_freqs(const string &term, Xapian::doccount *termfreq_ptr, Xapian::termcount *collfreq_ptr) const
Returns frequencies for a term.
void commit()
Implementation of virtual methods: see Database::Internal for details.
std::string get_value_upper_bound(Xapian::valueno slot) const
Get an upper bound on the values stored in the given value slot.
void set_metadata(const string &key, const string &value)
Set the metadata associated with a given key.
Xapian::docid modify_shortcut_docid
The document ID for the last document returned by open_document().
TermList * open_synonym_keylist(const string &prefix) const
Open a termlist returning each term which has synonyms.
void close()
Close all the tables permanently.
void remove_synonym(const string &word, const string &synonym) const
Remove a synonym for a term.
Xapian::doccount change_count
The number of documents added, deleted, or replaced since the last flush.
LeafPostList * open_post_list(const string &tname) const
Open a posting list.
void delete_document(Xapian::docid did)
Delete a document in the database.
Abstract base class for leaf postlists.
std::string term
The term name for this postlist (empty for an alldocs postlist).
A RemoteConnection object provides a bidirectional connection to another RemoteConnection object on a...
Compact a database, or merge and compact several.
compaction_level
Compaction level.
Base class for databases.
virtual void replace_document(Xapian::docid did, const Xapian::Document &document)
Replace a given document in the database.
virtual void delete_document(Xapian::docid did)
Delete a document in the database.
A document in the database, possibly plus modifications.
A handle representing a document in a Xapian database.
Abstract base class for iterating term positions in a document.
Class representing a query.
Abstract base class for termlists.
Abstract base class for value streams.
Compact a database, or merge and compact several.
Constants in the Xapian namespace.
double end_time(double timeout)
Return the end time for a timeout in timeout seconds.
int revision()
Report the revision of the library which the program is linked with.
XAPIAN_TERMCOUNT_BASE_TYPE termcount_diff
A signed difference between two counts of terms.
unsigned XAPIAN_TERMCOUNT_BASE_TYPE termcount
A counts of terms.
unsigned valueno
The number for a value slot in a document.
unsigned XAPIAN_DOCID_BASE_TYPE doccount
A count of documents.
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.
Define the XAPIAN_NORETURN macro.
Information about the steps involved in performing a replication.