BrassWritableDatabase Class Reference

A writable brass database. More...

#include <brass_database.h>

Inheritance diagram for BrassWritableDatabase:

Inheritance graph
[legend]
Collaboration diagram for BrassWritableDatabase:

Collaboration graph
[legend]

List of all members.

Public Member Functions

 BrassWritableDatabase (const string &dir, int action, int block_size)
 Create and open a writable brass database.
 ~BrassWritableDatabase ()
Xapian::termcount get_doclength (Xapian::docid did) const
 Virtual methods of Database::Internal.
Xapian::doccount get_termfreq (const string &tname) const
 Virtual methods of Database::Internal.
Xapian::termcount get_collection_freq (const string &tname) const
 Virtual methods of Database::Internal.
Xapian::doccount get_value_freq (Xapian::valueno slot) const
 Virtual methods of Database::Internal.
std::string get_value_lower_bound (Xapian::valueno slot) const
 Virtual methods of Database::Internal.
std::string get_value_upper_bound (Xapian::valueno slot) const
 Virtual methods of Database::Internal.
bool term_exists (const string &tname) const
 Virtual methods of Database::Internal.
LeafPostListopen_post_list (const string &tname) const
 Virtual methods of Database::Internal.
ValueListopen_value_list (Xapian::valueno slot) const
 Virtual methods of Database::Internal.
TermListopen_allterms (const string &prefix) const
 Virtual methods of Database::Internal.
void add_spelling (const string &word, Xapian::termcount freqinc) const
 Virtual methods of Database::Internal.
void remove_spelling (const string &word, Xapian::termcount freqdec) const
 Virtual methods of Database::Internal.
TermListopen_spelling_wordlist () const
 Virtual methods of Database::Internal.
TermListopen_synonym_keylist (const string &prefix) const
 Virtual methods of Database::Internal.
void add_synonym (const string &word, const string &synonym) const
 Virtual methods of Database::Internal.
void remove_synonym (const string &word, const string &synonym) const
 Virtual methods of Database::Internal.
void clear_synonyms (const string &word) const
 Virtual methods of Database::Internal.
void set_metadata (const string &key, const string &value)
 Virtual methods of Database::Internal.
void invalidate_doc_object (Xapian::Document::Internal *obj) const
 Virtual methods of Database::Internal.

Private Member Functions

void flush_postlist_changes () const
 Flush any unflushed postlist changes, but don't commit them.
void close ()
 Close all the tables permanently.
void apply ()
 Apply changes.
void commit ()
 Implementation of virtual methods: see Database::Internal for details.
void cancel ()
 Cancel pending modifications to the database.
Xapian::docid add_document (const Xapian::Document &document)
 Implementation of virtual methods: see Database::Internal for details.
Xapian::docid add_document_ (Xapian::docid did, const Xapian::Document &document)
 Implementation of virtual methods: see Database::Internal for details.
void delete_document (Xapian::docid did)
 Implementation of virtual methods: see Database::Internal for details.
void replace_document (Xapian::docid did, const Xapian::Document &document)
 Implementation of virtual methods: see Database::Internal for details.
Xapian::Document::Internalopen_document (Xapian::docid did, bool lazy) const
 Implementation of virtual methods: see Database::Internal for details.

Private Attributes

Inverter inverter
map< Xapian::valueno, ValueStatsvalue_stats
Xapian::doccount change_count
 The number of documents added, deleted, or replaced since the last flush.
Xapian::doccount flush_threshold
 If change_count reaches this threshold we automatically flush.
Xapian::Document::Internalmodify_shortcut_document
 A pointer to the last document which was returned by open_document(), or NULL if there is no such valid document.
Xapian::docid modify_shortcut_docid
 The document ID for the last document returned by open_document().


Detailed Description

A writable brass database.

Definition at line 300 of file brass_database.h.


Constructor & Destructor Documentation

BrassWritableDatabase::BrassWritableDatabase ( const string &  dir,
int  action,
int  block_size 
)

Create and open a writable brass database.

Exceptions:
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.
Parameters:
dir directory holding brass tables

