|
xapian-core
2.0.0
|
A backend designed for efficient indexing and retrieval, using compressed posting lists and a btree storage scheme. More...
#include <glass_database.h>
Inheritance diagram for GlassDatabase:
Collaboration diagram for GlassDatabase:Public Member Functions | |
| GlassDatabase (std::string_view db_dir_, int flags=Xapian::DB_READONLY_, unsigned int block_size=0u) | |
| Create and open a glass database. More... | |
| GlassDatabase (int fd) | |
| ~GlassDatabase () | |
| GlassCursor * | get_postlist_cursor () const |
| Get a postlist table cursor (used by GlassValueList). More... | |
| Xapian::doccount | get_doccount () const |
| Virtual methods of Database::Internal. More... | |
| Xapian::docid | get_lastdocid () const |
| Return the last used document id of this (sub) database. More... | |
| Xapian::totallength | get_total_length () const |
| Return the total length of all documents in this database. More... | |
| Xapian::termcount | get_doclength (Xapian::docid did) const |
| Xapian::termcount | get_unique_terms (Xapian::docid did) const |
| Get the number of unique terms in document. More... | |
| Xapian::termcount | get_wdfdocmax (Xapian::docid did) const |
| Get the max wdf in document. More... | |
| void | get_freqs (std::string_view term, Xapian::doccount *termfreq_ptr, Xapian::termcount *collfreq_ptr) const |
| Returns frequencies for a term. More... | |
| Xapian::doccount | get_value_freq (Xapian::valueno slot) const |
| Return the frequency of a given value slot. More... | |
| std::string | get_value_lower_bound (Xapian::valueno slot) const |
| Get a lower bound on the values stored in the given value slot. More... | |
| std::string | get_value_upper_bound (Xapian::valueno slot) const |
| Get an upper bound on the values stored in the given value slot. More... | |
| Xapian::termcount | get_doclength_lower_bound () const |
| Get a lower bound on the length of a document in this DB. More... | |
| Xapian::termcount | get_doclength_upper_bound () const |
| Get an upper bound on the length of a document in this DB. More... | |
| Xapian::termcount | get_wdf_upper_bound (std::string_view term) const |
| Get an upper bound on the wdf of term term. More... | |
| Xapian::termcount | get_unique_terms_lower_bound () const |
| Get a lower bound on the unique terms size of a document in this DB. More... | |
| bool | term_exists (std::string_view term) const |
| bool | has_positions () const |
| Check whether this database contains any positional information. More... | |
| PostList * | open_post_list (std::string_view tname) const |
| Return a PostList suitable for use in a PostingIterator. More... | |
| LeafPostList * | open_leaf_post_list (std::string_view term, bool need_read_pos) const |
| Create a LeafPostList for use during a match. More... | |
| ValueList * | open_value_list (Xapian::valueno slot) const |
| Open a value stream. More... | |
| Xapian::Document::Internal * | open_document (Xapian::docid did, bool lazy) const |
| Open a handle on a document. More... | |
| virtual void | read_position_list (GlassRePositionList *pos_list, Xapian::docid did, std::string_view term) const |
| virtual Xapian::termcount | positionlist_count (Xapian::docid did, std::string_view term) const |
| PositionList * | open_position_list (Xapian::docid did, std::string_view term) const |
| TermList * | open_term_list (Xapian::docid did) const |
| TermList * | open_term_list_direct (Xapian::docid did) const |
| Like open_term_list() but without MultiTermList wrapper. More... | |
| TermList * | open_allterms (std::string_view prefix) const |
| TermList * | open_spelling_termlist (std::string_view word) const |
| Create a termlist tree from trigrams of word. More... | |
| TermList * | open_spelling_wordlist () const |
| Return a termlist which returns the words which are spelling correction targets. More... | |
| Xapian::doccount | get_spelling_frequency (std::string_view word) const |
| Return the number of times word was added as a spelling. More... | |
| TermList * | open_synonym_termlist (std::string_view term) const |
| Open a termlist returning synonyms for a term. More... | |
| TermList * | open_synonym_keylist (std::string_view prefix) const |
| Open a termlist returning each term which has synonyms. More... | |
| string | get_metadata (std::string_view key) const |
| Get the metadata associated with a given key. More... | |
| TermList * | open_metadata_keylist (std::string_view prefix) const |
| Open a termlist returning each metadata key. More... | |
| 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. More... | |
| Xapian::rev | get_revision () const |
| Get the revision number which the tables are opened at. More... | |
| string | get_uuid () const |
| Get a UUID for the database. More... | |
| void | request_document (Xapian::docid) const |
| Request a document. More... | |
| void | readahead_for_query (const Xapian::Query &query) const |
| void | throw_termlist_table_close_exception () const |
| int | get_backend_info (string *path) const |
| Get backend information about this database. More... | |
| bool | single_file () const |
| void | get_used_docid_range (Xapian::docid &first, Xapian::docid &last) const |
| Find lowest and highest docids actually in use. More... | |
| virtual bool | has_uncommitted_changes () const |
| Return true if there are uncommitted changes. More... | |
| bool | locked () const |
| Return true if the database is open for writing. More... | |
| Xapian::Database::Internal * | update_lock (int flags) |
| Lock a read-only database for writing or unlock a writable database. More... | |
| std::string | get_description () const |
| Return a string describing this object. More... | |
Public Member Functions inherited from Xapian::Database::Internal | |
| virtual | ~Internal () |
| We have virtual methods and want to be able to delete derived classes using a pointer to the base class, so we need a virtual destructor. More... | |
| virtual size_type | size () const |
| virtual void | keep_alive () |
| virtual termcount | get_unique_terms_upper_bound () const |
| Get an upper bound on the unique terms size of a document in this DB. More... | |
| virtual void | add_spelling (std::string_view word, termcount freqinc) const |
| Add a word to the spelling dictionary. More... | |
| virtual termcount | remove_spelling (std::string_view word, termcount freqdec) const |
| Remove a word from the spelling dictionary. More... | |
| virtual void | add_synonym (std::string_view term, std::string_view synonym) const |
| Add a synonym for a term. More... | |
| virtual void | remove_synonym (std::string_view term, std::string_view synonym) const |
| Remove a synonym for a term. More... | |
| virtual void | clear_synonyms (std::string_view term) const |
| Clear all synonyms for a term. More... | |
| virtual void | set_metadata (std::string_view key, std::string_view value) |
| Set the metadata associated with a given key. More... | |
| virtual void | commit () |
| Commit pending modifications to the database. More... | |
| virtual void | begin_transaction (bool flushed) |
| Begin transaction. More... | |
| virtual void | end_transaction (bool do_commit) |
| End transaction. More... | |
| virtual docid | add_document (const Document &document) |
| virtual void | delete_document (docid did) |
| virtual void | delete_document (std::string_view unique_term) |
| Delete any documents indexed by a term from the database. More... | |
| virtual void | replace_document (docid did, const Document &document) |
| virtual docid | replace_document (std::string_view unique_term, const Document &document) |
| Replace any documents matching a term. More... | |
| virtual void | invalidate_doc_object (Document::Internal *obj) const |
| Notify the database that document is no longer valid. More... | |
| virtual std::string | reconstruct_text (Xapian::docid did, size_t length, std::string_view prefix, Xapian::termpos start_pos, Xapian::termpos end_pos) const |
Public Member Functions inherited from Xapian::Internal::intrusive_base | |
| intrusive_base () | |
| Construct with no references. More... | |
Static Public Member Functions | |
| static void | compact (Xapian::Compactor *compactor, const char *destdir, int fd, const std::vector< const Xapian::Database::Internal * > &sources, const std::vector< Xapian::docid > &offset, unsigned block_size, Xapian::Compactor::compaction_level compaction, unsigned flags, Xapian::docid last_docid) |
Private Member Functions | |
| bool | database_exists () |
| Return true if a database exists at the path specified for this database. More... | |
| void | create_and_open_tables (int flags, unsigned int blocksize) |
| Create new tables, and open them. More... | |
| bool | open_tables (int flags) |
| Open all tables at most recent revision. More... | |
| void | get_database_write_lock (int flags, bool creating) |
| Get a write lock on the database, or throw an Xapian::DatabaseLockError if failure. More... | |
| glass_revision_number_t | get_next_revision_number () const |
| Get an object holding the next revision number which should be used in the tables. More... | |
| void | set_revision_number (int flags, glass_revision_number_t new_revision) |
| Set the revision number in the tables. More... | |
| bool | reopen () |
| Re-open tables to recover from an overwritten condition, or just get most up-to-date version. More... | |
| void | close () |
| Close all the tables permanently. More... | |
| void | modifications_failed (glass_revision_number_t new_revision, const std::string &msg) |
| Called if a modifications fail. More... | |
| void | apply () |
| Apply any outstanding changes to the tables. More... | |
| void | cancel () |
| Cancel any outstanding changes to the tables. More... | |
| void | send_whole_database (RemoteConnection &conn, double end_time) |
| Send a set of messages which transfer the whole database. More... | |
| 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. More... | |
Private Attributes | |
| std::string | db_dir |
| Directory to store databases in. More... | |
| bool | readonly |
| Whether the database is readonly. More... | |
| GlassVersion | version_file |
| The file describing the Glass database. More... | |
| GlassPostListTable | postlist_table |
| Table storing posting lists. More... | |
| GlassPositionListTable | position_table |
| Table storing position lists. More... | |
| GlassTermListTable | termlist_table |
| Table storing term lists. More... | |
| GlassValueManager | value_manager |
| Value manager. More... | |
| GlassSynonymTable | synonym_table |
| Table storing synonym data. More... | |
| GlassSpellingTable | spelling_table |
| Table storing spelling correction data. More... | |
| GlassDocDataTable | docdata_table |
| Table storing document data. More... | |
| FlintLock | lock |
| Lock object. More... | |
| GlassChanges | changes |
| Replication changesets. More... | |
Friends | |
| class | GlassWritableDatabase |
| class | GlassTermList |
| class | GlassPostList |
| class | GlassAllTermsList |
| class | GlassAllDocsPostList |
| class | GlassSpellingWordsList |
| class | GlassSynonymTermList |
| class | HoneyDatabase |
Additional Inherited Members | |
Public Types inherited from Xapian::Database::Internal | |
| typedef Xapian::doccount | size_type |
Public Attributes inherited from Xapian::Internal::intrusive_base | |
| unsigned | _refs |
| Reference count. More... | |
Protected Types inherited from Xapian::Database::Internal | |
| enum | transaction_state { TRANSACTION_READONLY = -2 , TRANSACTION_UNIMPLEMENTED = -1 , TRANSACTION_NONE = 0 , TRANSACTION_UNFLUSHED = 1 , TRANSACTION_FLUSHED = 2 } |
| Transaction state enum. More... | |
Protected Member Functions inherited from Xapian::Database::Internal | |
| Internal (transaction_state transaction_support) | |
| Only constructable as a base class for derived classes. More... | |
| bool | is_read_only () const |
| Test if this shard is read-only. More... | |
| bool | transaction_active () const |
| Test if a transaction is currently active. More... | |
| void | dtor_called () |
| Helper to process uncommitted changes when a writable db is destroyed. More... | |
Protected Attributes inherited from Xapian::Database::Internal | |
| transaction_state | state |
| Current transaction state. More... | |
A backend designed for efficient indexing and retrieval, using compressed posting lists and a btree storage scheme.
Definition at line 57 of file glass_database.h.
|
explicit |
Create and open a glass database.
| Xapian::DatabaseCorruptError | is thrown if a problem is found with the database's format. |
| Xapian::DatabaseOpeningError | thrown if database can't be opened. |
| Xapian::DatabaseVersionError | thrown if database is in an unsupported format. This implies that the database was created by an older or newer version of Xapian. |
| dbdir | directory holding glass tables |
| block_size | Block size, in bytes, to use when creating tables. This is only important, and has the correct value, when the database is being created. |
Definition at line 97 of file glass_database.cc.
References create_and_open_tables(), database_exists(), Xapian::DB_CREATE, Xapian::DB_CREATE_OR_OVERWRITE, db_dir, Xapian::DB_OPEN, dir_exists(), get_database_write_lock(), GLASS_DEFAULT_BLOCKSIZE, GLASS_MAX_BLOCKSIZE, GLASS_MIN_BLOCKSIZE, LOGCALL_CTOR, open_tables(), and readonly.
Referenced by GlassWritableDatabase::update_lock().
|
explicit |
Definition at line 167 of file glass_database.cc.
References LOGCALL_CTOR, and open_tables().
| GlassDatabase::~GlassDatabase | ( | ) |
Definition at line 186 of file glass_database.cc.
References LOGCALL_DTOR.
|
private |
Apply any outstanding changes to the tables.
If an error occurs during this operation, this will be signalled by an exception being thrown. In this case the contents of the tables on disk will be left in an unmodified state (though possibly with increased revision numbers), and the outstanding changes will be lost.
Definition at line 648 of file glass_database.cc.
References changes, docdata_table, Xapian::Error::get_description(), GlassTable::get_flags(), get_next_revision_number(), GlassSpellingTable::is_modified(), GlassSynonymTable::is_modified(), GlassTable::is_modified(), GlassValueManager::is_modified(), LOGCALL_VOID, modifications_failed(), p, position_table, postlist_table, GlassTable::set_changes(), GlassVersion::set_changes(), set_revision_number(), spelling_table, GlassChanges::start(), synonym_table, termlist_table, value_manager, and version_file.
Referenced by GlassWritableDatabase::apply().
|
privatevirtual |
Cancel any outstanding changes to the tables.
Reimplemented from Xapian::Database::Internal.
Reimplemented in GlassWritableDatabase.
Definition at line 686 of file glass_database.cc.
References GlassValueManager::cancel(), GlassVersion::cancel(), GlassSpellingTable::cancel(), GlassSynonymTable::cancel(), GlassTable::cancel(), Glass::DOCDATA, docdata_table, GlassVersion::get_revision(), GlassVersion::get_root(), GlassVersion::get_spelling_wordfreq_upper_bound(), LOGCALL_VOID, Glass::POSITION, position_table, Glass::POSTLIST, postlist_table, GlassSpellingTable::set_wordfreq_upper_bound(), Glass::SPELLING, spelling_table, Glass::SYNONYM, synonym_table, Glass::TERMLIST, termlist_table, value_manager, and version_file.
Referenced by GlassWritableDatabase::cancel(), and modifications_failed().
|
privatevirtual |
Close all the tables permanently.
Implements Xapian::Database::Internal.
Reimplemented in GlassWritableDatabase.
Definition at line 401 of file glass_database.cc.
References GlassTable::close(), docdata_table, lock, LOGCALL_VOID, position_table, postlist_table, FlintLock::release(), spelling_table, synonym_table, and termlist_table.
Referenced by GlassWritableDatabase::close(), and modifications_failed().
|
static |
Definition at line 778 of file glass_compact.cc.
References Assert, GlassTable::commit(), GlassTable::create_and_open(), Xapian::DB_DANGEROUS, Xapian::DBCOMPACT_MULTIPASS, Xapian::DBCOMPACT_SINGLE_FILE, Glass::DOCDATA, GlassTable::empty(), file_size(), GlassTable::flush_db(), Glass::RootInfo::get_free_list(), GlassTable::get_path(), GLASS_DEFAULT_BLOCKSIZE, GLASS_MAX_BLOCKSIZE, GLASS_MIN_BLOCKSIZE, GLASS_TABLE_EXTENSION, GlassTable::is_modified(), FlintLock::lock(), GlassCompact::merge_docid_keyed(), GlassCompact::merge_positions(), GlassCompact::merge_postlists(), GlassCompact::merge_spellings(), GlassCompact::merge_synonyms(), GlassCompact::multimerge_postlists(), O_BINARY, O_CLOEXEC, GlassTable::open(), Xapian::Remote::open(), GlassFreeList::pack(), Glass::POSITION, Glass::POSTLIST, FlintLock::release(), GlassFreeList::set_first_unused_block(), Glass::RootInfo::set_free_list(), GlassTable::set_full_compaction(), Xapian::Compactor::set_status(), Glass::SPELLING, Xapian::Compactor::STANDARD, Xapian::Internal::str(), FlintLock::SUCCESS, GlassTable::sync(), Glass::SYNONYM, Glass::TERMLIST, and FlintLock::throw_databaselockerror().
Referenced by Xapian::Database::compact_().
|
private |
Create new tables, and open them.
Any existing tables will be removed first.
Definition at line 199 of file glass_database.cc.
References Assert, GlassVersion::create(), GlassTable::create_and_open(), database_exists(), Glass::DOCDATA, docdata_table, GlassVersion::get_revision(), GlassVersion::get_root(), LOGCALL_VOID, Glass::POSITION, position_table, Glass::POSTLIST, postlist_table, Glass::SPELLING, spelling_table, GlassVersion::sync(), Glass::SYNONYM, synonym_table, Glass::TERMLIST, termlist_table, version_file, and GlassVersion::write().
Referenced by GlassDatabase().
|
private |
Return true if a database exists at the path specified for this database.
Definition at line 192 of file glass_database.cc.
References GlassTable::exists(), LOGCALL, postlist_table, and RETURN.
Referenced by create_and_open_tables(), get_database_write_lock(), and GlassDatabase().
|
inlinevirtual |
Get backend information about this database.
| path | If non-NULL, and set the pointed to string to the file path of this database (or to some string describing the database in a backend-specified format if "path" isn't a concept which makes sense). |
Implements Xapian::Database::Internal.
Definition at line 309 of file glass_database.h.
References BACKEND_GLASS, db_dir, and HoneyDatabase::path.
|
private |
Get the revision stored in a changeset.
Definition at line 288 of file glass_database.cc.
References CHANGES_MAGIC_STRING, CHANGES_VERSION, CONST_STRLEN, io_read(), O_CLOEXEC, posixy_open, REASONABLE_CHANGESET_SIZE, and unpack_uint().
Referenced by write_changesets_to_fd().
|
private |
Get a write lock on the database, or throw an Xapian::DatabaseLockError if failure.
| flags | Bit-wise or of zero or more Xapian::DB_* constants |
| creating | true if the database is in the process of being created - if false, will throw a DatabaseOpening error if the lock can't be acquired and the database doesn't exist. |
Definition at line 414 of file glass_database.cc.
References database_exists(), db_dir, Xapian::DB_RETRY_LOCK, FlintLock::lock(), lock, LOGCALL_VOID, FlintLock::SUCCESS, FlintLock::throw_databaselockerror(), and FlintLock::UNKNOWN.
Referenced by GlassDatabase().
|
virtual |
Return a string describing this object.
Implements Xapian::Database::Internal.
Definition at line 1055 of file glass_database.cc.
|
virtual |
Virtual methods of Database::Internal.
Implements Xapian::Database::Internal.
Definition at line 704 of file glass_database.cc.
References GlassVersion::get_doccount(), LOGCALL, RETURN, and version_file.
Referenced by GlassTermList::accumulate_stats(), open_leaf_post_list(), GlassWritableDatabase::open_leaf_post_list(), term_exists(), and GlassWritableDatabase::term_exists().
|
virtual |
Implements Xapian::Database::Internal.
Reimplemented in GlassWritableDatabase.
Definition at line 725 of file glass_database.cc.
References Assert, GlassPostListTable::get_doclength(), LOGCALL, postlist_table, and RETURN.
Referenced by GlassWritableDatabase::get_doclength(), and open_document().
|
virtual |
Get a lower bound on the length of a document in this DB.
This bound does not include any zero-length documents.
Implements Xapian::Database::Internal.
Definition at line 789 of file glass_database.cc.
References GlassVersion::get_doclength_lower_bound(), and version_file.
|
virtual |
Get an upper bound on the length of a document in this DB.
Implements Xapian::Database::Internal.
Definition at line 795 of file glass_database.cc.
References GlassVersion::get_doclength_upper_bound(), and version_file.
|
virtual |
Returns frequencies for a term.
| term | The term to get frequencies for |
| termfreq_ptr | Point to return number of docs indexed by term (or NULL not to return) |
| collfreq_ptr | Point to return number of occurrences of term in the database (or NULL not to return) |
Implements Xapian::Database::Internal.
Reimplemented in GlassWritableDatabase.
Definition at line 758 of file glass_database.cc.
References Assert, GlassPostListTable::get_freqs(), LOGCALL_VOID, postlist_table, and term.
Referenced by GlassWritableDatabase::get_freqs(), and GlassTermList::get_termfreq().
|
virtual |
Return the last used document id of this (sub) database.
Implements Xapian::Database::Internal.
Definition at line 711 of file glass_database.cc.
References GlassVersion::get_last_docid(), LOGCALL, RETURN, and version_file.
|
virtual |
Get the metadata associated with a given key.
See Database::get_metadata() for more information.
Reimplemented from Xapian::Database::Internal.
Definition at line 971 of file glass_database.cc.
References GlassTable::get_exact_entry(), LOGCALL, postlist_table, and RETURN.
|
private |
Get an object holding the next revision number which should be used in the tables.
Definition at line 278 of file glass_database.cc.
References GlassVersion::get_revision(), LOGCALL, RETURN, and version_file.
Referenced by apply().
|
inline |
Get a postlist table cursor (used by GlassValueList).
Definition at line 239 of file glass_database.h.
References GlassTable::cursor_get(), and postlist_table.
|
virtual |
Get the revision number which the tables are opened at.
Reimplemented from Xapian::Database::Internal.
Definition at line 992 of file glass_database.cc.
References GlassVersion::get_revision(), LOGCALL, RETURN, and version_file.
Referenced by send_whole_database(), and write_changesets_to_fd().
|
virtual |
Return the number of times word was added as a spelling.
Reimplemented from Xapian::Database::Internal.
Definition at line 950 of file glass_database.cc.
References GlassSpellingTable::get_word_frequency(), and spelling_table.
|
virtual |
Return the total length of all documents in this database.
Implements Xapian::Database::Internal.
Definition at line 718 of file glass_database.cc.
References GlassVersion::get_total_doclen(), LOGCALL, RETURN, and version_file.
|
virtual |
Get the number of unique terms in document.
| did | The document id of the document to return this value for. |
Implements Xapian::Database::Internal.
Reimplemented in GlassWritableDatabase.
Definition at line 734 of file glass_database.cc.
References Assert, GlassTermList, LOGCALL, and RETURN.
Referenced by GlassWritableDatabase::get_unique_terms().
|
virtual |
Get a lower bound on the unique terms size of a document in this DB.
Reimplemented from Xapian::Database::Internal.
Definition at line 810 of file glass_database.cc.
References GlassVersion::get_unique_terms_lower_bound(), and version_file.
|
virtual |
Find lowest and highest docids actually in use.
Used during local matching and compaction, so only needs to be implemented by backends which support one or both of these.
For example, EmptyDatabase, MultiDatabase and RemoteDatabase don't need to implement this (empty shards are skipped early by the matcher; sharded databases are handled explicitly by the matcher rather than via the "multi" backend; matching for remote shards runs as a local match on the remote).
Reimplemented from Xapian::Database::Internal.
Definition at line 1016 of file glass_database.cc.
References GlassVersion::get_doccount(), GlassVersion::get_last_docid(), GlassPostListTable::get_used_docid_range(), postlist_table, and version_file.
|
virtual |
Get a UUID for the database.
The UUID will persist for the lifetime of the database.
Replicas (eg, made with the replication protocol, or by copying all the database files) will have the same UUID. However, copies (made with copydatabase, or xapian-compact) will have different UUIDs.
If the backend does not support UUIDs the empty string is returned.
Reimplemented from Xapian::Database::Internal.
Definition at line 999 of file glass_database.cc.
References GlassVersion::get_uuid_string(), LOGCALL, RETURN, and version_file.
Referenced by send_whole_database(), and write_changesets_to_fd().
|
virtual |
Return the frequency of a given value slot.
This is the number of documents which have a (non-empty) value stored in the slot.
| slot | The value slot to examine. |
Implements Xapian::Database::Internal.
Reimplemented in GlassWritableDatabase.
Definition at line 768 of file glass_database.cc.
References GlassValueManager::get_value_freq(), LOGCALL, RETURN, and value_manager.
Referenced by GlassWritableDatabase::get_value_freq().
|
virtual |
Get a lower bound on the values stored in the given value slot.
If there are no values stored in the given value slot, this will return an empty string.
| slot | The value slot to examine. |
Implements Xapian::Database::Internal.
Reimplemented in GlassWritableDatabase.
Definition at line 775 of file glass_database.cc.
References GlassValueManager::get_value_lower_bound(), LOGCALL, RETURN, and value_manager.
Referenced by GlassWritableDatabase::get_value_lower_bound().
|
virtual |
Get an upper bound on the values stored in the given value slot.
If there are no values stored in the given value slot, this will return an empty string.
| slot | The value slot to examine. |
Implements Xapian::Database::Internal.
Reimplemented in GlassWritableDatabase.
Definition at line 782 of file glass_database.cc.
References GlassValueManager::get_value_upper_bound(), LOGCALL, RETURN, and value_manager.
Referenced by GlassWritableDatabase::get_value_upper_bound().
|
virtual |
Get an upper bound on the wdf of term term.
Implements Xapian::Database::Internal.
Definition at line 801 of file glass_database.cc.
References Assert, GlassPostListTable::get_freqs(), GlassVersion::get_wdf_upper_bound(), postlist_table, term, and version_file.
|
virtual |
Get the max wdf in document.
| did | The document id of the document to return this value for. |
Implements Xapian::Database::Internal.
Definition at line 743 of file glass_database.cc.
References Assert, GlassTermList::get_wdf(), LOGCALL, GlassTermList::next(), and RETURN.
|
virtual |
Check whether this database contains any positional information.
Implements Xapian::Database::Internal.
Reimplemented in GlassWritableDatabase.
Definition at line 826 of file glass_database.cc.
References GlassTable::empty(), and position_table.
|
virtual |
Return true if there are uncommitted changes.
Reimplemented in GlassWritableDatabase.
Definition at line 1029 of file glass_database.cc.
Referenced by HoneyDatabase::compact().
|
virtual |
Return true if the database is open for writing.
If this is a WritableDatabase, always returns true.
For a Database, test if there's a writer holding the lock (or if we can't test for a lock without taking it on the current platform, throw Xapian::UnimplementedError).
Reimplemented from Xapian::Database::Internal.
Definition at line 1035 of file glass_database.cc.
References lock, and FlintLock::test().
|
private |
Called if a modifications fail.
| msg | is a string description of the exception that was raised when the modifications failed. |
Definition at line 606 of file glass_database.cc.
References cancel(), changes, close(), Glass::DOCDATA, docdata_table, GlassTable::get_flags(), Xapian::Error::get_msg(), GlassVersion::get_revision(), GlassVersion::get_root(), GlassPostListTable::open(), GlassTable::open(), p, Glass::POSITION, position_table, Glass::POSTLIST, postlist_table, GlassVersion::read(), GlassValueManager::reset(), GlassTable::set_changes(), GlassVersion::set_changes(), Glass::SPELLING, spelling_table, GlassChanges::start(), Glass::SYNONYM, synonym_table, Glass::TERMLIST, termlist_table, value_manager, and version_file.
Referenced by apply().
|
virtual |
Implements Xapian::Database::Internal.
Reimplemented in GlassWritableDatabase.
Definition at line 927 of file glass_database.cc.
References GlassAllTermsList, LOGCALL, and RETURN.
Referenced by GlassWritableDatabase::open_allterms().
|
virtual |
Open a handle on a document.
The returned handle provides access to document data and document values.
| did | The document id to open. |
| lazy | If true, there's no need to check that this document actually exists (only a hint - the backend may still check). Used to avoid unnecessary work when we already know that the requested document exists. |
Implements Xapian::Database::Internal.
Reimplemented in GlassWritableDatabase.
Definition at line 891 of file glass_database.cc.
References Assert, docdata_table, get_doclength(), LOGCALL, RETURN, and value_manager.
Referenced by GlassWritableDatabase::open_document().
|
virtual |
Create a LeafPostList for use during a match.
| term | The term to open a postlist for, or the empty string to create an all-docs postlist. |
| need_read_pos | Does the postlist need to support read_position_list()? Note that open_position_list() may still be called even if need_read_pos is false. |
Implements Xapian::Database::Internal.
Reimplemented in GlassWritableDatabase.
Definition at line 839 of file glass_database.cc.
References Assert, get_doccount(), GlassVersion::get_last_docid(), GlassAllDocsPostList, GlassPostList, LOGCALL, rare, RETURN, term, and version_file.
Referenced by open_post_list().
|
virtual |
Open a termlist returning each metadata key.
Only metadata keys which are associated with a non-empty value will be returned.
| prefix | If non-empty, only keys with this prefix are returned. |
Reimplemented from Xapian::Database::Internal.
Definition at line 982 of file glass_database.cc.
References GlassTable::cursor_get(), LOGCALL, postlist_table, and RETURN.
|
virtual |
Implements Xapian::Database::Internal.
Reimplemented in GlassWritableDatabase.
Definition at line 920 of file glass_database.cc.
References Assert, GlassPositionListTable::open_position_list(), position_table, and term.
Referenced by GlassPostList::open_position_list(), GlassWritableDatabase::open_position_list(), and GlassTermList::positionlist_begin().
|
virtual |
Return a PostList suitable for use in a PostingIterator.
Implements Xapian::Database::Internal.
Reimplemented in GlassWritableDatabase.
Definition at line 832 of file glass_database.cc.
References LOGCALL, open_leaf_post_list(), RETURN, and term.
|
virtual |
Create a termlist tree from trigrams of word.
You can assume word.size() > 1.
If there are no trigrams, returns NULL.
Reimplemented from Xapian::Database::Internal.
Definition at line 935 of file glass_database.cc.
References GlassSpellingTable::open_termlist(), and spelling_table.
|
virtual |
Return a termlist which returns the words which are spelling correction targets.
If there are no spelling correction targets, returns NULL.
Reimplemented from Xapian::Database::Internal.
Reimplemented in GlassWritableDatabase.
Definition at line 941 of file glass_database.cc.
References GlassTable::cursor_get(), GlassSpellingWordsList, and spelling_table.
Referenced by GlassWritableDatabase::open_spelling_wordlist().
|
virtual |
Open a termlist returning each term which has synonyms.
| prefix | If non-empty, only terms with this prefix are returned. |
Reimplemented from Xapian::Database::Internal.
Reimplemented in GlassWritableDatabase.
Definition at line 962 of file glass_database.cc.
References GlassTable::cursor_get(), GlassSynonymTermList, and synonym_table.
Referenced by GlassWritableDatabase::open_synonym_keylist().
|
virtual |
Open a termlist returning synonyms for a term.
If term has no synonyms, returns NULL.
Reimplemented from Xapian::Database::Internal.
Definition at line 956 of file glass_database.cc.
References GlassSynonymTable::open_termlist(), synonym_table, and term.
|
private |
Open all tables at most recent revision.
| Xapian::DatabaseCorruptError | is thrown if a problem is found with the database's format. |
Definition at line 226 of file glass_database.cc.
References changes, Glass::DOCDATA, docdata_table, GlassVersion::get_oldest_changeset(), GlassVersion::get_revision(), GlassVersion::get_root(), GlassVersion::get_spelling_wordfreq_upper_bound(), GlassTable::is_open(), LOGCALL, GlassPostListTable::open(), GlassTable::open(), p, Glass::POSITION, position_table, Glass::POSTLIST, postlist_table, GlassVersion::read(), readonly, GlassValueManager::reset(), RETURN, Xapian::revision(), GlassTable::set_changes(), GlassVersion::set_changes(), GlassChanges::set_oldest_changeset(), GlassSpellingTable::set_wordfreq_upper_bound(), Glass::SPELLING, spelling_table, GlassChanges::start(), Glass::SYNONYM, synonym_table, Glass::TERMLIST, termlist_table, GlassTable::throw_database_closed(), value_manager, and version_file.
Referenced by GlassDatabase(), and reopen().
|
virtual |
Implements Xapian::Database::Internal.
Definition at line 874 of file glass_database.cc.
References Assert, GlassTermList, GlassTable::is_open(), LOGCALL, RETURN, termlist_table, and throw_termlist_table_close_exception().
Referenced by open_term_list_direct().
|
virtual |
Like open_term_list() but without MultiTermList wrapper.
MultiDatabase::open_term_list() wraps the returns TermList in a MultiTermList, but we don't want that for query expansion.
Implements Xapian::Database::Internal.
Definition at line 885 of file glass_database.cc.
References open_term_list().
|
virtual |
Open a value stream.
This returns the value in a particular slot for each document.
| slot | The value slot. |
Reimplemented from Xapian::Database::Internal.
Reimplemented in GlassWritableDatabase.
Definition at line 866 of file glass_database.cc.
References LOGCALL, and RETURN.
Referenced by GlassWritableDatabase::open_value_list().
|
virtual |
Reimplemented in GlassWritableDatabase.
Definition at line 914 of file glass_database.cc.
References position_table, GlassPositionListTable::positionlist_count(), and term.
Referenced by GlassTermList::positionlist_count(), and GlassWritableDatabase::positionlist_count().
|
virtual |
Reimplemented in GlassWritableDatabase.
Definition at line 905 of file glass_database.cc.
References Assert, GlassRePositionList::read_data(), and term.
Referenced by GlassPostList::read_position_list(), and GlassWritableDatabase::read_position_list().
|
virtual |
Reimplemented from Xapian::Database::Internal.
Definition at line 382 of file glass_database.cc.
References Xapian::Query::get_unique_terms_begin(), GlassPostListTable::make_key(), postlist_table, query(), GlassTable::readahead_key(), and term.
|
privatevirtual |
Re-open tables to recover from an overwritten condition, or just get most up-to-date version.
Reimplemented from Xapian::Database::Internal.
Definition at line 393 of file glass_database.cc.
References GlassTable::get_flags(), LOGCALL, open_tables(), postlist_table, readonly, and RETURN.
Referenced by write_changesets_to_fd().
|
virtual |
Request a document.
This tells the database that we're going to want a particular document soon. It's just a hint which the backend may ignore, but for glass it issues a preread hint on the file with the document data in, and for the remote backend it might cause the document to be fetched asynchronously (this isn't currently implemented though).
It can be called for multiple documents in turn, and a common usage pattern would be to iterate over an MSet and request the documents, then iterate over it again to actually get and display them.
The default implementation is a no-op.
Reimplemented from Xapian::Database::Internal.
Definition at line 376 of file glass_database.cc.
References docdata_table, and GlassDocDataTable::readahead_for_document().
|
private |
Send a set of messages which transfer the whole database.
Definition at line 435 of file glass_database.cc.
References db_dir, RealTime::end_time(), get_revision(), get_uuid(), GLASS_TABLE_EXTENSION, LOGCALL_VOID, O_CLOEXEC, p, pack_string(), pack_uint(), posixy_open, REPL_REPLY_DB_FILEDATA, REPL_REPLY_DB_FILENAME, REPL_REPLY_DB_HEADER, RemoteConnection::send_file(), and RemoteConnection::send_message().
Referenced by write_changesets_to_fd().
|
private |
Set the revision number in the tables.
This updates the disk tables so that the currently open revision becomes the specified revision number.
| new_revision | The new revision number to store. This must be greater than the current revision number. FIXME: If we support rewinding to a previous revision, maybe this needs to be greater than any previously used revision. |
Definition at line 330 of file glass_database.cc.
References changes, GlassChanges::commit(), GlassTable::commit(), Glass::DOCDATA, docdata_table, GlassSpellingTable::flush_db(), GlassSynonymTable::flush_db(), GlassTable::flush_db(), GlassVersion::get_revision(), LOGCALL_VOID, GlassValueManager::merge_changes(), Glass::POSITION, position_table, Glass::POSTLIST, postlist_table, GlassVersion::root_to_set(), GlassVersion::set_spelling_wordfreq_upper_bound(), Glass::SPELLING, spelling_table, Xapian::Internal::str(), GlassTable::sync(), GlassVersion::sync(), Glass::SYNONYM, synonym_table, Glass::TERMLIST, termlist_table, value_manager, version_file, and GlassVersion::write().
Referenced by apply().
|
inline |
Definition at line 314 of file glass_database.h.
References GlassVersion::single_file(), and version_file.
|
virtual |
Implements Xapian::Database::Internal.
Reimplemented in GlassWritableDatabase.
Definition at line 816 of file glass_database.cc.
References get_doccount(), LOGCALL, postlist_table, RETURN, term, and GlassPostListTable::term_exists().
| void GlassDatabase::throw_termlist_table_close_exception | ( | ) | const |
Definition at line 1006 of file glass_database.cc.
References GlassTable::is_open(), postlist_table, and GlassTable::throw_database_closed().
Referenced by GlassWritableDatabase::delete_document(), open_term_list(), and GlassWritableDatabase::replace_document().
|
virtual |
Lock a read-only database for writing or unlock a writable database.
This is the internal method behind Database::lock() and Database::unlock().
In the unlocking case, the writable database is closed. In the locking case, the read-only database is left open.
| flags | Xapian::DB_READONLY_ to unlock, otherwise the flags to use when opening from writing. |
Reimplemented from Xapian::Database::Internal.
Reimplemented in GlassWritableDatabase.
Definition at line 1041 of file glass_database.cc.
References db_dir, Xapian::DB_OPEN, GlassWritableDatabase, GlassTable::is_open(), postlist_table, and GlassTable::throw_database_closed().
|
virtual |
Write a set of changesets to a file descriptor.
This call may reopen the database, leaving it pointing to a more recent version of the database.
Reimplemented from Xapian::Database::Internal.
Definition at line 475 of file glass_database.cc.
References Xapian::ReplicationInfo::changed, Xapian::ReplicationInfo::changeset_count, db_dir, Xapian::ReplicationInfo::fullcopy_count, get_changeset_revisions(), get_revision(), get_uuid(), LOGCALL_VOID, MAX_DB_COPIES_PER_CONVERSATION, O_CLOEXEC, pack_uint(), posixy_open, reopen(), REPL_REPLY_CHANGESET, REPL_REPLY_DB_FOOTER, REPL_REPLY_END_OF_CHANGES, REPL_REPLY_FAIL, Xapian::revision(), RemoteConnection::send_file(), RemoteConnection::send_message(), send_whole_database(), Xapian::Internal::str(), and unpack_uint().
|
friend |
Definition at line 62 of file glass_database.h.
Referenced by open_leaf_post_list(), and GlassWritableDatabase::open_leaf_post_list().
|
friend |
Definition at line 61 of file glass_database.h.
Referenced by open_allterms().
|
friend |
Definition at line 60 of file glass_database.h.
Referenced by open_leaf_post_list(), and GlassWritableDatabase::open_leaf_post_list().
|
friend |
Definition at line 63 of file glass_database.h.
Referenced by open_spelling_wordlist().
|
friend |
Definition at line 64 of file glass_database.h.
Referenced by open_synonym_keylist().
|
friend |
Definition at line 59 of file glass_database.h.
Referenced by get_unique_terms(), and open_term_list().
|
friend |
Definition at line 58 of file glass_database.h.
Referenced by update_lock().
|
friend |
Definition at line 65 of file glass_database.h.
|
private |
Replication changesets.
Definition at line 117 of file glass_database.h.
Referenced by apply(), GlassWritableDatabase::flush_postlist_changes(), modifications_failed(), open_tables(), and set_revision_number().
|
private |
Directory to store databases in.
Definition at line 70 of file glass_database.h.
Referenced by get_backend_info(), get_database_write_lock(), get_description(), GlassDatabase(), send_whole_database(), update_lock(), GlassWritableDatabase::update_lock(), and write_changesets_to_fd().
|
private |
Table storing document data.
Definition at line 111 of file glass_database.h.
Referenced by GlassWritableDatabase::add_document_(), apply(), cancel(), close(), create_and_open_tables(), GlassWritableDatabase::delete_document(), GlassWritableDatabase::has_uncommitted_changes(), modifications_failed(), open_document(), open_tables(), GlassWritableDatabase::replace_document(), request_document(), set_revision_number(), and GlassWritableDatabase::update_lock().
|
private |
Lock object.
Definition at line 114 of file glass_database.h.
Referenced by close(), get_database_write_lock(), and locked().
|
mutableprivate |
Table storing position lists.
Definition at line 92 of file glass_database.h.
Referenced by GlassWritableDatabase::add_document_(), apply(), cancel(), close(), create_and_open_tables(), GlassWritableDatabase::flush_postlist_changes(), has_positions(), GlassWritableDatabase::has_positions(), GlassWritableDatabase::has_uncommitted_changes(), modifications_failed(), open_position_list(), open_tables(), positionlist_count(), GlassWritableDatabase::positionlist_count(), GlassPostList::read_position_list(), GlassWritableDatabase::replace_document(), set_revision_number(), and GlassWritableDatabase::update_lock().
|
mutableprivate |
Table storing posting lists.
Whenever an update is performed, this table is the first to be updated: therefore, its most recent revision number is the most recent anywhere in the database.
Definition at line 88 of file glass_database.h.
Referenced by apply(), cancel(), close(), create_and_open_tables(), database_exists(), GlassWritableDatabase::flush_postlist_changes(), get_doclength(), get_freqs(), get_metadata(), get_postlist_cursor(), get_used_docid_range(), get_wdf_upper_bound(), GlassWritableDatabase::has_uncommitted_changes(), modifications_failed(), GlassWritableDatabase::open_allterms(), GlassWritableDatabase::open_leaf_post_list(), open_metadata_keylist(), GlassPostList::open_nearby_postlist(), open_tables(), readahead_for_query(), reopen(), GlassWritableDatabase::replace_document(), GlassWritableDatabase::set_metadata(), set_revision_number(), term_exists(), throw_termlist_table_close_exception(), update_lock(), and GlassWritableDatabase::update_lock().
|
private |
Whether the database is readonly.
Definition at line 74 of file glass_database.h.
Referenced by get_description(), GlassDatabase(), open_tables(), and reopen().
|
mutableprivate |
Table storing spelling correction data.
Definition at line 107 of file glass_database.h.
Referenced by GlassWritableDatabase::add_spelling(), apply(), cancel(), close(), create_and_open_tables(), get_spelling_frequency(), GlassWritableDatabase::has_uncommitted_changes(), modifications_failed(), open_spelling_termlist(), open_spelling_wordlist(), GlassWritableDatabase::open_spelling_wordlist(), open_tables(), GlassWritableDatabase::remove_spelling(), set_revision_number(), and GlassWritableDatabase::update_lock().
|
mutableprivate |
Table storing synonym data.
Definition at line 103 of file glass_database.h.
Referenced by GlassWritableDatabase::add_synonym(), apply(), cancel(), GlassWritableDatabase::clear_synonyms(), close(), create_and_open_tables(), GlassWritableDatabase::has_uncommitted_changes(), modifications_failed(), open_synonym_keylist(), GlassWritableDatabase::open_synonym_keylist(), open_synonym_termlist(), open_tables(), GlassWritableDatabase::remove_synonym(), set_revision_number(), and GlassWritableDatabase::update_lock().
|
private |
Table storing term lists.
Definition at line 96 of file glass_database.h.
Referenced by GlassWritableDatabase::add_document_(), apply(), cancel(), close(), create_and_open_tables(), GlassWritableDatabase::delete_document(), GlassTermList::GlassTermList(), GlassWritableDatabase::has_uncommitted_changes(), modifications_failed(), open_tables(), open_term_list(), GlassWritableDatabase::replace_document(), set_revision_number(), and GlassWritableDatabase::update_lock().
|
mutableprivate |
Value manager.
Definition at line 99 of file glass_database.h.
Referenced by GlassWritableDatabase::add_document_(), apply(), GlassWritableDatabase::apply(), cancel(), GlassWritableDatabase::delete_document(), get_value_freq(), get_value_lower_bound(), get_value_upper_bound(), GlassWritableDatabase::has_uncommitted_changes(), modifications_failed(), open_document(), open_tables(), GlassWritableDatabase::open_value_list(), GlassWritableDatabase::replace_document(), and set_revision_number().
|
private |
The file describing the Glass database.
This file has information about the format of the database which can't easily be stored in any of the individual tables.
Definition at line 80 of file glass_database.h.
Referenced by GlassWritableDatabase::add_document(), GlassWritableDatabase::add_document_(), apply(), cancel(), HoneyDatabase::compact(), create_and_open_tables(), GlassWritableDatabase::delete_document(), GlassWritableDatabase::flush_postlist_changes(), get_doccount(), get_doclength_lower_bound(), get_doclength_upper_bound(), get_lastdocid(), get_next_revision_number(), get_revision(), get_total_length(), get_unique_terms_lower_bound(), get_used_docid_range(), get_uuid(), get_wdf_upper_bound(), modifications_failed(), open_leaf_post_list(), GlassWritableDatabase::open_leaf_post_list(), open_tables(), GlassWritableDatabase::replace_document(), set_revision_number(), and single_file().