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

The HoneyVersion class manages the revision files. More...

#include <honey_version.h>

+ Collaboration diagram for HoneyVersion:

Public Member Functions

 HoneyVersion (std::string_view db_dir_)
 
 HoneyVersion (int fd_)
 
 ~HoneyVersion ()
 
void create ()
 Create the version file. More...
 
void read ()
 Read the version file and check it's a version we understand. More...
 
void cancel ()
 
const std::string write (honey_revision_number_t new_rev, int flags)
 
bool sync (const std::string &tmpfile, honey_revision_number_t new_rev, int flags)
 
honey_revision_number_t get_revision () const
 
const Honey::RootInfoget_root (Honey::table_type tbl) const
 
Honey::RootInforoot_to_set (Honey::table_type tbl)
 
const char * get_uuid () const
 Return pointer to 16 byte UUID. More...
 
std::string get_uuid_string () const
 Return UUID in the standard 36 character string format. More...
 
Xapian::doccount get_doccount () const
 
Xapian::totallength get_total_doclen () const
 
Xapian::docid get_last_docid () const
 
Xapian::termcount get_doclength_lower_bound () const
 
Xapian::termcount get_doclength_upper_bound () const
 
Xapian::termcount get_wdf_upper_bound () const
 
Xapian::termcount get_spelling_wordfreq_upper_bound () const
 
honey_revision_number_t get_oldest_changeset () const
 
Xapian::termcount get_unique_terms_lower_bound () const
 
Xapian::termcount get_unique_terms_upper_bound () const
 
void set_last_docid (Xapian::docid did)
 
void set_oldest_changeset (honey_revision_number_t changeset) const
 
void set_spelling_wordfreq_upper_bound (Xapian::termcount ub)
 
void set_unique_terms_lower_bound (Xapian::termcount ub)
 
void set_unique_terms_upper_bound (Xapian::termcount ub)
 
void add_document (Xapian::termcount doclen)
 
void delete_document (Xapian::termcount doclen)
 
void check_wdf (Xapian::termcount wdf)
 
Xapian::docid get_next_docid ()
 
void merge_stats (const HoneyVersion &o)
 Merge the database stats. More...
 
void merge_stats (Xapian::doccount o_doccount, Xapian::termcount o_doclen_lbound, Xapian::termcount o_doclen_ubound, Xapian::termcount o_wdf_ubound, Xapian::totallength o_total_doclen, Xapian::termcount o_spelling_wordfreq_ubound, Xapian::termcount o_uniq_terms_lbound, Xapian::termcount o_uniq_terms_ubound)
 
bool single_file () const
 
off_t get_offset () const
 

Private Member Functions

void serialise_stats ()
 
void unserialise_stats ()
 

Private Attributes

honey_revision_number_t rev = 0
 
Honey::RootInfo root [Honey::MAX_]
 
Honey::RootInfo old_root [Honey::MAX_]
 
Uuid uuid
 The UUID of this database. More...
 
int fd
 File descriptor. More...
 
off_t offset = 0
 Offset into the file at which the version data starts. More...
 
std::string db_dir
 The database directory. More...
 
Xapian::doccount doccount = 0
 The number of documents in the database. More...
 
Xapian::totallength total_doclen = 0
 The total of the lengths of all documents in the database. More...
 
Xapian::docid last_docid = 0
 Greatest document id ever used in this database. More...
 
Xapian::termcount doclen_lbound = 0
 A lower bound on the smallest document length in this database. More...
 
Xapian::termcount doclen_ubound = 0
 An upper bound on the greatest document length in this database. More...
 
Xapian::termcount wdf_ubound = 0
 An upper bound on the greatest wdf in this database. More...
 
Xapian::termcount spelling_wordfreq_ubound = 0
 An upper bound on the spelling wordfreq in this database. More...
 
honey_revision_number_t oldest_changeset = 0
 Oldest changeset removed when max_changesets is set. More...
 
Xapian::termcount uniq_terms_lbound = 0
 A lower bound on the number of unique terms in a document in this database. More...
 
Xapian::termcount uniq_terms_ubound = 0
 An upper bound on the number of unique terms in a document in this database. More...
 
std::string serialised_stats
 The serialised database stats. More...
 

Detailed Description

The HoneyVersion class manages the revision files.

The "iamhoney" file (currently) contains a "magic" string identifying that this is a honey database, a database format version number, the UUID of the database, the revision of the database, and the root block info for each table.