Definition at line 1044 of file brass_database.cc.

References flush_threshold, and LOGCALL_CTOR.

BrassWritableDatabase::~BrassWritableDatabase (  ) 

Definition at line 1061 of file brass_database.cc.

References Xapian::Database::Internal::dtor_called(), and LOGCALL_DTOR.


Member Function Documentation

Xapian::docid BrassWritableDatabase::add_document ( const Xapian::Document document  )  [private, virtual]

Implementation of virtual methods: see Database::Internal for details.

Reimplemented from Xapian::Database::Internal.

Definition at line 1104 of file brass_database.cc.

References add_document_(), BrassDatabaseStats::get_last_docid(), BrassDatabaseStats::get_next_docid(), LOGCALL, RETURN, and BrassDatabase::stats.

Xapian::docid BrassWritableDatabase::add_document_ ( Xapian::docid  did,
const Xapian::Document document 
) [private]

void BrassWritableDatabase::add_spelling ( const string &  word,
Xapian::termcount  freqinc 
) const [virtual]

Virtual methods of Database::Internal.

Reimplemented from Xapian::Database::Internal.

Definition at line 1549 of file brass_database.cc.

References BrassSpellingTable::add_word(), and BrassDatabase::spelling_table.

void BrassWritableDatabase::add_synonym ( const string &  word,
const string &  synonym 
) const [virtual]

Virtual methods of Database::Internal.

Reimplemented from Xapian::Database::Internal.

Definition at line 1577 of file brass_database.cc.

References BrassSynonymTable::add_synonym(), and BrassDatabase::synonym_table.

void BrassWritableDatabase::apply (  )  [private]

Apply changes.

Reimplemented from BrassDatabase.

Definition at line 1097 of file brass_database.cc.

References BrassValueManager::set_value_stats(), BrassDatabase::value_manager, and value_stats.

Referenced by add_document_(), commit(), delete_document(), and replace_document().

void BrassWritableDatabase::cancel (  )  [private, virtual]

Cancel pending modifications to the database.

Reimplemented from BrassDatabase.

Definition at line 1538 of file brass_database.cc.

References change_count, Inverter::clear(), inverter, BrassDatabase::postlist_table, BrassDatabaseStats::read(), BrassDatabase::stats, and value_stats.

Referenced by add_document_(), delete_document(), and replace_document().

void BrassWritableDatabase::clear_synonyms ( const string &  word  )  const [virtual]

Virtual methods of Database::Internal.

Reimplemented from Xapian::Database::Internal.

Definition at line 1591 of file brass_database.cc.

References BrassSynonymTable::clear_synonyms(), and BrassDatabase::synonym_table.

void BrassWritableDatabase::close (  )  [private, virtual]

Close all the tables permanently.

Reimplemented from BrassDatabase.

Definition at line 1086 of file brass_database.cc.

References commit(), LOGCALL_VOID, and Xapian::Database::Internal::transaction_active().

void BrassWritableDatabase::commit (  )  [private, virtual]

Implementation of virtual methods: see Database::Internal for details.

Reimplemented from Xapian::Database::Internal.

Definition at line 1068 of file brass_database.cc.

References apply(), change_count, flush_postlist_changes(), and Xapian::Database::Internal::transaction_active().

Referenced by close().

void BrassWritableDatabase::delete_document ( Xapian::docid  did  )  [private, virtual]

void BrassWritableDatabase::flush_postlist_changes (  )  const [private]

Flush any unflushed postlist changes, but don't commit them.

Definition at line 1077 of file brass_database.cc.

References change_count, Inverter::flush(), inverter, BrassDatabase::postlist_table, BrassDatabase::stats, and BrassDatabaseStats::write().

Referenced by add_document_(), commit(), delete_document(), and replace_document().

Xapian::termcount BrassWritableDatabase::get_collection_freq ( const string &  tname  )  const [virtual]

Virtual methods of Database::Internal.

Reimplemented from BrassDatabase.

Definition at line 1443 of file brass_database.cc.

References Inverter::get_cfdelta(), BrassDatabase::get_collection_freq(), inverter, LOGCALL, and RETURN.

