FlintSynonymTable Class Reference

#include <flint_synonym.h>

Inheritance diagram for FlintSynonymTable:

Inheritance graph
[legend]
Collaboration diagram for FlintSynonymTable:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 FlintSynonymTable (std::string dbdir, bool readonly)
 Create a new FlintSynonymTable object.
void merge_changes ()
void discard_changes ()
void add_synonym (const std::string &term, const std::string &synonym)
 Add a synonym for term.
void remove_synonym (const std::string &term, const std::string &synonym)
 Remove a synonym for term.
void clear_synonyms (const std::string &term)
 Remove all synonyms for term.
TermListopen_termlist (const std::string &term)
 Open synonym termlist for a term.
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 Attributes

std::string last_term
 The last term which was updated.
std::set< std::string > last_synonyms
 The synonyms for the last term which was updated.

Detailed Description

Definition at line 35 of file flint_synonym.h.


Constructor & Destructor Documentation

FlintSynonymTable::FlintSynonymTable ( std::string  dbdir,
bool  readonly 
) [inline]

Create a new FlintSynonymTable object.

This method does not create or open the table on disk - you must call the create() or open() methods respectively!

Parameters:
dbdir The directory the flint database is stored in.
readonly true if we're opening read-only, else false.

Definition at line 51 of file flint_synonym.h.


Member Function Documentation

void FlintSynonymTable::merge_changes (  ) 

Definition at line 43 of file flint_synonym.cc.

References FlintTable::del(), last_synonyms, last_term, and MAGIC_XOR_VALUE.

Referenced by commit(), and FlintWritableDatabase::open_synonym_keylist().

void FlintSynonymTable::discard_changes (  )  [inline]

Definition at line 58 of file flint_synonym.h.

References last_synonyms, and last_term.

Referenced by cancel().

void FlintSynonymTable::add_synonym ( const std::string &  term,
const std::string &  synonym 
)

Add a synonym for term.

If the synonym has already been added, no action is taken.

Referenced by FlintWritableDatabase::add_synonym().

void FlintSynonymTable::remove_synonym ( const std::string &  term,
const std::string &  synonym 
)

Remove a synonym for term.

If the synonym doesn't exist, no action is taken.

Referenced by FlintWritableDatabase::remove_synonym().

void FlintSynonymTable::clear_synonyms ( const std::string &  term  ) 

Remove all synonyms for term.

If term has no synonyms, no action is taken.

Referenced by FlintWritableDatabase::clear_synonyms().

TermList* FlintSynonymTable::open_termlist ( const std::string &  term  ) 

Open synonym termlist for a term.

If term has no synonyms, NULL is returned.

Referenced by FlintDatabase::open_synonym_termlist().

bool FlintSynonymTable::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 94 of file flint_synonym.h.

References FlintTable::is_modified(), and last_term.

Referenced by FlintDatabase::apply().

void FlintSynonymTable::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).

Parameters:
blocksize - Size of blocks to use.
Exceptions:
Xapian::DatabaseCreateError if the table can't be created.
Xapian::InvalidArgumentError if the requested blocksize is unsuitable.

Reimplemented from FlintTable.

Definition at line 98 of file flint_synonym.h.

References FlintTable::erase(), and FlintTable::set_block_size().

Referenced by FlintDatabase::create_and_open_tables().

void FlintSynonymTable::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.

Parameters:
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 105 of file flint_synonym.h.

References FlintTable::commit(), and merge_changes().

Referenced by FlintDatabase::set_revision_number().

void FlintSynonymTable::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 110 of file flint_synonym.h.

References FlintTable::cancel(), and discard_changes().

Referenced by FlintDatabase::cancel().


Member Data Documentation

std::string FlintSynonymTable::last_term [mutable, private]

The last term which was updated.

Definition at line 37 of file flint_synonym.h.

Referenced by discard_changes(), is_modified(), and merge_changes().

std::set<std::string> FlintSynonymTable::last_synonyms [mutable, private]

The synonyms for the last term which was updated.

Definition at line 40 of file flint_synonym.h.

Referenced by discard_changes(), and merge_changes().


The documentation for this class was generated from the following files:
Documentation for Xapian (version 1.0.10).
Generated on 24 Dec 2008 by Doxygen 1.5.2.