xapian-core  1.4.21
Public Member Functions | Private Member Functions | Private Attributes | List of all members
GlassVersion Class Reference

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

#include <glass_version.h>

+ Collaboration diagram for GlassVersion:

Public Member Functions

 GlassVersion (const std::string &db_dir_)
 
 GlassVersion (int fd_)
 
 ~GlassVersion ()
 
void create (unsigned blocksize)
 Create the version file. More...
 
void set_changes (GlassChanges *changes_)
 
void read ()
 Read the version file and check it's a version we understand. More...
 
void cancel ()
 
const std::string write (glass_revision_number_t new_rev, int flags)
 
bool sync (const std::string &tmpfile, glass_revision_number_t new_rev, int flags)
 
glass_revision_number_t get_revision () const
 
const RootInfoget_root (Glass::table_type tbl) const
 
RootInforoot_to_set (Glass::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
 
glass_revision_number_t get_oldest_changeset () const
 
void set_last_docid (Xapian::docid did)
 
void set_oldest_changeset (glass_revision_number_t changeset) const
 
void set_spelling_wordfreq_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 GlassVersion &o)
 Merge the database stats. More...
 
bool single_file () const
 
off_t get_offset () const
 

Private Member Functions

void serialise_stats ()
 
void unserialise_stats ()
 

Private Attributes

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

Detailed Description

The GlassVersion class manages the revision files.

The "iamglass" file (currently) contains a "magic" string identifying that this is a glass 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 94 of file glass_version.h.

Constructor & Destructor Documentation

◆ GlassVersion() [1/2]

GlassVersion::GlassVersion ( const std::string &  db_dir_)
inlineexplicit

Definition at line 158 of file glass_version.h.

References Glass::RootInfo::blocksize.

◆ GlassVersion() [2/2]

GlassVersion::GlassVersion ( int  fd_)
explicit

Definition at line 72 of file glass_version.cc.

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

◆ ~GlassVersion()

GlassVersion::~GlassVersion ( )

Definition at line 87 of file glass_version.cc.

References close(), and fd.

Member Function Documentation

◆ add_document()

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

◆ cancel()

void GlassVersion::cancel ( )

◆ check_wdf()

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

◆ create()

void GlassVersion::create ( unsigned  blocksize)

Create the version file.

Definition at line 397 of file glass_version.cc.

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

Referenced by GlassDatabase::create_and_open_tables().

◆ delete_document()

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

◆ get_doccount()

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

◆ get_doclength_lower_bound()

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

◆ get_doclength_upper_bound()

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

◆ get_last_docid()

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

◆ get_next_docid()

Xapian::docid GlassVersion::get_next_docid ( )
inline

Definition at line 264 of file glass_version.h.

Referenced by GlassWritableDatabase::add_document().

◆ get_offset()

off_t GlassVersion::get_offset ( ) const
inline

Definition at line 274 of file glass_version.h.

Referenced by check_db_fd(), and main().

◆ get_oldest_changeset()

glass_revision_number_t GlassVersion::get_oldest_changeset ( ) const
inline

Definition at line 227 of file glass_version.h.

Referenced by GlassDatabase::open_tables().

◆ get_revision()

glass_revision_number_t GlassVersion::get_revision ( ) const
inline

◆ get_root()

const RootInfo& GlassVersion::get_root ( Glass::table_type  tbl) const
inline

◆ get_spelling_wordfreq_upper_bound()

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

◆ get_total_doclen()

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

Definition at line 209 of file glass_version.h.

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

◆ get_uuid()

const char* GlassVersion::get_uuid ( ) const
inline

Return pointer to 16 byte UUID.

Definition at line 198 of file glass_version.h.

References Uuid::data().

◆ get_uuid_string()

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

Return UUID in the standard 36 character string format.

Definition at line 203 of file glass_version.h.

References Uuid::to_string().

Referenced by GlassDatabaseReplicator::get_uuid(), and GlassDatabase::get_uuid().

◆ get_wdf_upper_bound()

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

Definition at line 221 of file glass_version.h.

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

◆ merge_stats()

void GlassVersion::merge_stats ( const GlassVersion o)

◆ read()