Xapian::termcount BrassWritableDatabase::get_doclength ( Xapian::docid  did  )  const [virtual]

Virtual methods of Database::Internal.

Reimplemented from BrassDatabase.

Definition at line 1426 of file brass_database.cc.

References BrassDatabase::get_doclength(), Inverter::get_doclength(), inverter, LOGCALL, and RETURN.

Xapian::doccount BrassWritableDatabase::get_termfreq ( const string &  tname  )  const [virtual]

Virtual methods of Database::Internal.

Reimplemented from BrassDatabase.

Definition at line 1436 of file brass_database.cc.

References BrassDatabase::get_termfreq(), Inverter::get_tfdelta(), inverter, LOGCALL, and RETURN.

Referenced by term_exists().

Xapian::doccount BrassWritableDatabase::get_value_freq ( Xapian::valueno  slot  )  const [virtual]

Virtual methods of Database::Internal.

Reimplemented from BrassDatabase.

Definition at line 1450 of file brass_database.cc.

References BrassDatabase::get_value_freq(), LOGCALL, RETURN, and value_stats.

std::string BrassWritableDatabase::get_value_lower_bound ( Xapian::valueno  slot  )  const [virtual]

Virtual methods of Database::Internal.

Reimplemented from BrassDatabase.

Definition at line 1460 of file brass_database.cc.

References BrassDatabase::get_value_lower_bound(), LOGCALL, RETURN, and value_stats.

std::string BrassWritableDatabase::get_value_upper_bound ( Xapian::valueno  slot  )  const [virtual]

Virtual methods of Database::Internal.

Reimplemented from BrassDatabase.

Definition at line 1470 of file brass_database.cc.

References BrassDatabase::get_value_upper_bound(), LOGCALL, RETURN, and value_stats.

void BrassWritableDatabase::invalidate_doc_object ( Xapian::Document::Internal obj  )  const [virtual]

Virtual methods of Database::Internal.

Reimplemented from Xapian::Database::Internal.

Definition at line 1610 of file brass_database.cc.

References modify_shortcut_docid, and modify_shortcut_document.

TermList * BrassWritableDatabase::open_allterms ( const string &  prefix  )  const [virtual]

Virtual methods of Database::Internal.

Reimplemented from BrassDatabase.

Definition at line 1519 of file brass_database.cc.

References change_count, Inverter::flush_post_lists(), inverter, LOGCALL, BrassDatabase::open_allterms(), BrassDatabase::postlist_table, and RETURN.

Xapian::Document::Internal * BrassWritableDatabase::open_document ( Xapian::docid  did,
bool  lazy 
) const [private, virtual]

Implementation of virtual methods: see Database::Internal for details.

Reimplemented from BrassDatabase.

Definition at line 1415 of file brass_database.cc.

References LOGCALL, modify_shortcut_docid, modify_shortcut_document, and RETURN.

LeafPostList * BrassWritableDatabase::open_post_list ( const string &  tname  )  const [virtual]

TermList * BrassWritableDatabase::open_spelling_wordlist (  )  const [virtual]

Virtual methods of Database::Internal.

Reimplemented from BrassDatabase.

Definition at line 1563 of file brass_database.cc.

References BrassSpellingTable::merge_changes(), and BrassDatabase::spelling_table.

TermList * BrassWritableDatabase::open_synonym_keylist ( const string &  prefix  )  const [virtual]

Virtual methods of Database::Internal.

Reimplemented from BrassDatabase.

Definition at line 1570 of file brass_database.cc.

References BrassSynonymTable::merge_changes(), and BrassDatabase::synonym_table.

ValueList * BrassWritableDatabase::open_value_list ( Xapian::valueno  slot  )  const [virtual]

Virtual methods of Database::Internal.

Reimplemented from BrassDatabase.

Definition at line 1508 of file brass_database.cc.

References change_count, LOGCALL, BrassValueManager::merge_changes(), BrassDatabase::open_value_list(), RETURN, and BrassDatabase::value_manager.