Definition at line 79 of file honey_version.h.

Constructor & Destructor Documentation

◆ HoneyVersion() [1/2]

HoneyVersion::HoneyVersion ( std::string_view  db_dir_)
inlineexplicit

Definition at line 151 of file honey_version.h.

◆ HoneyVersion() [2/2]

HoneyVersion::HoneyVersion ( int  fd_)
explicit

Definition at line 94 of file honey_version.cc.

References fd, offset, rare, and Xapian::Internal::str().

◆ ~HoneyVersion()

HoneyVersion::~HoneyVersion ( )

Definition at line 105 of file honey_version.cc.

References close(), and fd.

Member Function Documentation

◆ add_document()

void HoneyVersion::add_document ( Xapian::termcount  doclen)
inline

Definition at line 244 of file honey_version.h.

References doccount, doclen_lbound, doclen_ubound, min_non_zero(), and total_doclen.

◆ cancel()

void HoneyVersion::cancel ( )

Definition at line 345 of file honey_version.cc.

References LOGCALL_VOID, Honey::MAX_, old_root, root, and unserialise_stats().

◆ check_wdf()

void HoneyVersion::check_wdf ( Xapian::termcount  wdf)
inline

Definition at line 263 of file honey_version.h.

References wdf_ubound.

◆ create()

void HoneyVersion::create ( )

Create the version file.

Definition at line 475 of file honey_version.cc.

References compress_min_tab, Uuid::generate(), Honey::RootInfo::init(), Honey::MAX_, root, and uuid.

◆ delete_document()

void HoneyVersion::delete_document ( Xapian::termcount  doclen)
inline

Definition at line 251 of file honey_version.h.

References doccount, doclen_lbound, doclen_ubound, total_doclen, and wdf_ubound.

◆ get_doccount()

Xapian::doccount HoneyVersion::get_doccount ( ) const
inline

◆ get_doclength_lower_bound()

Xapian::termcount HoneyVersion::get_doclength_lower_bound ( ) const
inline

Definition at line 200 of file honey_version.h.

References doclen_lbound.

Referenced by HoneyDatabase::get_doclength_lower_bound(), and merge_stats().

◆ get_doclength_upper_bound()

Xapian::termcount HoneyVersion::get_doclength_upper_bound ( ) const
inline

Definition at line 204 of file honey_version.h.

References doclen_ubound.

Referenced by HoneyDatabase::get_doclength_upper_bound(), and merge_stats().

◆ get_last_docid()

Xapian::docid HoneyVersion::get_last_docid ( ) const
inline

◆ get_next_docid()

Xapian::docid HoneyVersion::get_next_docid ( )
inline

Definition at line 267 of file honey_version.h.

References last_docid.

◆ get_offset()

off_t HoneyVersion::get_offset ( ) const
inline

Definition at line 286 of file honey_version.h.

References offset.

Referenced by main().

◆ get_oldest_changeset()

honey_revision_number_t HoneyVersion::get_oldest_changeset ( ) const
inline

Definition at line 214 of file honey_version.h.

References oldest_changeset.

◆ get_revision()

honey_revision_number_t HoneyVersion::get_revision ( ) const
inline

Definition at line 174 of file honey_version.h.

References rev.

Referenced by check_db_dir(), HoneyDatabase::get_revision(), HoneyDatabase::HoneyDatabase(), and main().

◆ get_root()

const Honey::RootInfo& HoneyVersion::get_root ( Honey::table_type  tbl) const
inline

Definition at line 176 of file honey_version.h.

References root.

Referenced by HoneyDatabase::HoneyDatabase(), and main().

◆ get_spelling_wordfreq_upper_bound()

Xapian::termcount HoneyVersion::get_spelling_wordfreq_upper_bound ( ) const
inline

Definition at line 210 of file honey_version.h.

References spelling_wordfreq_ubound.

Referenced by merge_stats().

◆ get_total_doclen()

Xapian::totallength HoneyVersion::get_total_doclen ( ) const
inline

Definition at line 196 of file honey_version.h.

References total_doclen.

Referenced by HoneyDatabase::get_total_length(), and merge_stats().

◆ get_unique_terms_lower_bound()

Xapian::termcount HoneyVersion::get_unique_terms_lower_bound ( ) const
inline

Definition at line 218 of file honey_version.h.

References uniq_terms_lbound.

Referenced by HoneyDatabase::get_unique_terms_lower_bound(), and merge_stats().

