xapian-core  2.0.0
Public Member Functions | Private Member Functions | Private Attributes | List of all members
HoneySpellingTable Class Reference

#include <honey_spelling.h>

+ Inheritance diagram for HoneySpellingTable:
+ Collaboration diagram for HoneySpellingTable:

Public Member Functions

 HoneySpellingTable (const std::string &dbdir, bool readonly)
 Create a new HoneySpellingTable object. More...
 
 HoneySpellingTable (int fd, off_t offset_, bool readonly)
 
void merge_changes ()
 Merge in batched-up changes. More...
 
void add_word (const std::string &word, Xapian::termcount freqinc)
 
Xapian::termcount remove_word (const std::string &word, Xapian::termcount freqdec)
 
TermListopen_termlist (std::string_view word)
 
Xapian::doccount get_word_frequency (std::string_view word) const
 
void set_wordfreq_upper_bound (Xapian::termcount ub)
 
bool is_modified () const
 Override methods of HoneyTable. More...
 
Xapian::termcount flush_db ()
 Returns updated wordfreq upper bound. More...
 
void cancel (const Honey::RootInfo &root_info, honey_revision_number_t rev)
 Override methods of HoneyTable. More...
 
- Public Member Functions inherited from HoneyLazyTable
 HoneyLazyTable (const char *name_, const std::string &path_, bool readonly)
 Create a new lazy table. More...
 
 HoneyLazyTable (const char *name_, int fd, off_t offset_, bool readonly)
 
- Public Member Functions inherited from HoneyTable
 HoneyTable (const char *, const std::string &path_, bool read_only_, bool lazy_=false)
 
 HoneyTable (const char *, int fd, off_t offset_, bool read_only_, bool lazy_=false)
 
 ~HoneyTable ()
 
bool is_writable () const
 
int get_flags () const
 
void create_and_open (int flags_, const Honey::RootInfo &root_info)
 
void open (int flags_, const Honey::RootInfo &root_info, honey_revision_number_t)
 
void close (bool permanent)
 
const std::string & get_path () const
 
void add (std::string_view key, const char *val, size_t val_size, bool compressed=false)
 
void add (std::string_view key, std::string_view val, bool compressed=false)
 
void flush_db ()
 
void cancel (const Honey::RootInfo &, honey_revision_number_t)
 
void commit (honey_revision_number_t, Honey::RootInfo *root_info)
 
bool sync ()
 
bool empty () const
 
bool get_exact_entry (std::string_view key, std::string &tag) const
 
bool key_exists (const std::string &key) const
 
bool del (const std::string &)
 
bool readahead_key (const std::string &) const
 
bool is_modified () const
 
HoneyCursorcursor_get () const
 
bool exists () const
 
bool is_open () const
 
honey_tablesize_t get_entry_count () const
 
honey_tablesize_t get_approx_entry_count () const
 Return an approximation of the number of entries in the table. More...
 
off_t get_root () const
 
off_t get_offset () const
 

Private Member Functions

void toggle_word (const std::string &word)
 
void toggle_fragment (Honey::fragment frag, const std::string &word)
 

Private Attributes

std::map< std::string, Xapian::termcount, std::less<> > wordfreq_changes
 
std::map< Honey::fragment, std::set< std::string > > termlist_deltas
 Changes to make to the termlists. More...
 
Xapian::termcount wordfreq_upper_bound = 0
 Used to track an upper bound on wordfreq. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from HoneyTable
static void throw_database_closed ()
 

Detailed Description

Definition at line 77 of file honey_spelling.h.

Constructor & Destructor Documentation

◆ HoneySpellingTable() [1/2]

HoneySpellingTable::HoneySpellingTable ( const std::string &  dbdir,
bool  readonly 
)
inline

Create a new HoneySpellingTable object.

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

Parameters
dbdirThe directory the honey database is stored in.
readonlytrue if we're opening read-only, else false.

Definition at line 107 of file honey_spelling.h.

◆ HoneySpellingTable() [2/2]

HoneySpellingTable::HoneySpellingTable ( int  fd,
off_t  offset_,
bool  readonly 
)
inline

Definition at line 110 of file honey_spelling.h.

Member Function Documentation

◆ add_word()

void HoneySpellingTable::add_word ( const std::string &  word,
Xapian::termcount  freqinc 
)

Definition at line 129 of file honey_spelling.cc.

References Honey::make_spelling_wordlist_key(), p, and unpack_uint_last().

◆ cancel()

void HoneySpellingTable::cancel ( const Honey::RootInfo root_info,
honey_revision_number_t  rev 
)
inline

Override methods of HoneyTable.

NB: these aren't virtual, but we always call them on the subclass in cases where it matters.

Definition at line 146 of file honey_spelling.h.

References HoneyTable::cancel(), termlist_deltas, and wordfreq_changes.

◆ flush_db()

Xapian::termcount HoneySpellingTable::flush_db ( )
inline

Returns updated wordfreq upper bound.

Definition at line 140 of file honey_spelling.h.

References HoneyTable::flush_db(), merge_changes(), and wordfreq_upper_bound.

◆ get_word_frequency()

Xapian::doccount HoneySpellingTable::get_word_frequency ( std::string_view  word) const

◆ is_modified()

bool HoneySpellingTable::is_modified ( ) const
inline

Override methods of HoneyTable.

NB: these aren't virtual, but we always call them on the subclass in cases where it matters.

Definition at line 135 of file honey_spelling.h.

References HoneyTable::is_modified(), and wordfreq_changes.

◆ merge_changes()

void HoneySpellingTable::merge_changes ( )

◆ open_termlist()

TermList * HoneySpellingTable::open_termlist ( std::string_view  word)

◆ remove_word()

Xapian::termcount HoneySpellingTable::remove_word ( const std::string &  word,
Xapian::termcount  freqdec 
)

Definition at line 163 of file honey_spelling.cc.

References Honey::make_spelling_wordlist_key(), p, and unpack_uint_last().

◆ set_wordfreq_upper_bound()

void HoneySpellingTable::set_wordfreq_upper_bound ( Xapian::termcount  ub)
inline

Definition at line 124 of file honey_spelling.h.

References wordfreq_upper_bound.

◆ toggle_fragment()

void HoneySpellingTable::toggle_fragment ( Honey::fragment  frag,
const std::string &  word 
)
private

Definition at line 113 of file honey_spelling.cc.

◆ toggle_word()

void HoneySpellingTable::toggle_word ( const std::string &  word)
private

Member Data Documentation

◆ termlist_deltas

std::map<Honey::fragment, std::set<std::string> > HoneySpellingTable::termlist_deltas
mutableprivate

Changes to make to the termlists.

This list is essentially xor-ed with the list on disk, so an entry here either means a new entry needs to be added on disk, or an existing entry on disk needs to be removed. We do it this way so we don't need to store an additional add/remove flag for every word.

Definition at line 93 of file honey_spelling.h.

Referenced by cancel().

◆ wordfreq_changes

std::map<std::string, Xapian::termcount, std::less<> > HoneySpellingTable::wordfreq_changes
mutableprivate

Definition at line 83 of file honey_spelling.h.

Referenced by cancel(), and is_modified().

◆ wordfreq_upper_bound

Xapian::termcount HoneySpellingTable::wordfreq_upper_bound = 0
private

Used to track an upper bound on wordfreq.

Definition at line 96 of file honey_spelling.h.

Referenced by flush_db(), and set_wordfreq_upper_bound().


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