void BrassWritableDatabase::remove_spelling ( const string &  word,
Xapian::termcount  freqdec 
) const [virtual]

Virtual methods of Database::Internal.

Reimplemented from Xapian::Database::Internal.

Definition at line 1556 of file brass_database.cc.

References BrassSpellingTable::remove_word(), and BrassDatabase::spelling_table.

void BrassWritableDatabase::remove_synonym ( const string &  word,
const string &  synonym 
) const [virtual]

Virtual methods of Database::Internal.

Reimplemented from Xapian::Database::Internal.

Definition at line 1584 of file brass_database.cc.

References BrassSynonymTable::remove_synonym(), and BrassDatabase::synonym_table.

void BrassWritableDatabase::replace_document ( Xapian::docid  did,
const Xapian::Document document 
) [private, virtual]

Implementation of virtual methods: see Database::Internal for details.

Reimplemented from Xapian::Database::Internal.

Definition at line 1243 of file brass_database.cc.

References BrassDatabaseStats::add_document(), add_document_(), Inverter::add_posting(), apply(), Assert, BrassTermList::at_end(), cancel(), change_count, BrassDatabaseStats::check_wdf(), BrassDatabaseStats::delete_document(), BrassPositionListTable::delete_positionlist(), BrassPostListTable::document_exists(), flush_postlist_changes(), flush_threshold, Xapian::Internal::RefCntPtr< T >::get(), Xapian::Document::get_data(), BrassTermList::get_doclength(), BrassDatabaseStats::get_last_docid(), BrassTermList::get_termname(), Xapian::TermIterator::get_wdf(), BrassTermList::get_wdf(), Xapian::Document::internal, inverter, BrassTable::is_open(), LOGCALL_VOID, LOGLINE, MAX_SAFE_TERM_LENGTH, modify_shortcut_docid, modify_shortcut_document, BrassTermList::next(), BrassDatabase::position_table, Xapian::TermIterator::positionlist_begin(), Xapian::TermIterator::positionlist_end(), BrassDatabase::postlist_table, BrassDatabase::record_table, Inverter::remove_posting(), BrassValueManager::replace_document(), BrassRecordTable::replace_record(), Inverter::set_doclength(), BrassDatabaseStats::set_last_docid(), BrassPositionListTable::set_positionlist(), BrassTermListTable::set_termlist(), BrassDatabase::stats, STRINGIZE, Xapian::Document::termlist_begin(), Xapian::Document::termlist_end(), BrassDatabase::termlist_table, Xapian::Database::Internal::transaction_active(), Inverter::update_posting(), BrassDatabase::value_manager, and value_stats.

void BrassWritableDatabase::set_metadata ( const string &  key,
const string &  value 
) [virtual]

Virtual methods of Database::Internal.

Reimplemented from Xapian::Database::Internal.

Definition at line 1597 of file brass_database.cc.

References BrassTable::add(), BrassTable::del(), LOGCALL, and BrassDatabase::postlist_table.

bool BrassWritableDatabase::term_exists ( const string &  tname  )  const [virtual]

Virtual methods of Database::Internal.

Reimplemented from BrassDatabase.

Definition at line 1480 of file brass_database.cc.

References get_termfreq(), LOGCALL, and RETURN.


Member Data Documentation

The number of documents added, deleted, or replaced since the last flush.

Definition at line 308 of file brass_database.h.

Referenced by add_document_(), cancel(), commit(), delete_document(), flush_postlist_changes(), open_allterms(), open_value_list(), and replace_document().

If change_count reaches this threshold we automatically flush.

Definition at line 311 of file brass_database.h.

Referenced by add_document_(), BrassWritableDatabase(), delete_document(), and replace_document().

The document ID for the last document returned by open_document().

Definition at line 323 of file brass_database.h.

Referenced by delete_document(), invalidate_doc_object(), open_document(), and replace_document().

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 319 of file brass_database.h.

Referenced by delete_document(), invalidate_doc_object(), open_document(), and replace_document().


The documentation for this class was generated from the following files:

Documentation for Xapian (version 1.2.13).
Generated on 9 Jan 2013 by Doxygen 1.5.9.