xapian-core
1.4.26
|
The GlassVersion class manages the revision files. More...
#include <glass_version.h>
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... | |
GlassChanges * | changes |
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... | |
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.
|
inlineexplicit |
Definition at line 158 of file glass_version.h.
References Glass::RootInfo::blocksize.
|
explicit |
Definition at line 72 of file glass_version.cc.
References fd, offset, rare, and Xapian::Internal::str().
GlassVersion::~GlassVersion | ( | ) |
Definition at line 87 of file glass_version.cc.
|
inline |
Definition at line 241 of file glass_version.h.
References min_non_zero().
Referenced by GlassWritableDatabase::add_document_(), and GlassWritableDatabase::replace_document().
void GlassVersion::cancel | ( | ) |
Definition at line 261 of file glass_version.cc.
References LOGCALL_VOID, Glass::MAX_, old_root, root, and unserialise_stats().
Referenced by GlassDatabase::cancel().
|
inline |
Definition at line 260 of file glass_version.h.
Referenced by GlassWritableDatabase::add_document_(), and GlassWritableDatabase::replace_document().
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().
|
inline |
Definition at line 248 of file glass_version.h.
Referenced by GlassWritableDatabase::delete_document(), and GlassWritableDatabase::replace_document().
|
inline |
Definition at line 207 of file glass_version.h.
Referenced by check_db_dir(), check_db_fd(), check_glass_table(), GlassDatabase::get_doccount(), GlassDatabase::get_used_docid_range(), and merge_stats().
|
inline |
Definition at line 213 of file glass_version.h.
Referenced by check_glass_table(), GlassDatabase::get_doclength_lower_bound(), and merge_stats().
|
inline |
Definition at line 217 of file glass_version.h.
Referenced by check_glass_table(), GlassDatabase::get_doclength_upper_bound(), and merge_stats().
|
inline |
Definition at line 211 of file glass_version.h.
Referenced by GlassWritableDatabase::add_document(), check_db_dir(), check_db_fd(), check_glass_table(), GlassDatabase::get_lastdocid(), GlassDatabase::get_used_docid_range(), GlassDatabase::open_post_list(), GlassWritableDatabase::open_post_list(), and GlassWritableDatabase::replace_document().
|
inline |
Definition at line 264 of file glass_version.h.
Referenced by GlassWritableDatabase::add_document().
|
inline |
Definition at line 274 of file glass_version.h.
Referenced by check_db_fd(), and main().
|
inline |
Definition at line 227 of file glass_version.h.
Referenced by GlassDatabase::open_tables().
|
inline |
Definition at line 187 of file glass_version.h.
Referenced by GlassDatabaseReplicator::apply_changeset_from_conn(), GlassDatabase::cancel(), GlassTableCheck::check(), check_db_dir(), GlassDatabase::create_and_open_tables(), GlassDatabase::get_next_revision_number(), GlassDatabase::get_revision_number(), main(), GlassDatabase::modifications_failed(), GlassDatabase::open_tables(), and GlassDatabase::set_revision_number().
|
inline |
Definition at line 189 of file glass_version.h.
Referenced by GlassDatabase::cancel(), GlassTableCheck::check(), GlassDatabase::create_and_open_tables(), main(), GlassDatabase::modifications_failed(), and GlassDatabase::open_tables().
|
inline |
Definition at line 223 of file glass_version.h.
Referenced by GlassDatabase::cancel(), merge_stats(), and GlassDatabase::open_tables().
|
inline |
Definition at line 209 of file glass_version.h.
Referenced by GlassDatabase::get_total_length(), and merge_stats().
|
inline |
Return pointer to 16 byte UUID.
Definition at line 198 of file glass_version.h.
References Uuid::data().
|
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().
|
inline |
Definition at line 221 of file glass_version.h.
Referenced by GlassDatabase::get_wdf_upper_bound(), and merge_stats().
void GlassVersion::merge_stats | ( | const GlassVersion & | o | ) |
Merge the database stats.
Used by compaction.
Definition at line 236 of file glass_version.cc.
References doccount, doclen_lbound, doclen_ubound, get_doccount(), get_doclength_lower_bound(), get_doclength_upper_bound(), get_spelling_wordfreq_upper_bound(), get_total_doclen(), get_wdf_upper_bound(), spelling_wordfreq_ubound, total_doclen, and wdf_ubound.
void GlassVersion::read | ( | ) |
Read the version file and check it's a version we understand.
On failure, an exception is thrown.
Definition at line 96 of file glass_version.cc.
References Uuid::assign(), Uuid::BINARY_SIZE, db_dir, fd, GLASS_FORMAT_VERSION, GLASS_VERSION_MAGIC, GLASS_VERSION_MAGIC_AND_VERSION_LEN, GLASS_VERSION_MAGIC_LEN, io_read(), LOGCALL_VOID, Glass::MAX_, O_BINARY, offset, old_root, posixy_open, rare, rev, root, serialised_stats, single_file(), Xapian::Internal::str(), unpack_uint(), unserialise_stats(), uuid, VERSION_TO_DAY, VERSION_TO_MONTH, and VERSION_TO_YEAR.
Referenced by GlassDatabaseReplicator::apply_changeset_from_conn(), check_db_dir(), check_db_fd(), check_db_table(), GlassDatabaseReplicator::get_uuid(), main(), GlassDatabase::modifications_failed(), and GlassDatabase::open_tables().
|
inline |
Definition at line 193 of file glass_version.h.
Referenced by GlassDatabase::set_revision_number().
|
private |
Definition at line 174 of file glass_version.cc.
References doccount, doclen_lbound, doclen_ubound, last_docid, oldest_changeset, pack_uint(), serialised_stats, spelling_wordfreq_ubound, total_doclen, and wdf_ubound.
Referenced by write().
|
inline |
Definition at line 172 of file glass_version.h.
Referenced by GlassDatabase::apply(), GlassDatabase::modifications_failed(), and GlassDatabase::open_tables().
|
inline |
Definition at line 231 of file glass_version.h.
Referenced by GlassWritableDatabase::replace_document().
|
inline |
Definition at line 233 of file glass_version.h.
Referenced by GlassWritableDatabase::flush_postlist_changes().
|
inline |
Definition at line 237 of file glass_version.h.
Referenced by GlassDatabase::set_revision_number().
|
inline |
Definition at line 272 of file glass_version.h.
Referenced by read(), GlassDatabase::single_file(), sync(), unserialise_stats(), and write().
bool GlassVersion::sync | ( | const std::string & | tmpfile, |
glass_revision_number_t | new_rev, | ||
int | flags | ||
) |
Definition at line 327 of file glass_version.cc.
References Assert, close(), db_dir, Xapian::DB_FULL_SYNC, Xapian::DB_NO_SYNC, fd, io_full_sync(), io_sync(), io_tmp_rename(), Glass::MAX_, old_root, rev, root, and single_file().
Referenced by GlassDatabase::create_and_open_tables(), and GlassDatabase::set_revision_number().
|
private |
Definition at line 192 of file glass_version.cc.
References doccount, doclen_lbound, doclen_ubound, last_docid, oldest_changeset, serialised_stats, single_file(), spelling_wordfreq_ubound, total_doclen, unpack_uint(), and wdf_ubound.
const string GlassVersion::write | ( | glass_revision_number_t | new_rev, |
int | flags | ||
) |
Definition at line 271 of file glass_version.cc.
References Uuid::BINARY_SIZE, changes, close(), Uuid::data(), Xapian::DB_DANGEROUS, db_dir, fd, GLASS_VERSION_MAGIC, GLASS_VERSION_MAGIC_AND_VERSION_LEN, io_write(), LOGCALL, Glass::MAX_, O_BINARY, pack_uint(), posixy_open, rare, RETURN, root, Glass::RootInfo::serialise(), serialise_stats(), serialised_stats, single_file(), uuid, and GlassChanges::write_block().
Referenced by GlassDatabase::create_and_open_tables(), and GlassDatabase::set_revision_number().
|
private |
Definition at line 122 of file glass_version.h.
Referenced by write().
|
private |
The database directory.
Definition at line 120 of file glass_version.h.
|
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().
|
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().
|
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().
|
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().
|
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().
|
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().
|
private |
Definition at line 98 of file glass_version.h.
|
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().
|
private |
Definition at line 95 of file glass_version.h.
|
private |
Definition at line 97 of file glass_version.h.
Referenced by cancel(), create(), Glass::RootInfo::init(), read(), Glass::RootInfo::serialise(), sync(), Glass::RootInfo::unserialise(), and write().
|
private |
The serialised database stats.
Definition at line 149 of file glass_version.h.
Referenced by read(), serialise_stats(), unserialise_stats(), and write().
|
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().
|
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().
|
private |
The UUID of this database.
Definition at line 101 of file glass_version.h.
|
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().