◆ get_unique_terms_upper_bound()

Xapian::termcount HoneyVersion::get_unique_terms_upper_bound ( ) const
inline

Definition at line 222 of file honey_version.h.

References uniq_terms_ubound.

Referenced by HoneyDatabase::get_unique_terms_upper_bound(), and merge_stats().

◆ get_uuid()

const char* HoneyVersion::get_uuid ( ) const
inline

Return pointer to 16 byte UUID.

Definition at line 185 of file honey_version.h.

References Uuid::data(), and uuid.

◆ get_uuid_string()

std::string HoneyVersion::get_uuid_string ( ) const
inline

Return UUID in the standard 36 character string format.

Definition at line 190 of file honey_version.h.

References Uuid::to_string(), and uuid.

Referenced by HoneyDatabase::get_uuid().

◆ get_wdf_upper_bound()

Xapian::termcount HoneyVersion::get_wdf_upper_bound ( ) const
inline

Definition at line 208 of file honey_version.h.

References wdf_ubound.

Referenced by HoneyDatabase::get_wdf_upper_bound(), and merge_stats().

◆ merge_stats() [1/2]

void HoneyVersion::merge_stats ( const HoneyVersion o)

◆ merge_stats() [2/2]

void HoneyVersion::merge_stats ( Xapian::doccount  o_doccount,
Xapian::termcount  o_doclen_lbound,
Xapian::termcount  o_doclen_ubound,
Xapian::termcount  o_wdf_ubound,
Xapian::totallength  o_total_doclen,
Xapian::termcount  o_spelling_wordfreq_ubound,
Xapian::termcount  o_uniq_terms_lbound,
Xapian::termcount  o_uniq_terms_ubound 
)

◆ read()

void HoneyVersion::read ( )

◆ root_to_set()

Honey::RootInfo* HoneyVersion::root_to_set ( Honey::table_type  tbl)
inline

Definition at line 180 of file honey_version.h.

References root.

◆ serialise_stats()

void HoneyVersion::serialise_stats ( )
private

◆ set_last_docid()

void HoneyVersion::set_last_docid ( Xapian::docid  did)
inline

Definition at line 226 of file honey_version.h.

References last_docid.

◆ set_oldest_changeset()

void HoneyVersion::set_oldest_changeset ( honey_revision_number_t  changeset) const
inline

Definition at line 228 of file honey_version.h.

References oldest_changeset.

◆ set_spelling_wordfreq_upper_bound()

void HoneyVersion::set_spelling_wordfreq_upper_bound ( Xapian::termcount  ub)
inline

Definition at line 232 of file honey_version.h.

References spelling_wordfreq_ubound.

◆ set_unique_terms_lower_bound()

void HoneyVersion::set_unique_terms_lower_bound ( Xapian::termcount  ub)
inline

Definition at line 236 of file honey_version.h.

References uniq_terms_lbound.

◆ set_unique_terms_upper_bound()

void HoneyVersion::set_unique_terms_upper_bound ( Xapian::termcount  ub)
inline

Definition at line 240 of file honey_version.h.

References uniq_terms_ubound.

◆ single_file()

bool HoneyVersion::single_file ( ) const
inline

Definition at line 284 of file honey_version.h.

References db_dir.

Referenced by read(), sync(), and write().

◆ sync()

bool HoneyVersion::sync ( const std::string &  tmpfile,
honey_revision_number_t  new_rev,
int  flags 
)

◆ unserialise_stats()

void HoneyVersion::unserialise_stats ( )
private

◆ write()

const string HoneyVersion::write ( honey_revision_number_t  new_rev,
int  flags 
)

Member Data Documentation

◆ db_dir

std::string HoneyVersion::db_dir
private

The database directory.

Definition at line 105 of file honey_version.h.

Referenced by check_honey_table(), read(), single_file(), sync(), and write().

◆ doccount

Xapian::doccount HoneyVersion::doccount = 0
private

The number of documents in the database.

Definition at line 108 of file honey_version.h.

Referenced by add_document(), delete_document(), get_doccount(), merge_stats(), serialise_stats(), and unserialise_stats().

◆ doclen_lbound

Xapian::termcount HoneyVersion::doclen_lbound = 0
private

A lower bound on the smallest document length in this database.

Definition at line 117 of file honey_version.h.

Referenced by add_document(), delete_document(), get_doclength_lower_bound(), merge_stats(), serialise_stats(), and unserialise_stats().