void GlassVersion::read ( )

◆ root_to_set()

RootInfo* GlassVersion::root_to_set ( Glass::table_type  tbl)
inline

Definition at line 193 of file glass_version.h.

Referenced by GlassDatabase::set_revision_number().

◆ serialise_stats()

void GlassVersion::serialise_stats ( )
private

◆ set_changes()

void GlassVersion::set_changes ( GlassChanges changes_)
inline

◆ set_last_docid()

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

Definition at line 231 of file glass_version.h.

Referenced by GlassWritableDatabase::replace_document().

◆ set_oldest_changeset()

void GlassVersion::set_oldest_changeset ( glass_revision_number_t  changeset) const
inline

Definition at line 233 of file glass_version.h.

Referenced by GlassWritableDatabase::flush_postlist_changes().

◆ set_spelling_wordfreq_upper_bound()

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

Definition at line 237 of file glass_version.h.

Referenced by GlassDatabase::set_revision_number().

◆ single_file()

bool GlassVersion::single_file ( ) const
inline

Definition at line 272 of file glass_version.h.

Referenced by read(), GlassDatabase::single_file(), sync(), unserialise_stats(), and write().

◆ sync()

bool GlassVersion::sync ( const std::string &  tmpfile,
glass_revision_number_t  new_rev,
int  flags 
)

◆ unserialise_stats()

void GlassVersion::unserialise_stats ( )
private

◆ write()

const string GlassVersion::write ( glass_revision_number_t  new_rev,
int  flags 
)

Member Data Documentation

◆ changes

GlassChanges* GlassVersion::changes
private

Definition at line 122 of file glass_version.h.

Referenced by write().

◆ db_dir

std::string GlassVersion::db_dir
private

The database directory.

Definition at line 120 of file glass_version.h.

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

◆ doccount

Xapian::doccount GlassVersion::doccount
private

The number of documents in the database.

Definition at line 125 of file glass_version.h.

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

◆ doclen_lbound

Xapian::termcount GlassVersion::doclen_lbound
private

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

Definition at line 134 of file glass_version.h.

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

◆ doclen_ubound

Xapian::termcount GlassVersion::doclen_ubound
private

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

Definition at line 137 of file glass_version.h.

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

◆ fd

int GlassVersion::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 111 of file glass_version.h.

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

◆ last_docid

Xapian::docid GlassVersion::last_docid
private

Greatest document id ever used in this database.

Definition at line 131 of file glass_version.h.

Referenced by serialise_stats(), and unserialise_stats().

◆ offset

off_t GlassVersion::offset
private

Offset into the file at which the version data starts.

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

Definition at line 117 of file glass_version.h.

Referenced by GlassVersion(), and read().

◆ old_root

RootInfo GlassVersion::old_root[Glass::MAX_]
private

Definition at line 98 of file glass_version.h.

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

◆ oldest_changeset

glass_revision_number_t GlassVersion::oldest_changeset
mutableprivate

Oldest changeset removed when max_changesets is set.

Definition at line 146 of file glass_version.h.

Referenced by serialise_stats(), and unserialise_stats().

◆ rev

glass_revision_number_t GlassVersion::rev
private

Definition at line 95 of file glass_version.h.

Referenced by read(), and sync().

◆ root

RootInfo GlassVersion::root[Glass::MAX_]
private

◆ serialised_stats

std::string GlassVersion::serialised_stats
private

The serialised database stats.

Definition at line 149 of file glass_version.h.

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

◆ spelling_wordfreq_ubound

Xapian::termcount GlassVersion::spelling_wordfreq_ubound
private

An upper bound on the spelling wordfreq in this database.

Definition at line 143 of file glass_version.h.

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

◆ total_doclen

Xapian::totallength GlassVersion::total_doclen
private

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

Definition at line 128 of file glass_version.h.

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

◆ uuid

Uuid GlassVersion::uuid
private

The UUID of this database.

Definition at line 101 of file glass_version.h.

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

◆ wdf_ubound

Xapian::termcount GlassVersion::wdf_ubound
private

An upper bound on the greatest wdf in this database.

Definition at line 140 of file glass_version.h.

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


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