#include <flint_spelling.h>
Inheritance diagram for FlintSpellingTable:
Public Member Functions | |
FlintSpellingTable (std::string dbdir, bool readonly) | |
Create a new FlintSpellingTable object. | |
void | merge_changes () |
void | add_word (const std::string &word, Xapian::termcount freqinc) |
void | remove_word (const std::string &word, Xapian::termcount freqdec) |
TermList * | open_termlist (const std::string &word) |
Xapian::doccount | get_word_frequency (const string &word) const |
bool | is_modified () const |
Override methods of FlintTable. | |
void | create_and_open (unsigned int blocksize) |
Create a new empty btree structure on disk and open it at the initial revision. | |
void | commit (flint_revision_number_t revision) |
Commit any outstanding changes to the table. | |
void | cancel () |
Cancel any outstanding changes. | |
Private Member Functions | |
void | add_fragment (fragment frag, const string &word) |
void | remove_fragment (fragment frag, const string &word) |
Private Attributes | |
std::map< std::string, Xapian::termcount > | wordfreq_changes |
std::map< fragment, std::set< std::string > > | termlist_deltas |
Definition at line 55 of file flint_spelling.h.
FlintSpellingTable::FlintSpellingTable | ( | std::string | dbdir, | |
bool | readonly | |||
) | [inline] |
Create a new FlintSpellingTable object.
This method does not create or open the table on disk - you must call the create() or open() methods respectively!
dbdir | The directory the flint database is stored in. | |
readonly | true if we're opening read-only, else false. |
Definition at line 71 of file flint_spelling.h.
void FlintSpellingTable::add_fragment | ( | fragment | frag, | |
const string & | word | |||
) | [private] |
void FlintSpellingTable::remove_fragment | ( | fragment | frag, | |
const string & | word | |||
) | [private] |
void FlintSpellingTable::merge_changes | ( | ) |
Definition at line 130 of file flint_spelling.cc.
References PrefixCompressedStringWriter::append(), Assert, PrefixCompressedStringItor::at_end(), current, FlintTable::del(), FlintTable::get_exact_entry(), if(), pack_uint_last(), termlist_deltas, and wordfreq_changes.
Referenced by commit(), and FlintWritableDatabase::open_spelling_wordlist().
void FlintSpellingTable::add_word | ( | const std::string & | word, | |
Xapian::termcount | freqinc | |||
) |
Referenced by FlintWritableDatabase::add_spelling().
void FlintSpellingTable::remove_word | ( | const std::string & | word, | |
Xapian::termcount | freqdec | |||
) |
Referenced by FlintWritableDatabase::remove_spelling().
TermList* FlintSpellingTable::open_termlist | ( | const std::string & | word | ) |
Referenced by FlintDatabase::open_spelling_termlist().
Xapian::doccount FlintSpellingTable::get_word_frequency | ( | const string & | word | ) | const |
Definition at line 474 of file flint_spelling.cc.
References FlintTable::get_exact_entry(), unpack_uint_last(), and wordfreq_changes.
Referenced by FlintDatabase::get_spelling_frequency().
bool FlintSpellingTable::is_modified | ( | ) | const [inline] |
Override methods of FlintTable.
NB: these aren't virtual, but we always call them on the subclass in cases where it matters).
Reimplemented from FlintTable.
Definition at line 91 of file flint_spelling.h.
References FlintTable::is_modified(), and wordfreq_changes.
Referenced by FlintDatabase::apply().
void FlintSpellingTable::create_and_open | ( | unsigned int | blocksize | ) | [inline] |
Create a new empty btree structure on disk and open it at the initial revision.
The table must be writable - it doesn't make sense to create a table that is read-only!
The block size must be less than 64K, where K = 1024. It is unwise to use a small block size (less than 1024 perhaps), so we enforce a minimum block size of 2K.
Example:
Btree btree("X-"); btree.create_and_open(8192); // Files will be X-DB, X-baseA (and X-baseB).
blocksize | - Size of blocks to use. |
Xapian::DatabaseCreateError | if the table can't be created. | |
Xapian::InvalidArgumentError | if the requested blocksize is unsuitable. |
Reimplemented from FlintTable.
Definition at line 95 of file flint_spelling.h.
References FlintTable::erase(), and FlintTable::set_block_size().
Referenced by FlintDatabase::create_and_open_tables().
void FlintSpellingTable::commit | ( | flint_revision_number_t | revision | ) | [inline] |
Commit any outstanding changes to the table.
Commit changes made by calling add() and del() to the Btree.
If an error occurs during the operation, this will be signalled by an exception. In case of error, changes made will not be committed to the Btree - they will be discarded.
new_revision | The new revision number to store. This must be greater than the latest revision number (see get_latest_revision_number()), or an exception will be thrown. |
Reimplemented from FlintTable.
Definition at line 102 of file flint_spelling.h.
References FlintTable::commit(), and merge_changes().
Referenced by FlintDatabase::set_revision_number().
void FlintSpellingTable::cancel | ( | ) | [inline] |
Cancel any outstanding changes.
This will discard any modifications which haven't been committed by calling commit().
Reimplemented from FlintTable.
Definition at line 107 of file flint_spelling.h.
References FlintTable::cancel(), termlist_deltas, and wordfreq_changes.
Referenced by FlintDatabase::cancel().
std::map<std::string, Xapian::termcount> FlintSpellingTable::wordfreq_changes [private] |
Definition at line 59 of file flint_spelling.h.
Referenced by cancel(), get_word_frequency(), is_modified(), and merge_changes().
std::map<fragment, std::set<std::string> > FlintSpellingTable::termlist_deltas [private] |
Definition at line 60 of file flint_spelling.h.
Referenced by add_fragment(), cancel(), merge_changes(), and remove_fragment().