#include <inmemory_database.h>
Inheritance diagram for InMemoryDatabase:


Public Member Functions | |
| InMemoryDatabase () | |
| Create and open an in-memory database. | |
| ~InMemoryDatabase () | |
| Xapian::doccount | get_doccount () const |
| Return the number of docs in this (sub) database. | |
| Xapian::docid | get_lastdocid () const |
| Return the last used document id of this (sub) database. | |
| Xapian::doclength | get_avlength () const |
| Return the average length of a document in this (sub) database. | |
| Xapian::doclength | get_doclength (Xapian::docid did) const |
| Get the length of a given document. | |
| Xapian::doccount | get_termfreq (const string &tname) const |
| Return the number of documents indexed by a given term. | |
| Xapian::termcount | get_collection_freq (const string &tname) const |
| Return the total number of occurrences of the given term. | |
| bool | term_exists (const string &tname) const |
| Check whether a given term is in the database. | |
| bool | has_positions () const |
| Check whether this database contains any positional information. | |
| LeafPostList * | open_post_list (const string &tname) const |
| Open a posting list. | |
| TermList * | open_term_list (Xapian::docid did) const |
| Open a term list. | |
| Xapian::Document::Internal * | open_document (Xapian::docid did, bool lazy=false) const |
| Open a document. | |
| std::string | get_metadata (const std::string &key) const |
| void | set_metadata (const std::string &key, const std::string &value) |
| Xapian::termcount | positionlist_count (Xapian::docid did, const string &tname) const |
| PositionList * | open_position_list (Xapian::docid did, const string &tname) const |
| Open a position list for the given term in the given document. | |
| TermList * | open_allterms (const string &prefix) const |
| Open an allterms list. | |
Private Member Functions | |
| InMemoryDatabase & | operator= (const InMemoryDatabase &) |
| InMemoryDatabase (const InMemoryDatabase &) | |
| void | make_term (const string &tname) |
| bool | doc_exists (Xapian::docid did) const |
| Xapian::docid | make_doc (const string &docdata) |
| void | finish_add_doc (Xapian::docid did, const Xapian::Document &document) |
| void | add_values (Xapian::docid did, const map< Xapian::valueno, string > &values_) |
| void | make_posting (InMemoryDoc *doc, const string &tname, Xapian::docid did, Xapian::termpos position, Xapian::termcount wdf, bool use_position=true) |
| void | flush () |
| Implementation of virtual methods: see Database for details. | |
| void | cancel () |
| Cancel pending modifications to the database. | |
| Xapian::docid | add_document (const Xapian::Document &document) |
| Add a new document to the database. | |
| void | delete_document (Xapian::docid did) |
| Delete a document in the database. | |
| void | replace_document (Xapian::docid did, const Xapian::Document &document) |
| Replace a given document in the database. | |
Private Attributes | |
| map< string, InMemoryTerm > | postlists |
| vector< InMemoryDoc > | termlists |
| vector< std::string > | doclists |
| vector< std::map< Xapian::valueno, string > > | valuelists |
| vector< Xapian::doclength > | doclengths |
| std::map< string, string > | metadata |
| Xapian::doccount | totdocs |
| Xapian::doclength | totlen |
| bool | positions_present |
Friends | |
| class | InMemoryAllDocsPostList |
This is a prototype database, mainly used for debugging and testing.
Definition at line 231 of file inmemory_database.h.
| InMemoryDatabase::InMemoryDatabase | ( | const InMemoryDatabase & | ) | [private] |
| InMemoryDatabase::InMemoryDatabase | ( | ) |
Create and open an in-memory database.
| Xapian::DatabaseOpeningError | thrown if database can't be opened. |
Definition at line 352 of file inmemory_database.cc.
References Xapian::Database::Internal::transaction_state, and Xapian::Database::Internal::TRANSACTION_UNIMPLEMENTED.
| InMemoryDatabase::~InMemoryDatabase | ( | ) |
Definition at line 359 of file inmemory_database.cc.
References Xapian::Database::Internal::dtor_called().
| InMemoryDatabase& InMemoryDatabase::operator= | ( | const InMemoryDatabase & | ) | [private] |
| void InMemoryDatabase::make_term | ( | const string & | tname | ) | [private] |
Definition at line 683 of file inmemory_database.cc.
References postlists.
Referenced by finish_add_doc().
| bool InMemoryDatabase::doc_exists | ( | Xapian::docid | did | ) | const [private] |
Definition at line 384 of file inmemory_database.cc.
References termlists.
Referenced by delete_document(), get_doclength(), make_posting(), open_document(), open_position_list(), open_term_list(), positionlist_count(), and replace_document().
| Xapian::docid InMemoryDatabase::make_doc | ( | const string & | docdata | ) | [private] |
Definition at line 689 of file inmemory_database.cc.
References AssertEqParanoid, doclengths, doclists, and termlists.
Referenced by add_document().
| void InMemoryDatabase::finish_add_doc | ( | Xapian::docid | did, | |
| const Xapian::Document & | document | |||
| ) | [private] |
Definition at line 636 of file inmemory_database.cc.
References add_values(), Assert, DEBUGLINE, doclengths, Xapian::ValueIterator::get_valueno(), Xapian::TermIterator::get_wdf(), make_posting(), make_term(), Xapian::TermIterator::positionlist_begin(), Xapian::TermIterator::positionlist_end(), positions_present, postlists, Xapian::Document::termlist_begin(), Xapian::Document::termlist_end(), termlists, totdocs, totlen, Xapian::Document::values_begin(), and Xapian::Document::values_end().
Referenced by add_document(), and replace_document().
| void InMemoryDatabase::add_values | ( | Xapian::docid | did, | |
| const map< Xapian::valueno, string > & | values_ | |||
| ) | [private] |
Definition at line 519 of file inmemory_database.cc.
References valuelists.
Referenced by finish_add_doc().
| void InMemoryDatabase::make_posting | ( | InMemoryDoc * | doc, | |
| const string & | tname, | |||
| Xapian::docid | did, | |||
| Xapian::termpos | position, | |||
| Xapian::termcount | wdf, | |||
| bool | use_position = true | |||
| ) | [private] |
Definition at line 700 of file inmemory_database.cc.
References InMemoryDoc::add_posting(), Assert, InMemoryPosting::did, doc_exists(), doclengths, InMemoryTermEntry::positions, InMemoryPosting::positions, postlists, termlists, InMemoryTermEntry::tname, InMemoryPosting::valid, InMemoryTermEntry::wdf, and InMemoryPosting::wdf.
Referenced by finish_add_doc().
| void InMemoryDatabase::flush | ( | ) | [private, virtual] |
Implementation of virtual methods: see Database for details.
Reimplemented from Xapian::Database::Internal.
Definition at line 530 of file inmemory_database.cc.
| void InMemoryDatabase::cancel | ( | ) | [private, virtual] |
Cancel pending modifications to the database.
Reimplemented from Xapian::Database::Internal.
Definition at line 536 of file inmemory_database.cc.
| Xapian::docid InMemoryDatabase::add_document | ( | const Xapian::Document & | document | ) | [private, virtual] |
Add a new document to the database.
See WritableDatabase::add_document() for more information.
Reimplemented from Xapian::Database::Internal.
Definition at line 624 of file inmemory_database.cc.
References DEBUGLINE, finish_add_doc(), Xapian::Document::get_data(), and make_doc().
| void InMemoryDatabase::delete_document | ( | Xapian::docid | did | ) | [private, virtual] |
Delete a document in the database.
See WritableDatabase::delete_document() for more information.
Reimplemented from Xapian::Database::Internal.
Definition at line 541 of file inmemory_database.cc.
References Assert, doc_exists(), doclengths, doclists, om_tostring(), positions_present, postlists, termlists, totdocs, totlen, and valuelists.
| void InMemoryDatabase::replace_document | ( | Xapian::docid | did, | |
| const Xapian::Document & | document | |||
| ) | [private, virtual] |
Replace a given document in the database.
See WritableDatabase::replace_document() for more information.
Reimplemented from Xapian::Database::Internal.
Definition at line 578 of file inmemory_database.cc.
References Assert, DEBUGLINE, doc_exists(), doclengths, doclists, finish_add_doc(), Xapian::Document::get_data(), postlists, termlists, totdocs, totlen, and valuelists.
| Xapian::doccount InMemoryDatabase::get_doccount | ( | ) | const [virtual] |
Return the number of docs in this (sub) database.
Implements Xapian::Database::Internal.
Definition at line 406 of file inmemory_database.cc.
References totdocs.
| Xapian::docid InMemoryDatabase::get_lastdocid | ( | ) | const [virtual] |
Return the last used document id of this (sub) database.
Implements Xapian::Database::Internal.
Definition at line 412 of file inmemory_database.cc.
References termlists.
| Xapian::doclength InMemoryDatabase::get_avlength | ( | ) | const [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.
Implements Xapian::Database::Internal.
Definition at line 418 of file inmemory_database.cc.
| Xapian::doclength InMemoryDatabase::get_doclength | ( | Xapian::docid | did | ) | const [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. |
Implements Xapian::Database::Internal.
Definition at line 425 of file inmemory_database.cc.
References doc_exists(), doclengths, and om_tostring().
Referenced by open_term_list().
| Xapian::doccount InMemoryDatabase::get_termfreq | ( | const string & | tname | ) | const [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. |
Implements Xapian::Database::Internal.
Definition at line 390 of file inmemory_database.cc.
References postlists.
| Xapian::termcount InMemoryDatabase::get_collection_freq | ( | const string & | tname | ) | const [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. |
Implements Xapian::Database::Internal.
Definition at line 398 of file inmemory_database.cc.
References postlists.
| bool InMemoryDatabase::term_exists | ( | const string & | tname | ) | const [virtual] |
Check whether a given term is in the database.
| tname | The term whose presence is being checked. |
Implements Xapian::Database::Internal.
Definition at line 738 of file inmemory_database.cc.
| bool InMemoryDatabase::has_positions | ( | ) | const [virtual] |
Check whether this database contains any positional information.
Implements Xapian::Database::Internal.
Definition at line 747 of file inmemory_database.cc.
References positions_present.
| LeafPostList * InMemoryDatabase::open_post_list | ( | const string & | tname | ) | const [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. |
Implements Xapian::Database::Internal.
Definition at line 365 of file inmemory_database.cc.
References Assert, Xapian::PostingIterator::Internal::at_end(), InMemoryAllDocsPostList, postlists, and termlists.
| TermList * InMemoryDatabase::open_term_list | ( | Xapian::docid | did | ) | const [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. |
Implements Xapian::Database::Internal.
Definition at line 435 of file inmemory_database.cc.
References doc_exists(), get_doclength(), om_tostring(), and termlists.
| Xapian::Document::Internal * InMemoryDatabase::open_document | ( | Xapian::docid | did, | |
| bool | lazy = false | |||
| ) | const [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. |
Implements Xapian::Database::Internal.
Definition at line 448 of file inmemory_database.cc.
References doc_exists(), doclists, om_tostring(), and valuelists.
| std::string InMemoryDatabase::get_metadata | ( | const std::string & | key | ) | const |
| void InMemoryDatabase::set_metadata | ( | const std::string & | key, | |
| const std::string & | value | |||
| ) |
| Xapian::termcount InMemoryDatabase::positionlist_count | ( | Xapian::docid | did, | |
| const string & | tname | |||
| ) | const |
Definition at line 482 of file inmemory_database.cc.
References doc_exists(), termlists, and InMemoryDoc::terms.
| PositionList * InMemoryDatabase::open_position_list | ( | Xapian::docid | did, | |
| const string & | tname | |||
| ) | const [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. |
Implements Xapian::Database::Internal.
Definition at line 500 of file inmemory_database.cc.
References doc_exists(), om_tostring(), termlists, and InMemoryDoc::terms.
| TermList * InMemoryDatabase::open_allterms | ( | const string & | prefix | ) | const [virtual] |
Open an allterms list.
This is a list of all the terms in the database
| prefix | The prefix to restrict the terms to. |
Implements Xapian::Database::Internal.
Definition at line 753 of file inmemory_database.cc.
References postlists.
friend class InMemoryAllDocsPostList [friend] |
map<string, InMemoryTerm> InMemoryDatabase::postlists [private] |
Definition at line 234 of file inmemory_database.h.
Referenced by delete_document(), finish_add_doc(), get_collection_freq(), get_termfreq(), make_posting(), make_term(), open_allterms(), open_post_list(), replace_document(), and term_exists().
vector<InMemoryDoc> InMemoryDatabase::termlists [private] |
Definition at line 235 of file inmemory_database.h.
Referenced by delete_document(), doc_exists(), finish_add_doc(), get_lastdocid(), make_doc(), make_posting(), open_position_list(), open_post_list(), open_term_list(), positionlist_count(), and replace_document().
vector<std::string> InMemoryDatabase::doclists [private] |
Definition at line 236 of file inmemory_database.h.
Referenced by delete_document(), make_doc(), open_document(), and replace_document().
vector<std::map<Xapian::valueno, string> > InMemoryDatabase::valuelists [private] |
Definition at line 237 of file inmemory_database.h.
Referenced by add_values(), delete_document(), open_document(), and replace_document().
vector<Xapian::doclength> InMemoryDatabase::doclengths [private] |
Definition at line 239 of file inmemory_database.h.
Referenced by delete_document(), finish_add_doc(), get_doclength(), make_doc(), make_posting(), and replace_document().
std::map<string, string> InMemoryDatabase::metadata [private] |
Definition at line 241 of file inmemory_database.h.
Referenced by get_metadata(), and set_metadata().
Xapian::doccount InMemoryDatabase::totdocs [private] |
Definition at line 243 of file inmemory_database.h.
Referenced by delete_document(), finish_add_doc(), get_avlength(), get_doccount(), and replace_document().
Xapian::doclength InMemoryDatabase::totlen [private] |
Definition at line 245 of file inmemory_database.h.
Referenced by delete_document(), finish_add_doc(), get_avlength(), and replace_document().
bool InMemoryDatabase::positions_present [private] |
Definition at line 247 of file inmemory_database.h.
Referenced by delete_document(), finish_add_doc(), and has_positions().