◆ doclen_ubound

Xapian::termcount HoneyVersion::doclen_ubound = 0
private

An upper bound on the greatest document length in this database.

Definition at line 120 of file honey_version.h.

Referenced by add_document(), delete_document(), get_doclength_upper_bound(), merge_stats(), serialise_stats(), and unserialise_stats().

◆ fd

int HoneyVersion::fd
private

File descriptor.

When committing, this hold the file descriptor of the new changes file between the call to the write() and sync() methods.

For a single-file database (when db_dir.empty()), this holds the fd of that file for use in read().

Definition at line 96 of file honey_version.h.

Referenced by check_honey_table(), HoneyVersion(), read(), sync(), write(), and ~HoneyVersion().

◆ last_docid

Xapian::docid HoneyVersion::last_docid = 0
private

Greatest document id ever used in this database.

Definition at line 114 of file honey_version.h.

Referenced by get_last_docid(), get_next_docid(), serialise_stats(), set_last_docid(), and unserialise_stats().

◆ offset

off_t HoneyVersion::offset = 0
private

Offset into the file at which the version data starts.

Will be 0, except for an embedded multi-file database.

Definition at line 102 of file honey_version.h.

Referenced by get_offset(), HoneyVersion(), and read().

◆ old_root

Honey::RootInfo HoneyVersion::old_root[Honey::MAX_]
private

Definition at line 83 of file honey_version.h.

Referenced by cancel(), read(), and sync().

◆ oldest_changeset

honey_revision_number_t HoneyVersion::oldest_changeset = 0
mutableprivate

Oldest changeset removed when max_changesets is set.

Definition at line 129 of file honey_version.h.

Referenced by get_oldest_changeset(), serialise_stats(), set_oldest_changeset(), and unserialise_stats().

◆ rev

honey_revision_number_t HoneyVersion::rev = 0
private

Definition at line 80 of file honey_version.h.

Referenced by get_revision(), read(), and sync().

◆ root

Honey::RootInfo HoneyVersion::root[Honey::MAX_]
private

Definition at line 82 of file honey_version.h.

Referenced by cancel(), create(), get_root(), read(), root_to_set(), sync(), and write().

◆ serialised_stats

std::string HoneyVersion::serialised_stats
private

The serialised database stats.

Definition at line 142 of file honey_version.h.

Referenced by read(), serialise_stats(), unserialise_stats(), and write().

◆ spelling_wordfreq_ubound

Xapian::termcount HoneyVersion::spelling_wordfreq_ubound = 0
private

An upper bound on the spelling wordfreq in this database.

Definition at line 126 of file honey_version.h.

Referenced by get_spelling_wordfreq_upper_bound(), merge_stats(), serialise_stats(), set_spelling_wordfreq_upper_bound(), and unserialise_stats().

◆ total_doclen

Xapian::totallength HoneyVersion::total_doclen = 0
private

The total of the lengths of all documents in the database.

Definition at line 111 of file honey_version.h.

Referenced by add_document(), delete_document(), get_total_doclen(), merge_stats(), serialise_stats(), and unserialise_stats().

◆ uniq_terms_lbound

Xapian::termcount HoneyVersion::uniq_terms_lbound = 0
private

A lower bound on the number of unique terms in a document in this database.

Definition at line 134 of file honey_version.h.

Referenced by get_unique_terms_lower_bound(), merge_stats(), serialise_stats(), set_unique_terms_lower_bound(), and unserialise_stats().

◆ uniq_terms_ubound

Xapian::termcount HoneyVersion::uniq_terms_ubound = 0
private

An upper bound on the number of unique terms in a document in this database.

Definition at line 139 of file honey_version.h.

Referenced by get_unique_terms_upper_bound(), merge_stats(), serialise_stats(), set_unique_terms_upper_bound(), and unserialise_stats().

◆ uuid

Uuid HoneyVersion::uuid
private

The UUID of this database.

Definition at line 86 of file honey_version.h.

Referenced by create(), get_uuid(), get_uuid_string(), read(), and write().

◆ wdf_ubound

Xapian::termcount HoneyVersion::wdf_ubound = 0
private

An upper bound on the greatest wdf in this database.

Definition at line 123 of file honey_version.h.

Referenced by check_wdf(), delete_document(), get_wdf_upper_bound(), merge_stats(), serialise_stats(), and unserialise_stats().


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