xapian-core
1.4.26
|
A writable glass database. More...
#include <glass_database.h>
Public Member Functions | |
GlassWritableDatabase (const string &dir, int flags, int block_size) | |
Create and open a writable glass database. More... | |
~GlassWritableDatabase () | |
bool | has_uncommitted_changes () const |
Return true if there are uncommitted changes. More... | |
Xapian::termcount | get_doclength (Xapian::docid did) const |
Virtual methods of Database::Internal. More... | |
Xapian::termcount | get_unique_terms (Xapian::docid did) const |
Virtual methods of Database::Internal. More... | |
void | get_freqs (const string &term, Xapian::doccount *termfreq_ptr, Xapian::termcount *collfreq_ptr) const |
Virtual methods of Database::Internal. More... | |
Xapian::doccount | get_value_freq (Xapian::valueno slot) const |
Virtual methods of Database::Internal. More... | |
std::string | get_value_lower_bound (Xapian::valueno slot) const |
Virtual methods of Database::Internal. More... | |
std::string | get_value_upper_bound (Xapian::valueno slot) const |
Virtual methods of Database::Internal. More... | |
bool | term_exists (const string &tname) const |
Virtual methods of Database::Internal. More... | |
bool | has_positions () const |
Virtual methods of Database::Internal. More... | |
LeafPostList * | open_post_list (const string &tname) const |
Virtual methods of Database::Internal. More... | |
ValueList * | open_value_list (Xapian::valueno slot) const |
Virtual methods of Database::Internal. More... | |
void | read_position_list (GlassPositionList *pos_list, Xapian::docid did, const string &term) const |
Virtual methods of Database::Internal. More... | |
Xapian::termcount | positionlist_count (Xapian::docid did, const string &term) const |
Virtual methods of Database::Internal. More... | |
PositionList * | open_position_list (Xapian::docid did, const string &term) const |
Virtual methods of Database::Internal. More... | |
TermList * | open_allterms (const string &prefix) const |
Virtual methods of Database::Internal. More... | |
void | add_spelling (const string &word, Xapian::termcount freqinc) const |
Virtual methods of Database::Internal. More... | |
void | remove_spelling (const string &word, Xapian::termcount freqdec) const |
Virtual methods of Database::Internal. More... | |
TermList * | open_spelling_wordlist () const |
Virtual methods of Database::Internal. More... | |
TermList * | open_synonym_keylist (const string &prefix) const |
Virtual methods of Database::Internal. More... | |
void | add_synonym (const string &word, const string &synonym) const |
Virtual methods of Database::Internal. More... | |
void | remove_synonym (const string &word, const string &synonym) const |
Virtual methods of Database::Internal. More... | |
void | clear_synonyms (const string &word) const |
Virtual methods of Database::Internal. More... | |
void | set_metadata (const string &key, const string &value) |
Virtual methods of Database::Internal. More... | |
void | invalidate_doc_object (Xapian::Document::Internal *obj) const |
Virtual methods of Database::Internal. More... | |
Public Member Functions inherited from GlassDatabase | |
GlassDatabase (const string &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... | |
glass_revision_number_t | get_revision_number () const |
Get an object holding the revision number which the tables are opened at. More... | |
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... | |
bool | locked () const |
Return true if the database is open for writing. More... | |
Xapian::doccount | get_doccount () const |
Virtual methods of Database::Internal. More... | |
Xapian::docid | get_lastdocid () const |
Virtual methods of Database::Internal. More... | |
Xapian::totallength | get_total_length () const |
Virtual methods of Database::Internal. More... | |
Xapian::termcount | get_doclength_lower_bound () const |
Virtual methods of Database::Internal. More... | |
Xapian::termcount | get_doclength_upper_bound () const |
Virtual methods of Database::Internal. More... | |
Xapian::termcount | get_wdf_upper_bound (const string &term) const |
Virtual methods of Database::Internal. More... | |
TermList * | open_term_list (Xapian::docid did) const |
Virtual methods of Database::Internal. More... | |
TermList * | open_spelling_termlist (const string &word) const |
Virtual methods of Database::Internal. More... | |
Xapian::doccount | get_spelling_frequency (const string &word) const |
Virtual methods of Database::Internal. More... | |
TermList * | open_synonym_termlist (const string &term) const |
Virtual methods of Database::Internal. More... | |
string | get_metadata (const string &key) const |
Virtual methods of Database::Internal. More... | |
TermList * | open_metadata_keylist (const std::string &prefix) const |
Virtual methods of Database::Internal. More... | |
void | write_changesets_to_fd (int fd, const string &start_revision, bool need_whole_db, Xapian::ReplicationInfo *info) |
Virtual methods of Database::Internal. More... | |
string | get_revision_info () const |
Virtual methods of Database::Internal. More... | |
string | get_uuid () const |
Virtual methods of Database::Internal. More... | |
void | request_document (Xapian::docid) const |
Virtual methods of Database::Internal. More... | |
void | readahead_for_query (const Xapian::Query &query) |
Virtual methods of Database::Internal. More... | |
Public Member Functions inherited from Xapian::Database::Internal | |
virtual | ~Internal () |
Destroy the database. More... | |
virtual void | keep_alive () |
Send a keep-alive signal to a remote database, to stop it from timing out. More... | |
void | begin_transaction (bool flushed) |
Begin a transaction. More... | |
void | commit_transaction () |
Commit a transaction. More... | |
void | cancel_transaction () |
Cancel a transaction. More... | |
virtual void | delete_document (const string &unique_term) |
Delete any documents indexed by a term from the database. More... | |
virtual Xapian::docid | replace_document (const string &unique_term, const Xapian::Document &document) |
Replace any documents matching a term. More... | |
virtual Xapian::Document::Internal * | collect_document (Xapian::docid did) const |
Request and later collect a document from the database. More... | |
Public Member Functions inherited from Xapian::Internal::intrusive_base | |
intrusive_base () | |
Construct with no references. More... | |
Private Member Functions | |
void | check_flush_threshold () |
Check if we should autoflush. More... | |
void | flush_postlist_changes () |
Flush any unflushed postlist changes, but don't commit them. More... | |
void | close () |
Close all the tables permanently. More... | |
void | apply () |
Apply changes. More... | |
void | commit () |
Implementation of virtual methods: see Database::Internal for details. More... | |
void | cancel () |
Cancel pending modifications to the database. More... | |
Xapian::docid | add_document (const Xapian::Document &document) |
Implementation of virtual methods: see Database::Internal for details. More... | |
Xapian::docid | add_document_ (Xapian::docid did, const Xapian::Document &document) |
Implementation of virtual methods: see Database::Internal for details. More... | |
void | delete_document (Xapian::docid did) |
Implementation of virtual methods: see Database::Internal for details. More... | |
void | replace_document (Xapian::docid did, const Xapian::Document &document) |
Implementation of virtual methods: see Database::Internal for details. More... | |
Xapian::Document::Internal * | open_document (Xapian::docid did, bool lazy) const |
Implementation of virtual methods: see Database::Internal for details. More... | |
Private Attributes | |
Inverter | inverter |
map< Xapian::valueno, ValueStats > | value_stats |
Xapian::doccount | change_count |
The number of documents added, deleted, or replaced since the last flush. More... | |
Xapian::doccount | flush_threshold |
If change_count reaches this threshold we automatically flush. More... | |
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 valid document. More... | |
Xapian::docid | modify_shortcut_docid |
The document ID for the last document returned by open_document(). More... | |
Additional Inherited Members | |
Static Public Member Functions inherited from GlassDatabase | |
static void | compact (Xapian::Compactor *compactor, const char *destdir, int fd, 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) |
Public Attributes inherited from Xapian::Internal::intrusive_base | |
unsigned | _refs |
Reference count. More... | |
Protected Types inherited from Xapian::Database::Internal | |
enum | { TRANSACTION_UNIMPLEMENTED = -1, TRANSACTION_NONE = 0, TRANSACTION_UNFLUSHED = 1, TRANSACTION_FLUSHED = 2 } |
Transaction state. More... | |
Protected Member Functions inherited from Xapian::Database::Internal | |
bool | transaction_active () const |
Internal () | |
Create a database - called only by derived classes. More... | |
void | dtor_called () |
Internal method to perform cleanup when a writable database is destroyed with uncommitted changes. More... | |
Protected Attributes inherited from Xapian::Database::Internal | |
enum Xapian::Database::Internal:: { ... } | transaction_state |
Transaction state. More... | |
A writable glass database.
Definition at line 332 of file glass_database.h.
GlassWritableDatabase::GlassWritableDatabase | ( | const string & | dir, |
int | flags, | ||
int | block_size | ||
) |
Create and open a writable glass database.
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. |
dir | directory holding glass tables |
Definition at line 1015 of file glass_database.cc.
References flush_threshold, and LOGCALL_CTOR.
GlassWritableDatabase::~GlassWritableDatabase | ( | ) |
Definition at line 1032 of file glass_database.cc.
References Xapian::Database::Internal::dtor_called(), and LOGCALL_DTOR.
|
privatevirtual |
Implementation of virtual methods: see Database::Internal for details.
Reimplemented from Xapian::Database::Internal.
Definition at line 1096 of file glass_database.cc.
References add_document_(), GlassVersion::get_last_docid(), GlassVersion::get_next_docid(), GLASS_MAX_DOCID, LOGCALL, RETURN, and GlassDatabase::version_file.
|
private |
Implementation of virtual methods: see Database::Internal for details.
Definition at line 1107 of file glass_database.cc.
References GlassValueManager::add_document(), GlassVersion::add_document(), Inverter::add_posting(), Assert, cancel(), check_flush_threshold(), GlassVersion::check_wdf(), GlassDatabase::docdata_table, Xapian::Document::get_data(), Xapian::TermIterator::get_wdf(), inverter, GlassTable::is_open(), LOGCALL, LOGLINE, MAX_SAFE_TERM_LENGTH, GlassDatabase::position_table, GlassDocDataTable::replace_document_data(), RETURN, Inverter::set_doclength(), Inverter::set_positionlist(), GlassTermListTable::set_termlist(), STRINGIZE, Xapian::Document::termlist_begin(), Xapian::Document::termlist_end(), GlassDatabase::termlist_table, GlassDatabase::value_manager, value_stats, and GlassDatabase::version_file.
Referenced by add_document(), and replace_document().
|
virtual |
Virtual methods of Database::Internal.
Reimplemented from Xapian::Database::Internal.
Definition at line 1594 of file glass_database.cc.
References GlassSpellingTable::add_word(), and GlassDatabase::spelling_table.
|
virtual |
Virtual methods of Database::Internal.
Reimplemented from Xapian::Database::Internal.
Definition at line 1622 of file glass_database.cc.
References GlassSynonymTable::add_synonym(), and GlassDatabase::synonym_table.
|
private |
Apply changes.
Definition at line 1089 of file glass_database.cc.
References GlassDatabase::apply(), GlassValueManager::set_value_stats(), GlassDatabase::value_manager, and value_stats.
Referenced by check_flush_threshold(), and commit().
|
privatevirtual |
Cancel pending modifications to the database.
Reimplemented from GlassDatabase.
Definition at line 1585 of file glass_database.cc.
References GlassDatabase::cancel(), change_count, Inverter::clear(), inverter, and value_stats.
Referenced by add_document_(), delete_document(), flush_postlist_changes(), and replace_document().
|
private |
Check if we should autoflush.
Called at the end of each document changing operation.
Definition at line 1048 of file glass_database.cc.
References apply(), change_count, flush_postlist_changes(), flush_threshold, and Xapian::Database::Internal::transaction_active().
Referenced by add_document_(), delete_document(), and replace_document().
|
virtual |
Virtual methods of Database::Internal.
Reimplemented from Xapian::Database::Internal.
Definition at line 1636 of file glass_database.cc.
References GlassSynonymTable::clear_synonyms(), and GlassDatabase::synonym_table.
|
privatevirtual |
Close all the tables permanently.
Reimplemented from GlassDatabase.
Definition at line 1078 of file glass_database.cc.
References GlassDatabase::close(), commit(), LOGCALL_VOID, and Xapian::Database::Internal::transaction_active().
|
privatevirtual |
Implementation of virtual methods: see Database::Internal for details.
Reimplemented from Xapian::Database::Internal.
Definition at line 1039 of file glass_database.cc.
References apply(), change_count, flush_postlist_changes(), and Xapian::Database::Internal::transaction_active().
Referenced by close().
|
privatevirtual |
Implementation of virtual methods: see Database::Internal for details.
Reimplemented from Xapian::Database::Internal.
Definition at line 1160 of file glass_database.cc.
References Assert, GlassTermList::at_end(), cancel(), check_flush_threshold(), Inverter::delete_doclength(), GlassValueManager::delete_document(), GlassVersion::delete_document(), GlassDocDataTable::delete_document_data(), Inverter::delete_positionlist(), GlassTermListTable::delete_termlist(), GlassDatabase::docdata_table, GlassTermList::get_doclength(), get_doclength(), GlassTermList::get_termname(), GlassTermList::get_wdf(), inverter, GlassTable::is_open(), LOGCALL_VOID, modify_shortcut_docid, modify_shortcut_document, GlassTermList::next(), rare, Inverter::remove_posting(), GlassDatabase::termlist_table, GlassDatabase::throw_termlist_table_close_exception(), GlassDatabase::value_manager, value_stats, and GlassDatabase::version_file.
|
private |
Flush any unflushed postlist changes, but don't commit them.
Definition at line 1060 of file glass_database.cc.
References cancel(), change_count, GlassDatabase::changes, Inverter::flush(), Inverter::flush_pos_lists(), GlassChanges::get_oldest_changeset(), inverter, GlassDatabase::position_table, GlassDatabase::postlist_table, GlassVersion::set_oldest_changeset(), and GlassDatabase::version_file.
Referenced by check_flush_threshold(), and commit().
|
virtual |
Virtual methods of Database::Internal.
Reimplemented from GlassDatabase.
Definition at line 1395 of file glass_database.cc.
References Inverter::get_doclength(), GlassDatabase::get_doclength(), inverter, LOGCALL, and RETURN.
Referenced by delete_document().
|
virtual |
Virtual methods of Database::Internal.
Reimplemented from GlassDatabase.
Definition at line 1424 of file glass_database.cc.
References Assert, Inverter::get_deltas(), GlassDatabase::get_freqs(), inverter, and LOGCALL_VOID.
Referenced by term_exists().
|
virtual |
Virtual methods of Database::Internal.
Reimplemented from GlassDatabase.
Definition at line 1405 of file glass_database.cc.
References Assert, GlassTermList::get_approx_size(), Inverter::get_doclength(), GlassDatabase::get_unique_terms(), inverter, LOGCALL, and RETURN.
|
virtual |
Virtual methods of Database::Internal.
Reimplemented from GlassDatabase.
Definition at line 1441 of file glass_database.cc.
References GlassDatabase::get_value_freq(), LOGCALL, RETURN, and value_stats.
|
virtual |
Virtual methods of Database::Internal.
Reimplemented from GlassDatabase.
Definition at line 1451 of file glass_database.cc.
References GlassDatabase::get_value_lower_bound(), LOGCALL, RETURN, and value_stats.
|
virtual |
Virtual methods of Database::Internal.
Reimplemented from GlassDatabase.
Definition at line 1461 of file glass_database.cc.
References GlassDatabase::get_value_upper_bound(), LOGCALL, RETURN, and value_stats.
|
virtual |
Virtual methods of Database::Internal.
Reimplemented from GlassDatabase.
Definition at line 1480 of file glass_database.cc.
References Inverter::has_positions(), inverter, and GlassDatabase::position_table.
|
virtual |
Return true if there are uncommitted changes.
Reimplemented from GlassDatabase.
Definition at line 1664 of file glass_database.cc.
References change_count, GlassDatabase::docdata_table, GlassSynonymTable::is_modified(), GlassSpellingTable::is_modified(), GlassValueManager::is_modified(), GlassTable::is_modified(), GlassDatabase::position_table, GlassDatabase::postlist_table, GlassDatabase::spelling_table, GlassDatabase::synonym_table, GlassDatabase::termlist_table, and GlassDatabase::value_manager.
|
virtual |
Virtual methods of Database::Internal.
Reimplemented from Xapian::Database::Internal.
Definition at line 1655 of file glass_database.cc.
References modify_shortcut_docid, and modify_shortcut_document.
|
virtual |
Virtual methods of Database::Internal.
Reimplemented from GlassDatabase.
Definition at line 1565 of file glass_database.cc.
References change_count, Inverter::flush_post_lists(), inverter, LOGCALL, GlassDatabase::open_allterms(), GlassDatabase::postlist_table, and RETURN.
|
privatevirtual |
Implementation of virtual methods: see Database::Internal for details.
Reimplemented from GlassDatabase.
Definition at line 1384 of file glass_database.cc.
References LOGCALL, modify_shortcut_docid, modify_shortcut_document, GlassDatabase::open_document(), and RETURN.
|
virtual |
Virtual methods of Database::Internal.
Reimplemented from GlassDatabase.
Definition at line 1546 of file glass_database.cc.
References Assert, Inverter::get_positionlist(), inverter, and GlassDatabase::position_table.
|
virtual |
Virtual methods of Database::Internal.
Reimplemented from GlassDatabase.
Definition at line 1486 of file glass_database.cc.
References Inverter::flush_doclengths(), Inverter::flush_post_list(), GlassDatabase::get_doccount(), GlassVersion::get_last_docid(), GlassDatabase::GlassAllDocsPostList, GlassDatabase::GlassPostList, inverter, LOGCALL, GlassDatabase::postlist_table, RETURN, and GlassDatabase::version_file.
|
virtual |
Virtual methods of Database::Internal.
Reimplemented from GlassDatabase.
Definition at line 1608 of file glass_database.cc.
References GlassSpellingTable::merge_changes(), GlassDatabase::open_spelling_wordlist(), and GlassDatabase::spelling_table.
|
virtual |
Virtual methods of Database::Internal.
Reimplemented from GlassDatabase.
Definition at line 1615 of file glass_database.cc.
References GlassSynonymTable::merge_changes(), GlassDatabase::open_synonym_keylist(), and GlassDatabase::synonym_table.
|
virtual |
Virtual methods of Database::Internal.
Reimplemented from GlassDatabase.
Definition at line 1507 of file glass_database.cc.
References change_count, LOGCALL, GlassValueManager::merge_changes(), GlassDatabase::open_value_list(), RETURN, and GlassDatabase::value_manager.
|
virtual |
Virtual methods of Database::Internal.
Reimplemented from GlassDatabase.
Definition at line 1532 of file glass_database.cc.
References Assert, Inverter::get_positionlist(), inverter, GlassDatabase::position_table, GlassPositionListTable::positionlist_count(), and GlassDatabase::positionlist_count().
|
virtual |
Virtual methods of Database::Internal.
Reimplemented from GlassDatabase.
Definition at line 1518 of file glass_database.cc.
References Assert, Inverter::get_positionlist(), inverter, GlassPositionList::read_data(), and GlassDatabase::read_position_list().
|
virtual |
Virtual methods of Database::Internal.
Reimplemented from Xapian::Database::Internal.
Definition at line 1601 of file glass_database.cc.
References GlassSpellingTable::remove_word(), and GlassDatabase::spelling_table.
|
virtual |
Virtual methods of Database::Internal.
Reimplemented from Xapian::Database::Internal.
Definition at line 1629 of file glass_database.cc.
References GlassSynonymTable::remove_synonym(), and GlassDatabase::synonym_table.
|
privatevirtual |
Implementation of virtual methods: see Database::Internal for details.
Reimplemented from Xapian::Database::Internal.
Definition at line 1224 of file glass_database.cc.
References GlassVersion::add_document(), add_document_(), Inverter::add_posting(), Assert, GlassTermList::at_end(), cancel(), check_flush_threshold(), GlassVersion::check_wdf(), GlassVersion::delete_document(), Inverter::delete_positionlist(), GlassDatabase::docdata_table, GlassPostListTable::document_exists(), Xapian::Document::get_data(), GlassTermList::get_doclength(), GlassVersion::get_last_docid(), GlassTermList::get_termname(), Xapian::TermIterator::get_wdf(), GlassTermList::get_wdf(), Xapian::Document::internal, inverter, GlassTable::is_open(), LOGCALL_VOID, LOGLINE, MAX_SAFE_TERM_LENGTH, modify_shortcut_docid, modify_shortcut_document, GlassTermList::next(), GlassDatabase::position_table, GlassDatabase::postlist_table, Inverter::remove_posting(), GlassValueManager::replace_document(), GlassDocDataTable::replace_document_data(), Inverter::set_doclength(), GlassVersion::set_last_docid(), Inverter::set_positionlist(), GlassTermListTable::set_termlist(), STRINGIZE, Xapian::Document::termlist_begin(), Xapian::Document::termlist_end(), GlassDatabase::termlist_table, GlassDatabase::throw_termlist_table_close_exception(), Inverter::update_posting(), GlassDatabase::value_manager, value_stats, and GlassDatabase::version_file.
|
virtual |
Virtual methods of Database::Internal.
Reimplemented from Xapian::Database::Internal.
Definition at line 1642 of file glass_database.cc.
References GlassTable::add(), GlassTable::del(), LOGCALL_VOID, and GlassDatabase::postlist_table.
|
virtual |
Virtual methods of Database::Internal.
Reimplemented from GlassDatabase.
Definition at line 1471 of file glass_database.cc.
References get_freqs(), LOGCALL, and RETURN.
|
mutableprivate |
The number of documents added, deleted, or replaced since the last flush.
Definition at line 340 of file glass_database.h.
Referenced by cancel(), check_flush_threshold(), commit(), flush_postlist_changes(), has_uncommitted_changes(), open_allterms(), and open_value_list().
|
private |
If change_count reaches this threshold we automatically flush.
Definition at line 343 of file glass_database.h.
Referenced by check_flush_threshold(), and GlassWritableDatabase().
|
mutableprivate |
Definition at line 333 of file glass_database.h.
Referenced by add_document_(), cancel(), delete_document(), flush_postlist_changes(), get_doclength(), get_freqs(), get_unique_terms(), has_positions(), open_allterms(), open_position_list(), open_post_list(), positionlist_count(), read_position_list(), and replace_document().
|
mutableprivate |
The document ID for the last document returned by open_document().
Definition at line 355 of file glass_database.h.
Referenced by delete_document(), invalidate_doc_object(), open_document(), and replace_document().
|
mutableprivate |
A pointer to the last document which was returned by open_document(), or NULL if there is no such valid document.
This is used purely for comparing with a supplied document to help with optimising replace_document. When the document internals are deleted, this pointer gets set to NULL.
Definition at line 351 of file glass_database.h.
Referenced by delete_document(), invalidate_doc_object(), open_document(), and replace_document().
|
mutableprivate |
Definition at line 335 of file glass_database.h.
Referenced by add_document_(), apply(), cancel(), delete_document(), get_value_freq(), get_value_lower_bound(), get_value_upper_bound(), and replace_document().