#include <database.h>
Inheritance diagram for Xapian::Database::Internal:
Public Member Functions | |
virtual | ~Internal () |
Destroy the database. | |
virtual void | keep_alive () |
Send a keep-alive signal to a remote database, to stop it from timing out. | |
virtual Xapian::doccount | get_doccount () const=0 |
Return the number of docs in this (sub) database. | |
virtual Xapian::docid | get_lastdocid () const=0 |
Return the last used document id of this (sub) database. | |
virtual Xapian::doclength | get_avlength () const=0 |
Return the average length of a document in this (sub) database. | |
virtual Xapian::doclength | get_doclength (Xapian::docid did) const =0 |
Get the length of a given document. | |
virtual Xapian::doccount | get_termfreq (const string &tname) const=0 |
Return the number of documents indexed by a given term. | |
virtual Xapian::termcount | get_collection_freq (const string &tname) const=0 |
Return the total number of occurrences of the given term. | |
virtual bool | term_exists (const string &tname) const=0 |
Check whether a given term is in the database. | |
virtual bool | has_positions () const=0 |
Check whether this database contains any positional information. | |
virtual LeafPostList * | open_post_list (const string &tname) const=0 |
Open a posting list. | |
virtual TermList * | open_term_list (Xapian::docid did) const =0 |
Open a term list. | |
virtual TermList * | open_allterms (const string &prefix) const=0 |
Open an allterms list. | |
virtual PositionList * | open_position_list (Xapian::docid did, const string &tname) const=0 |
Open a position list for the given term in the given document. | |
virtual Xapian::Document::Internal * | open_document (Xapian::docid did, bool lazy=false) const=0 |
Open a document. | |
virtual TermList * | open_spelling_termlist (const string &word) const |
Create a termlist tree from trigrams of word. | |
virtual TermList * | open_spelling_wordlist () const |
Return a termlist which returns the words which are spelling correction targets. | |
virtual Xapian::doccount | get_spelling_frequency (const string &word) const |
Return the number of times word was added as a spelling. | |
virtual void | add_spelling (const string &word, Xapian::termcount freqinc) const |
Add a word to the spelling dictionary. | |
virtual void | remove_spelling (const string &word, Xapian::termcount freqdec) const |
Remove a word from the spelling dictionary. | |
virtual TermList * | open_synonym_termlist (const string &term) const |
Open a termlist returning synonyms for a term. | |
virtual TermList * | open_synonym_keylist (const string &prefix) const |
Open a termlist returning each term which has synonyms. | |
virtual void | add_synonym (const string &term, const string &synonym) const |
Add a synonym for a term. | |
virtual void | remove_synonym (const string &term, const string &synonym) const |
Remove a synonym for a term. | |
virtual void | clear_synonyms (const string &term) const |
Clear all synonyms for a term. | |
virtual string | get_metadata (const string &key) const |
Get the metadata associated with a given key. | |
virtual TermList * | open_metadata_keylist (const std::string &prefix) const |
Open a termlist returning each metadata key. | |
virtual void | set_metadata (const string &key, const string &value) |
Set the metadata associated with a given key. | |
virtual void | reopen () |
Reopen the database to the latest available revision. | |
virtual void | flush () |
Flush pending modifications to the database. | |
virtual void | cancel () |
Cancel pending modifications to the database. | |
void | begin_transaction (bool flushed) |
Begin a transaction. | |
void | commit_transaction () |
Commit a transaction. | |
void | cancel_transaction () |
Cancel a transaction. | |
virtual Xapian::docid | add_document (const Xapian::Document &document) |
Add a new document to the database. | |
virtual void | delete_document (Xapian::docid did) |
Delete a document in the database. | |
virtual void | delete_document (const string &unique_term) |
Delete any documents indexed by a term from the database. | |
virtual void | replace_document (Xapian::docid did, const Xapian::Document &document) |
Replace a given document in the database. | |
virtual Xapian::docid | replace_document (const string &unique_term, const Xapian::Document &document) |
Replace any documents matching a term. | |
virtual RemoteDatabase * | as_remotedatabase () |
Return a pointer to this object as a RemoteDatabase, or NULL. | |
virtual void | request_document (Xapian::docid) const |
Request and later collect a document from the database. | |
virtual Xapian::Document::Internal * | collect_document (Xapian::docid did) const |
Protected Types | |
enum | { TRANSACTION_UNIMPLEMENTED = -1, TRANSACTION_NONE = 0, TRANSACTION_UNFLUSHED = 1, TRANSACTION_FLUSHED = 2 } |
Transaction state. More... | |
Protected Member Functions | |
bool | transaction_active () const |
Internal () | |
Create a database - called only by derived classes. | |
void | dtor_called () |
Internal method to perform cleanup when a writable database is destroyed with unflushed changes. | |
Protected Attributes | |
enum Xapian::Database::Internal:: { ... } | transaction_state |
Transaction state. | |
Private Member Functions | |
Internal (const Internal &) | |
Copies are not allowed. | |
void | operator= (const Internal &) |
Assignment is not allowed. |
Definition at line 49 of file database.h.
anonymous enum [protected] |
Xapian::Database::Internal::Internal | ( | const Internal & | ) | [private] |
Copies are not allowed.
Xapian::Database::Internal::Internal | ( | ) | [protected] |
Xapian::Database::Internal::~Internal | ( | ) | [virtual] |
Destroy the database.
This method should not be called until all objects using the database have been cleaned up.
If any transactions are in progress, they should be finished by cancel_transaction() or commit_transaction() - if this is not done, the destructor will attempt to clean things up by cancelling the transaction, but any errors produced by these operations will not be reported.
Definition at line 228 of file database.cc.
void Xapian::Database::Internal::operator= | ( | const Internal & | ) | [private] |
Assignment is not allowed.
bool Xapian::Database::Internal::transaction_active | ( | ) | const [inline, protected] |
Definition at line 66 of file database.h.
References transaction_state.
Referenced by QuartzWritableDatabase::add_document_(), FlintWritableDatabase::add_document_(), cancel_transaction(), commit_transaction(), QuartzWritableDatabase::delete_document(), FlintWritableDatabase::delete_document(), dtor_called(), QuartzWritableDatabase::flush(), FlintWritableDatabase::flush(), QuartzWritableDatabase::open_allterms(), QuartzWritableDatabase::open_post_list(), QuartzWritableDatabase::replace_document(), and FlintWritableDatabase::replace_document().
void Xapian::Database::Internal::dtor_called | ( | ) | [protected] |
Internal method to perform cleanup when a writable database is destroyed with unflushed changes.
A derived class' destructor should call this method before destroying the database to ensure that no sessions or transactions are in progress at destruction time.
Note that it is not safe to throw exceptions from destructors, so this method will catch and discard any exceptions.
Definition at line 241 of file database.cc.
References cancel_transaction(), flush(), transaction_active(), TRANSACTION_NONE, and transaction_state.
Referenced by RemoteDatabase::do_close(), FlintWritableDatabase::~FlintWritableDatabase(), InMemoryDatabase::~InMemoryDatabase(), and QuartzWritableDatabase::~QuartzWritableDatabase().
void Xapian::Database::Internal::keep_alive | ( | ) | [virtual] |
Send a keep-alive signal to a remote database, to stop it from timing out.
Reimplemented in RemoteDatabase.
Definition at line 233 of file database.cc.
virtual Xapian::doccount Xapian::Database::Internal::get_doccount | ( | ) | const [pure virtual] |
Return the number of docs in this (sub) database.
Implemented in FlintDatabase, InMemoryDatabase, QuartzDatabase, QuartzWritableDatabase, and RemoteDatabase.
Referenced by ValueRangePostList::get_termfreq_est(), ValueRangePostList::get_termfreq_max(), and LocalSubMatch::prepare_match().
virtual Xapian::docid Xapian::Database::Internal::get_lastdocid | ( | ) | const [pure virtual] |
Return the last used document id of this (sub) database.
Implemented in FlintDatabase, InMemoryDatabase, QuartzDatabase, QuartzWritableDatabase, and RemoteDatabase.
Referenced by ValueRangePostList::check(), and ValueGePostList::check().
virtual Xapian::doclength Xapian::Database::Internal::get_avlength | ( | ) | const [pure virtual] |
Return the average length of a document in this (sub) database.
See Database::Internal::get_doclength() for the meaning of document length within Xapian.
Implemented in FlintDatabase, InMemoryDatabase, QuartzDatabase, QuartzWritableDatabase, and RemoteDatabase.
Referenced by LocalSubMatch::prepare_match().
virtual Xapian::doclength Xapian::Database::Internal::get_doclength | ( | Xapian::docid | did | ) | const [pure virtual] |
Get the length of a given document.
Document length, for the purposes of Xapian, is defined to be the number of instances of terms within a document. Expressed differently, the sum of the within document frequencies over all the terms in the document.
did | The document id of the document whose length is being requested. |
Implemented in FlintDatabase, FlintWritableDatabase, InMemoryDatabase, QuartzDatabase, QuartzWritableDatabase, and RemoteDatabase.
virtual Xapian::doccount Xapian::Database::Internal::get_termfreq | ( | const string & | tname | ) | const [pure virtual] |
Return the number of documents indexed by a given term.
This may be an approximation, but must be an upper bound (ie, greater or equal to the true value), and should be as accurate as possible.
tname | The term whose term frequency is being requested. |
Implemented in FlintDatabase, FlintWritableDatabase, InMemoryDatabase, QuartzDatabase, QuartzWritableDatabase, and RemoteDatabase.
Referenced by LocalSubMatch::prepare_match().
virtual Xapian::termcount Xapian::Database::Internal::get_collection_freq | ( | const string & | tname | ) | const [pure virtual] |
Return the total number of occurrences of the given term.
This is the sum of the number of ocurrences of the term in each document: ie, the sum of the within document frequencies of the term.
tname | The term whose collection frequency is being requested. |
Implemented in FlintDatabase, FlintWritableDatabase, InMemoryDatabase, QuartzDatabase, QuartzWritableDatabase, and RemoteDatabase.
virtual bool Xapian::Database::Internal::term_exists | ( | const string & | tname | ) | const [pure virtual] |
Check whether a given term is in the database.
tname | The term whose presence is being checked. |
Implemented in FlintDatabase, FlintWritableDatabase, InMemoryDatabase, QuartzDatabase, QuartzWritableDatabase, and RemoteDatabase.
virtual bool Xapian::Database::Internal::has_positions | ( | ) | const [pure virtual] |
Check whether this database contains any positional information.
Implemented in FlintDatabase, InMemoryDatabase, QuartzDatabase, QuartzWritableDatabase, and RemoteDatabase.
virtual LeafPostList* Xapian::Database::Internal::open_post_list | ( | const string & | tname | ) | const [pure virtual] |
Open a posting list.
Method defined by subclass to open a posting list. This is a list of all the documents which contain a given term.
tname | The term whose posting list is being requested. |
Implemented in FlintDatabase, FlintWritableDatabase, InMemoryDatabase, QuartzDatabase, QuartzWritableDatabase, and RemoteDatabase.
Referenced by ValueRangePostList::next(), ValueGePostList::next(), and LocalSubMatch::postlist_from_op_leaf_query().
virtual TermList* Xapian::Database::Internal::open_term_list | ( | Xapian::docid | did | ) | const [pure virtual] |
Open a term list.
This is a list of all the terms contained by a given document.
did | The document id whose term list is being requested. |
Implemented in FlintDatabase, InMemoryDatabase, QuartzDatabase, QuartzWritableDatabase, and RemoteDatabase.
Referenced by RSetI::calculate_stats().
virtual TermList* Xapian::Database::Internal::open_allterms | ( | const string & | prefix | ) | const [pure virtual] |
Open an allterms list.
This is a list of all the terms in the database
prefix | The prefix to restrict the terms to. |
Implemented in FlintDatabase, FlintWritableDatabase, InMemoryDatabase, QuartzDatabase, QuartzWritableDatabase, and RemoteDatabase.
virtual PositionList* Xapian::Database::Internal::open_position_list | ( | Xapian::docid | did, | |
const string & | tname | |||
) | const [pure virtual] |
Open a position list for the given term in the given document.
did | The document id for which a position list is being requested. | |
tname | The term for which a position list is being requested. |
Implemented in FlintDatabase, InMemoryDatabase, QuartzDatabase, QuartzWritableDatabase, and RemoteDatabase.
virtual Xapian::Document::Internal* Xapian::Database::Internal::open_document | ( | Xapian::docid | did, | |
bool | lazy = false | |||
) | const [pure virtual] |
Open a document.
This is used to access the values and data associated with a document. See class Xapian::Document::Internal for further details.
did | The document id which is being requested. | |
lazy | Don't check the document exists immediately - use from within the matcher where we know the document exists, and don't want to read the record when we just want the values. |
Implemented in FlintDatabase, InMemoryDatabase, QuartzDatabase, QuartzWritableDatabase, and RemoteDatabase.
Referenced by ValueRangePostList::check(), ValueGePostList::check(), collect_document(), ValueRangePostList::next(), and ValueGePostList::next().
TermList * Xapian::Database::Internal::open_spelling_termlist | ( | const string & | word | ) | const [virtual] |
Create a termlist tree from trigrams of word.
If there are no trigrams, returns NULL.
Reimplemented in FlintDatabase.
Definition at line 365 of file database.cc.
TermList * Xapian::Database::Internal::open_spelling_wordlist | ( | ) | const [virtual] |
Return a termlist which returns the words which are spelling correction targets.
If there are no spelling correction targets, returns NULL.
Reimplemented in FlintDatabase, and FlintWritableDatabase.
Definition at line 374 of file database.cc.
Xapian::doccount Xapian::Database::Internal::get_spelling_frequency | ( | const string & | word | ) | const [virtual] |
Return the number of times word was added as a spelling.
Reimplemented in FlintDatabase.
Definition at line 383 of file database.cc.
void Xapian::Database::Internal::add_spelling | ( | const string & | word, | |
Xapian::termcount | freqinc | |||
) | const [virtual] |
Add a word to the spelling dictionary.
If the word is already present, its frequency is increased.
word | The word to add. | |
freqinc | How much to increase its frequency by. |
Reimplemented in FlintWritableDatabase.
Definition at line 392 of file database.cc.
void Xapian::Database::Internal::remove_spelling | ( | const string & | word, | |
Xapian::termcount | freqdec | |||
) | const [virtual] |
Remove a word from the spelling dictionary.
The word's frequency is decreased, and if would become zero or less then the word is removed completely.
word | The word to remove. | |
freqdec | How much to decrease its frequency by. |
Reimplemented in FlintWritableDatabase.
Definition at line 398 of file database.cc.
TermList * Xapian::Database::Internal::open_synonym_termlist | ( | const string & | term | ) | const [virtual] |
Open a termlist returning synonyms for a term.
If term has no synonyms, returns NULL.
Reimplemented in FlintDatabase.
Definition at line 404 of file database.cc.
TermList * Xapian::Database::Internal::open_synonym_keylist | ( | const string & | prefix | ) | const [virtual] |
Open a termlist returning each term which has synonyms.
prefix | If non-empty, only terms with this prefix are returned. |
Reimplemented in FlintDatabase, and FlintWritableDatabase.
Definition at line 413 of file database.cc.
void Xapian::Database::Internal::add_synonym | ( | const string & | term, | |
const string & | synonym | |||
) | const [virtual] |
Add a synonym for a term.
If synonym is already a synonym for term, then no action is taken.
Reimplemented in FlintWritableDatabase.
Definition at line 422 of file database.cc.
void Xapian::Database::Internal::remove_synonym | ( | const string & | term, | |
const string & | synonym | |||
) | const [virtual] |
Remove a synonym for a term.
If synonym isn't a synonym for term, then no action is taken.
Reimplemented in FlintWritableDatabase.
Definition at line 428 of file database.cc.
void Xapian::Database::Internal::clear_synonyms | ( | const string & | term | ) | const [virtual] |
Clear all synonyms for a term.
If term has no synonyms, no action is taken.
Reimplemented in FlintWritableDatabase.
Definition at line 434 of file database.cc.
string Xapian::Database::Internal::get_metadata | ( | const string & | key | ) | const [virtual] |
Get the metadata associated with a given key.
See Database::get_metadata() for more information.
Reimplemented in FlintDatabase.
Definition at line 440 of file database.cc.
TermList * Xapian::Database::Internal::open_metadata_keylist | ( | const std::string & | prefix | ) | const [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 in FlintDatabase.
Definition at line 446 of file database.cc.
void Xapian::Database::Internal::set_metadata | ( | const string & | key, | |
const string & | value | |||
) | [virtual] |
Set the metadata associated with a given key.
See WritableDatabase::set_metadata() for more information.
Reimplemented in FlintWritableDatabase.
Definition at line 454 of file database.cc.
void Xapian::Database::Internal::reopen | ( | ) | [virtual] |
Reopen the database to the latest available revision.
Database backends which don't support simultaneous update and reading probably don't need to do anything here.
Reimplemented in FlintDatabase, QuartzDatabase, and RemoteDatabase.
Definition at line 460 of file database.cc.
void Xapian::Database::Internal::flush | ( | ) | [virtual] |
Flush pending modifications to the database.
See WritableDatabase::flush() for more information.
Reimplemented in FlintWritableDatabase, InMemoryDatabase, QuartzWritableDatabase, and RemoteDatabase.
Definition at line 256 of file database.cc.
References Assert.
Referenced by begin_transaction(), commit_transaction(), and dtor_called().
void Xapian::Database::Internal::cancel | ( | ) | [virtual] |
Cancel pending modifications to the database.
Reimplemented in FlintDatabase, FlintWritableDatabase, InMemoryDatabase, QuartzDatabase, QuartzWritableDatabase, and RemoteDatabase.
Definition at line 263 of file database.cc.
References Assert.
Referenced by cancel_transaction().
void Xapian::Database::Internal::begin_transaction | ( | bool | flushed | ) |
Begin a transaction.
See WritableDatabase::begin_transaction() for more information.
Definition at line 270 of file database.cc.
References flush(), TRANSACTION_FLUSHED, TRANSACTION_NONE, transaction_state, TRANSACTION_UNFLUSHED, and TRANSACTION_UNIMPLEMENTED.
void Xapian::Database::Internal::commit_transaction | ( | ) |
Commit a transaction.
See WritableDatabase::commit_transaction() for more information.
Definition at line 288 of file database.cc.
References flush(), transaction_active(), TRANSACTION_FLUSHED, TRANSACTION_NONE, transaction_state, and TRANSACTION_UNIMPLEMENTED.
void Xapian::Database::Internal::cancel_transaction | ( | ) |
Cancel a transaction.
See WritableDatabase::cancel_transaction() for more information.
Definition at line 303 of file database.cc.
References cancel(), transaction_active(), TRANSACTION_NONE, transaction_state, and TRANSACTION_UNIMPLEMENTED.
Referenced by dtor_called().
Xapian::docid Xapian::Database::Internal::add_document | ( | const Xapian::Document & | document | ) | [virtual] |
Add a new document to the database.
See WritableDatabase::add_document() for more information.
Reimplemented in FlintWritableDatabase, InMemoryDatabase, QuartzWritableDatabase, and RemoteDatabase.
Definition at line 315 of file database.cc.
References Assert.
void Xapian::Database::Internal::delete_document | ( | Xapian::docid | did | ) | [virtual] |
Delete a document in the database.
See WritableDatabase::delete_document() for more information.
Reimplemented in FlintWritableDatabase, InMemoryDatabase, QuartzWritableDatabase, and RemoteDatabase.
Definition at line 323 of file database.cc.
References Assert.
virtual void Xapian::Database::Internal::delete_document | ( | const string & | unique_term | ) | [virtual] |
Delete any documents indexed by a term from the database.
See WritableDatabase::delete_document() for more information.
void Xapian::Database::Internal::replace_document | ( | Xapian::docid | did, | |
const Xapian::Document & | document | |||
) | [virtual] |
Replace a given document in the database.
See WritableDatabase::replace_document() for more information.
Reimplemented in FlintWritableDatabase, InMemoryDatabase, QuartzWritableDatabase, and RemoteDatabase.
Definition at line 340 of file database.cc.
References Assert.
virtual Xapian::docid Xapian::Database::Internal::replace_document | ( | const string & | unique_term, | |
const Xapian::Document & | document | |||
) | [virtual] |
Replace any documents matching a term.
See WritableDatabase::replace_document() for more information.
void Xapian::Database::Internal::request_document | ( | Xapian::docid | ) | const [virtual] |
Request and later collect a document from the database.
Multiple documents can be requested with request_document(), and then collected with collect_document(). Allows the backend to optimise (e.g. the remote backend can start requests for all the documents so they fetch in parallel).
If a backend doesn't support this, request_document() can be a no-op and collect_document() the same as open_document().
Definition at line 467 of file database.cc.
Xapian::Document::Internal * Xapian::Database::Internal::collect_document | ( | Xapian::docid | did | ) | const [virtual] |
RemoteDatabase * Xapian::Database::Internal::as_remotedatabase | ( | ) | [virtual] |
Return a pointer to this object as a RemoteDatabase, or NULL.
This method is used by MultiMatch to decide whether to use a LocalSubMatch or a RemoteSubMatch to perform a search over the database.
Reimplemented in RemoteDatabase.
Definition at line 478 of file database.cc.
enum { ... } Xapian::Database::Internal::transaction_state [protected] |