xapian-core  1.4.30
Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | Friends | List of all members
GlassDatabase Class Reference

A backend designed for efficient indexing and retrieval, using compressed posting lists and a btree storage scheme. More...

#include <glass_database.h>

+ Inheritance diagram for GlassDatabase:
+ Collaboration diagram for GlassDatabase:

Public Member Functions

 GlassDatabase (const string &db_dir_, int flags=Xapian::DB_READONLY_, unsigned int block_size=0u)
 Create and open a glass database. More...
 
 GlassDatabase (int fd)
 
 ~GlassDatabase ()
 
GlassCursorget_postlist_cursor () const
 Get a postlist table cursor (used by GlassValueList). More...
 
glass_revision_number_t get_revision_number () const
 Get an object holding the revision number which the tables are opened at. More...
 
Xapian::doccount get_doccount () const
 Virtual methods of Database::Internal. More...
 
Xapian::docid get_lastdocid () const
 Return the last used document id of this (sub) database. More...
 
Xapian::totallength get_total_length () const
 Return the total length of all documents in this database. More...
 
Xapian::termcount get_doclength (Xapian::docid did) const
 Get the length of a given document. More...
 
Xapian::termcount get_unique_terms (Xapian::docid did) const
 Get the number of unique term in document. More...
 
void get_freqs (const string &term, Xapian::doccount *termfreq_ptr, Xapian::termcount *collfreq_ptr) const
 Returns frequencies for a term. More...
 
Xapian::doccount get_value_freq (Xapian::valueno slot) const
 Return the frequency of a given value slot. More...
 
std::string get_value_lower_bound (Xapian::valueno slot) const
 Get a lower bound on the values stored in the given value slot. More...
 
std::string get_value_upper_bound (Xapian::valueno slot) const
 Get an upper bound on the values stored in the given value slot. More...
 
Xapian::termcount get_doclength_lower_bound () const
 Get a lower bound on the length of a document in this DB. More...
 
Xapian::termcount get_doclength_upper_bound () const
 Get an upper bound on the length of a document in this DB. More...
 
Xapian::termcount get_wdf_upper_bound (const string &term) const
 Get an upper bound on the wdf of term term. More...
 
bool term_exists (const string &tname) const
 Check whether a given term is in the database. More...
 
bool has_positions () const
 Check whether this database contains any positional information. More...
 
LeafPostListopen_post_list (const string &tname) const
 Open a posting list. More...
 
ValueListopen_value_list (Xapian::valueno slot) const
 Open a value stream. More...
 
Xapian::Document::Internalopen_document (Xapian::docid did, bool lazy) const
 Open a document. More...
 
virtual void read_position_list (GlassPositionList *pos_list, Xapian::docid did, const string &term) const
 
virtual Xapian::termcount positionlist_count (Xapian::docid did, const string &term) const
 
PositionListopen_position_list (Xapian::docid did, const string &term) const
 Open a position list for the given term in the given document. More...
 
TermListopen_term_list (Xapian::docid did) const
 Open a term list. More...
 
TermListopen_allterms (const string &prefix) const
 Open an allterms list. More...
 
TermListopen_spelling_termlist (const string &word) const
 Create a termlist tree from trigrams of word. More...
 
TermListopen_spelling_wordlist () const
 Return a termlist which returns the words which are spelling correction targets. More...
 
Xapian::doccount get_spelling_frequency (const string &word) const
 Return the number of times word was added as a spelling. More...
 
TermListopen_synonym_termlist (const string &term) const
 Open a termlist returning synonyms for a term. More...
 
TermListopen_synonym_keylist (const string &prefix) const
 Open a termlist returning each term which has synonyms. More...
 
string get_metadata (const string &key) const
 Get the metadata associated with a given key. More...
 
TermListopen_metadata_keylist (const std::string &prefix) const
 Open a termlist returning each metadata key. More...
 
void write_changesets_to_fd (int fd, const string &start_revision, bool need_whole_db, Xapian::ReplicationInfo *info)
 Write a set of changesets to a file descriptor. More...
 
string get_revision_info () const
 Get a string describing the current revision of the database. More...
 
string get_uuid () const
 Get a UUID for the database. More...
 
void request_document (Xapian::docid) const
 Request and later collect a document from the database. More...
 
void readahead_for_query (const Xapian::Query &query)
 
void throw_termlist_table_close_exception () const
 
int get_backend_info (string *path) const
 Get backend information about this database. More...
 
bool single_file () const
 
void get_used_docid_range (Xapian::docid &first, Xapian::docid &last) const
 Find lowest and highest docids actually in use. More...
 
virtual bool has_uncommitted_changes () const
 Return true if there are uncommitted changes. More...
 
bool locked () const
 Return true if the database is open for writing. More...
 
- Public Member Functions inherited from Xapian::Database::Internal
virtual ~Internal ()
 Destroy the database. More...
 
virtual void keep_alive ()
 Send a keep-alive signal to a remote database, to stop it from timing out. More...
 
virtual void add_spelling (const string &word, Xapian::termcount freqinc) const
 Add a word to the spelling dictionary. More...
 
virtual void remove_spelling (const string &word, Xapian::termcount freqdec) const
 Remove a word from the spelling dictionary. More...
 
virtual void add_synonym (const string &term, const string &synonym) const
 Add a synonym for a term. More...
 
virtual void remove_synonym (const string &term, const string &synonym) const
 Remove a synonym for a term. More...
 
virtual void clear_synonyms (const string &term) const
 Clear all synonyms for a term. More...
 
virtual void set_metadata (const string &key, const string &value)
 Set the metadata associated with a given key. More...
 
virtual void commit ()
 Commit pending modifications to the database. More...
 
void begin_transaction (bool flushed)
 Begin a transaction. More...
 
void commit_transaction ()
 Commit a transaction. More...
 
void cancel_transaction ()
 Cancel a transaction. More...
 
virtual Xapian::docid add_document (const Xapian::Document &document)
 Add a new document to the database. More...
 
virtual void delete_document (Xapian::docid did)
 Delete a document in the database. More...
 
virtual void delete_document (const string &unique_term)
 Delete any documents indexed by a term from the database. More...
 
virtual void replace_document (Xapian::docid did, const Xapian::Document &document)
 Replace a given document in the database. More...
 
virtual Xapian::docid replace_document (const string &unique_term, const Xapian::Document &document)
 Replace any documents matching a term. More...
 
virtual Xapian::Document::Internalcollect_document (Xapian::docid did) const
 
virtual void invalidate_doc_object (Xapian::Document::Internal *obj) const
 Notify the database that document is no longer valid. More...
 
- Public Member Functions inherited from Xapian::Internal::intrusive_base
 intrusive_base ()
 Construct with no references. More...
 

Static Public Member Functions

static void compact (Xapian::Compactor *compactor, const char *destdir, int fd, const std::vector< Xapian::Database::Internal * > &sources, const std::vector< Xapian::docid > &offset, size_t block_size, Xapian::Compactor::compaction_level compaction, unsigned flags, Xapian::docid last_docid)
 

Private Member Functions

bool database_exists ()
 Return true if a database exists at the path specified for this database. More...
 
void create_and_open_tables (int flags, unsigned int blocksize)
 Create new tables, and open them. More...
 
bool open_tables (int flags)
 Open all tables at most recent revision. More...
 
void get_database_write_lock (int flags, bool creating)
 Get a write lock on the database, or throw an Xapian::DatabaseLockError if failure. More...
 
glass_revision_number_t get_next_revision_number () const
 Get an object holding the next revision number which should be used in the tables. More...
 
void set_revision_number (int flags, glass_revision_number_t new_revision)
 Set the revision number in the tables. More...
 
bool reopen ()
 Re-open tables to recover from an overwritten condition, or just get most up-to-date version. More...
 
void close ()
 Close all the tables permanently. More...
 
void modifications_failed (glass_revision_number_t new_revision, const std::string &msg)
 Called if a modifications fail. More...
 
void apply ()
 Apply any outstanding changes to the tables. More...
 
void cancel ()
 Cancel any outstanding changes to the tables. More...
 
void send_whole_database (RemoteConnection &conn, double end_time)
 Send a set of messages which transfer the whole database. More...
 
void get_changeset_revisions (const string &path, glass_revision_number_t *startrev, glass_revision_number_t *endrev) const
 Get the revision stored in a changeset. More...
 

Private Attributes

std::string db_dir
 Directory to store databases in. More...
 
bool readonly
 Whether the database is readonly. More...
 
GlassVersion version_file
 The file describing the Glass database. More...
 
GlassPostListTable postlist_table
 Table storing posting lists. More...
 
GlassPositionListTable position_table
 Table storing position lists. More...
 
GlassTermListTable termlist_table
 Table storing term lists. More...
 
GlassValueManager value_manager
 Value manager. More...
 
GlassSynonymTable synonym_table
 Table storing synonym data. More...
 
GlassSpellingTable spelling_table
 Table storing spelling correction data. More...
 
GlassDocDataTable docdata_table
 Table storing document data. More...
 
FlintLock lock
 Lock object. More...
 
GlassChanges changes
 Replication changesets. More...
 

Friends

class GlassWritableDatabase
 
class GlassTermList
 
class GlassPostList
 
class GlassAllTermsList
 
class GlassAllDocsPostList
 

Additional Inherited Members

- Public Attributes inherited from Xapian::Internal::intrusive_base
unsigned _refs
 Reference count. More...
 
- Protected Types inherited from Xapian::Database::Internal
enum  { TRANSACTION_UNIMPLEMENTED = -1 , TRANSACTION_NONE = 0 , TRANSACTION_UNFLUSHED = 1 , TRANSACTION_FLUSHED = 2 }
 Transaction state. More...
 
- Protected Member Functions inherited from Xapian::Database::Internal
bool transaction_active () const
 
 Internal ()
 Create a database - called only by derived classes. More...
 
void dtor_called ()
 Internal method to perform cleanup when a writable database is destroyed with uncommitted changes. More...
 
- Protected Attributes inherited from Xapian::Database::Internal
enum Xapian::Database::Internal:: { ... }  transaction_state
 Transaction state. More...
 

Detailed Description

A backend designed for efficient indexing and retrieval, using compressed posting lists and a btree storage scheme.

Definition at line 58 of file glass_database.h.

Constructor & Destructor Documentation

◆ GlassDatabase() [1/2]

GlassDatabase::GlassDatabase ( const string &  db_dir_,
int  flags = Xapian::DB_READONLY_,
unsigned int  block_size = 0u 
)
explicit

Create and open a glass database.

Exceptions
Xapian::DatabaseCorruptErroris thrown if a problem is found with the database's format.
Xapian::DatabaseOpeningErrorthrown if database can't be opened.
Xapian::DatabaseVersionErrorthrown if database is in an unsupported format. This implies that the database was created by an older or newer version of Xapian.
Parameters
dbdirdirectory holding glass tables
block_sizeBlock size, in bytes, to use when creating tables. This is only important, and has the correct value, when the database is being created.

Definition at line 98 of file glass_database.cc.

References create_and_open_tables(), database_exists(), Xapian::DB_CREATE, Xapian::DB_CREATE_OR_OVERWRITE, db_dir, Xapian::DB_OPEN, dir_exists(), get_database_write_lock(), GLASS_DEFAULT_BLOCKSIZE, LOGCALL_CTOR, open_tables(), and readonly.

◆ GlassDatabase() [2/2]

GlassDatabase::GlassDatabase ( int  fd)
explicit

Definition at line 163 of file glass_database.cc.

References LOGCALL_CTOR, and open_tables().

◆ ~GlassDatabase()

GlassDatabase::~GlassDatabase ( )

Definition at line 181 of file glass_database.cc.

References LOGCALL_DTOR.

Member Function Documentation

◆ apply()

void GlassDatabase::apply ( )
private

Apply any outstanding changes to the tables.

If an error occurs during this operation, this will be signalled by an exception being thrown. In this case the contents of the tables on disk will be left in an unmodified state (though possibly with increased revision numbers), and the outstanding changes will be lost.

Definition at line 657 of file glass_database.cc.

References changes, docdata_table, Xapian::Error::get_description(), GlassTable::get_flags(), get_next_revision_number(), GlassSpellingTable::is_modified(), GlassSynonymTable::is_modified(), GlassTable::is_modified(), GlassValueManager::is_modified(), LOGCALL_VOID, modifications_failed(), position_table, postlist_table, GlassTable::set_changes(), GlassVersion::set_changes(), set_revision_number(), spelling_table, GlassChanges::start(), synonym_table, termlist_table, value_manager, and version_file.

Referenced by GlassWritableDatabase::apply().

◆ cancel()

void GlassDatabase::cancel ( )
privatevirtual

◆ close()

void GlassDatabase::close ( )
privatevirtual

◆ compact()

void GlassDatabase::compact ( Xapian::Compactor compactor,
const char *  destdir,
int  fd,
const std::vector< Xapian::Database::Internal * > &  sources,
const std::vector< Xapian::docid > &  offset,
size_t  block_size,
Xapian::Compactor::compaction_level  compaction,
unsigned  flags,
Xapian::docid  last_docid 
)
static

◆ create_and_open_tables()

void GlassDatabase::create_and_open_tables ( int  flags,
unsigned int  blocksize 
)
private

◆ database_exists()

bool GlassDatabase::database_exists ( )
private

Return true if a database exists at the path specified for this database.

Definition at line 187 of file glass_database.cc.

References GlassTable::exists(), LOGCALL, postlist_table, and RETURN.

Referenced by create_and_open_tables(), get_database_write_lock(), and GlassDatabase().

◆ get_backend_info()

int GlassDatabase::get_backend_info ( string *  path) const
inlinevirtual

Get backend information about this database.

Parameters
pathIf non-NULL, and set the pointed to string to the file path of this database (or if to some string describing the database in a backend-specified format if "path" isn't a concept which make sense).
Returns
A constant indicating the backend type.

Implements Xapian::Database::Internal.

Definition at line 304 of file glass_database.h.

References BACKEND_GLASS, and db_dir.

◆ get_changeset_revisions()

void GlassDatabase::get_changeset_revisions ( const string &  path,
glass_revision_number_t startrev,
glass_revision_number_t endrev 
) const
private

Get the revision stored in a changeset.

Definition at line 290 of file glass_database.cc.

References CHANGES_MAGIC_STRING, CHANGES_VERSION, CONST_STRLEN, io_read(), O_CLOEXEC, posixy_open, REASONABLE_CHANGESET_SIZE, and unpack_uint().

Referenced by write_changesets_to_fd().

◆ get_database_write_lock()

void GlassDatabase::get_database_write_lock ( int  flags,
bool  creating 
)
private

Get a write lock on the database, or throw an Xapian::DatabaseLockError if failure.

Parameters
flagsBit-wise or of zero or more Xapian::DB_* constants
creatingtrue if the database is in the process of being created - if false, will throw a DatabaseOpening error if the lock can't be acquired and the database doesn't exist.

Definition at line 416 of file glass_database.cc.

References database_exists(), db_dir, Xapian::DB_RETRY_LOCK, FlintLock::lock(), lock, LOGCALL_VOID, FlintLock::SUCCESS, FlintLock::throw_databaselockerror(), and FlintLock::UNKNOWN.

Referenced by GlassDatabase().

◆ get_doccount()

Xapian::doccount GlassDatabase::get_doccount ( ) const
virtual

Virtual methods of Database::Internal.

Implements Xapian::Database::Internal.

Definition at line 713 of file glass_database.cc.

References GlassVersion::get_doccount(), LOGCALL, RETURN, and version_file.

Referenced by GlassTermList::accumulate_stats(), open_post_list(), and GlassWritableDatabase::open_post_list().

◆ get_doclength()

Xapian::termcount GlassDatabase::get_doclength ( Xapian::docid  did) const
virtual

Get the length of a given document.

Document length, for the purposes of Xapian, is defined to be the number of instances of terms within a document. Expressed differently, the sum of the within document frequencies over all the terms in the document.

Parameters
didThe document id of the document whose length is being requested.

Implements Xapian::Database::Internal.

Reimplemented in GlassWritableDatabase.

Definition at line 734 of file glass_database.cc.

References Assert, GlassPostListTable::get_doclength(), LOGCALL, postlist_table, and RETURN.

Referenced by GlassPostList::get_doclength(), GlassWritableDatabase::get_doclength(), and open_document().

◆ get_doclength_lower_bound()

Xapian::termcount GlassDatabase::get_doclength_lower_bound ( ) const
virtual

Get a lower bound on the length of a document in this DB.

This bound does not include any zero-length documents.

Reimplemented from Xapian::Database::Internal.

Definition at line 783 of file glass_database.cc.

References GlassVersion::get_doclength_lower_bound(), and version_file.

◆ get_doclength_upper_bound()

Xapian::termcount GlassDatabase::get_doclength_upper_bound ( ) const
virtual

Get an upper bound on the length of a document in this DB.

Reimplemented from Xapian::Database::Internal.

Definition at line 789 of file glass_database.cc.

References GlassVersion::get_doclength_upper_bound(), and version_file.

◆ get_freqs()

void GlassDatabase::get_freqs ( const string &  term,
Xapian::doccount termfreq_ptr,
Xapian::termcount collfreq_ptr 
) const
virtual

Returns frequencies for a term.

Parameters
termThe term to get frequencies for
termfreq_ptrPoint to return number of docs indexed by term (or NULL not to return)
collfreq_ptrPoint to return number of occurrences of term in the database (or NULL not to return)

Implements Xapian::Database::Internal.

Reimplemented in GlassWritableDatabase.

Definition at line 752 of file glass_database.cc.

References Assert, GlassPostListTable::get_freqs(), LOGCALL_VOID, and postlist_table.

Referenced by GlassWritableDatabase::get_freqs(), and GlassTermList::get_termfreq().

◆ get_lastdocid()

Xapian::docid GlassDatabase::get_lastdocid ( ) const
virtual

Return the last used document id of this (sub) database.

Implements Xapian::Database::Internal.

Definition at line 720 of file glass_database.cc.

References GlassVersion::get_last_docid(), LOGCALL, RETURN, and version_file.

◆ get_metadata()

string GlassDatabase::get_metadata ( const string &  key) const
virtual

Get the metadata associated with a given key.

See Database::get_metadata() for more information.

Reimplemented from Xapian::Database::Internal.

Definition at line 942 of file glass_database.cc.

References GlassTable::get_exact_entry(), LOGCALL, postlist_table, and RETURN.

◆ get_next_revision_number()

glass_revision_number_t GlassDatabase::get_next_revision_number ( ) const
private

Get an object holding the next revision number which should be used in the tables.

Returns
the next revision number.

Definition at line 280 of file glass_database.cc.

References GlassVersion::get_revision(), LOGCALL, RETURN, and version_file.

Referenced by apply().

◆ get_postlist_cursor()

GlassCursor* GlassDatabase::get_postlist_cursor ( ) const
inline

Get a postlist table cursor (used by GlassValueList).

Definition at line 237 of file glass_database.h.

References GlassTable::cursor_get(), and postlist_table.

◆ get_revision_info()

string GlassDatabase::get_revision_info ( ) const
virtual

Get a string describing the current revision of the database.

Reimplemented from Xapian::Database::Internal.

Definition at line 963 of file glass_database.cc.

References get_revision_number(), LOGCALL, pack_uint(), and RETURN.

◆ get_revision_number()

glass_revision_number_t GlassDatabase::get_revision_number ( ) const

Get an object holding the revision number which the tables are opened at.

Returns
the current revision number.

Definition at line 273 of file glass_database.cc.

References GlassVersion::get_revision(), LOGCALL, RETURN, and version_file.

Referenced by get_revision_info(), send_whole_database(), and write_changesets_to_fd().

◆ get_spelling_frequency()

Xapian::doccount GlassDatabase::get_spelling_frequency ( const string &  word) const
virtual

Return the number of times word was added as a spelling.

Reimplemented from Xapian::Database::Internal.

Definition at line 921 of file glass_database.cc.

References GlassSpellingTable::get_word_frequency(), and spelling_table.

◆ get_total_length()

Xapian::totallength GlassDatabase::get_total_length ( ) const
virtual

Return the total length of all documents in this database.

Implements Xapian::Database::Internal.

Definition at line 727 of file glass_database.cc.

References GlassVersion::get_total_doclen(), LOGCALL, RETURN, and version_file.

◆ get_unique_terms()

Xapian::termcount GlassDatabase::get_unique_terms ( Xapian::docid  did) const
virtual

Get the number of unique term in document.

Parameters
didThe document id of the document whose number of terms is being requested.

Implements Xapian::Database::Internal.

Reimplemented in GlassWritableDatabase.

Definition at line 743 of file glass_database.cc.

References Assert, GlassTermList, LOGCALL, and RETURN.

Referenced by GlassPostList::get_unique_terms(), and GlassWritableDatabase::get_unique_terms().

◆ get_used_docid_range()

void GlassDatabase::get_used_docid_range ( Xapian::docid first,
Xapian::docid last 
) const
virtual

Find lowest and highest docids actually in use.

Only used by compaction, so only needs to be implemented by backends which support compaction.

Reimplemented from Xapian::Database::Internal.

Definition at line 989 of file glass_database.cc.

References GlassVersion::get_doccount(), GlassVersion::get_last_docid(), GlassPostListTable::get_used_docid_range(), postlist_table, and version_file.

◆ get_uuid()

string GlassDatabase::get_uuid ( ) const
virtual

Get a UUID for the database.

The UUID will persist for the lifetime of the database.

Replicas (eg, made with the replication protocol, or by copying all the database files) will have the same UUID. However, copies (made with copydatabase, or xapian-compact) will have different UUIDs.

If the backend does not support UUIDs the empty string is returned.

Reimplemented from Xapian::Database::Internal.

Definition at line 972 of file glass_database.cc.

References GlassVersion::get_uuid_string(), LOGCALL, RETURN, and version_file.

Referenced by send_whole_database(), and write_changesets_to_fd().

◆ get_value_freq()

Xapian::doccount GlassDatabase::get_value_freq ( Xapian::valueno  slot) const
virtual

Return the frequency of a given value slot.

This is the number of documents which have a (non-empty) value stored in the slot.

Parameters
slotThe value slot to examine.

Implements Xapian::Database::Internal.

Reimplemented in GlassWritableDatabase.

Definition at line 762 of file glass_database.cc.

References GlassValueManager::get_value_freq(), LOGCALL, RETURN, and value_manager.

Referenced by GlassWritableDatabase::get_value_freq().

◆ get_value_lower_bound()

std::string GlassDatabase::get_value_lower_bound ( Xapian::valueno  slot) const
virtual

Get a lower bound on the values stored in the given value slot.

If there are no values stored in the given value slot, this will return an empty string.

Parameters
slotThe value slot to examine.

Implements Xapian::Database::Internal.

Reimplemented in GlassWritableDatabase.

Definition at line 769 of file glass_database.cc.

References GlassValueManager::get_value_lower_bound(), LOGCALL, RETURN, and value_manager.

Referenced by GlassWritableDatabase::get_value_lower_bound().

◆ get_value_upper_bound()

std::string GlassDatabase::get_value_upper_bound ( Xapian::valueno  slot) const
virtual

Get an upper bound on the values stored in the given value slot.

If there are no values stored in the given value slot, this will return an empty string.

Parameters
slotThe value slot to examine.

Implements Xapian::Database::Internal.

Reimplemented in GlassWritableDatabase.

Definition at line 776 of file glass_database.cc.

References GlassValueManager::get_value_upper_bound(), LOGCALL, RETURN, and value_manager.

Referenced by GlassWritableDatabase::get_value_upper_bound().

◆ get_wdf_upper_bound()

Xapian::termcount GlassDatabase::get_wdf_upper_bound ( const string &  term) const
virtual

Get an upper bound on the wdf of term term.

Reimplemented from Xapian::Database::Internal.

Definition at line 795 of file glass_database.cc.

References Assert, GlassPostListTable::get_freqs(), GlassVersion::get_wdf_upper_bound(), postlist_table, and version_file.

◆ has_positions()

bool GlassDatabase::has_positions ( ) const
virtual

Check whether this database contains any positional information.

Implements Xapian::Database::Internal.

Reimplemented in GlassWritableDatabase.

Definition at line 812 of file glass_database.cc.

References GlassTable::empty(), and position_table.

◆ has_uncommitted_changes()

bool GlassDatabase::has_uncommitted_changes ( ) const
virtual

Return true if there are uncommitted changes.

Reimplemented in GlassWritableDatabase.

Definition at line 1002 of file glass_database.cc.

◆ locked()

bool GlassDatabase::locked ( ) const
virtual

Return true if the database is open for writing.

If this is a WritableDatabase, always returns true.

For a Database, test if there's a writer holding the lock (or if we can't test for a lock without taking it on the current platform, throw Xapian::UnimplementedError).

Reimplemented from Xapian::Database::Internal.

Definition at line 1008 of file glass_database.cc.

References lock, and FlintLock::test().

◆ modifications_failed()

void GlassDatabase::modifications_failed ( glass_revision_number_t  new_revision,
const std::string &  msg 
)
private

◆ open_allterms()

TermList * GlassDatabase::open_allterms ( const string &  prefix) const
virtual

Open an allterms list.

This is a list of all the terms in the database

Parameters
prefixThe prefix to restrict the terms to.
Returns
A pointer to the newly created allterms list. This object must be deleted by the caller after use.

Implements Xapian::Database::Internal.

Reimplemented in GlassWritableDatabase.

Definition at line 898 of file glass_database.cc.

References GlassAllTermsList, LOGCALL, and RETURN.

Referenced by GlassWritableDatabase::open_allterms().

◆ open_document()

Xapian::Document::Internal * GlassDatabase::open_document ( Xapian::docid  did,
bool  lazy 
) const
virtual

Open a document.

This is used to access the values and data associated with a document. See class Xapian::Document::Internal for further details.

Parameters
didThe document id which is being requested.
lazyNo need to check that this document actually exists. Used when we already know that this document exists (only a hint - the backend may still check).
Returns
A pointer to the newly created document object. This object must be deleted by the caller after use.

Implements Xapian::Database::Internal.

Reimplemented in GlassWritableDatabase.

Definition at line 854 of file glass_database.cc.

References Assert, docdata_table, get_doclength(), LOGCALL, RETURN, and value_manager.

Referenced by GlassWritableDatabase::open_document().

◆ open_metadata_keylist()

TermList * GlassDatabase::open_metadata_keylist ( const std::string &  prefix) const
virtual

Open a termlist returning each metadata key.

Only metadata keys which are associated with a non-empty value will be returned.

Parameters
prefixIf non-empty, only keys with this prefix are returned.

Reimplemented from Xapian::Database::Internal.

Definition at line 953 of file glass_database.cc.

References GlassTable::cursor_get(), LOGCALL, postlist_table, and RETURN.

◆ open_position_list()

PositionList * GlassDatabase::open_position_list ( Xapian::docid  did,
const string &  tname 
) const
virtual

Open a position list for the given term in the given document.

Parameters
didThe document id for which a position list is being requested.
tnameThe term for which a position list is being requested.
Returns
A pointer to the newly created position list. This object must be deleted by the caller after use.

Implements Xapian::Database::Internal.

Reimplemented in GlassWritableDatabase.

Definition at line 883 of file glass_database.cc.

References Assert, and position_table.

Referenced by GlassPostList::open_position_list(), and GlassTermList::positionlist_begin().

◆ open_post_list()

LeafPostList * GlassDatabase::open_post_list ( const string &  tname) const
virtual

Open a posting list.

Method defined by subclass to open a posting list. This is a list of all the documents which contain a given term.

Parameters
tnameThe term whose posting list is being requested.
Returns
A pointer to the newly created posting list. If the term doesn't exist, a LeafPostList object returning no documents is returned, which makes it easier to implement a search over multiple databases. This object must be deleted by the caller after use.

Implements Xapian::Database::Internal.

Reimplemented in GlassWritableDatabase.

Definition at line 818 of file glass_database.cc.

References get_doccount(), GlassVersion::get_last_docid(), GlassAllDocsPostList, GlassPostList, LOGCALL, RETURN, and version_file.

◆ open_spelling_termlist()

TermList * GlassDatabase::open_spelling_termlist ( const string &  word) const
virtual

Create a termlist tree from trigrams of word.

You can assume word.size() > 1.

If there are no trigrams, returns NULL.

Reimplemented from Xapian::Database::Internal.

Definition at line 906 of file glass_database.cc.

References GlassSpellingTable::open_termlist(), and spelling_table.

◆ open_spelling_wordlist()

TermList * GlassDatabase::open_spelling_wordlist ( ) const
virtual

Return a termlist which returns the words which are spelling correction targets.

If there are no spelling correction targets, returns NULL.

Reimplemented from Xapian::Database::Internal.

Reimplemented in GlassWritableDatabase.

Definition at line 912 of file glass_database.cc.

References GlassTable::cursor_get(), and spelling_table.

Referenced by GlassWritableDatabase::open_spelling_wordlist().

◆ open_synonym_keylist()

TermList * GlassDatabase::open_synonym_keylist ( const string &  prefix) const
virtual

Open a termlist returning each term which has synonyms.

Parameters
prefixIf non-empty, only terms with this prefix are returned.

Reimplemented from Xapian::Database::Internal.

Reimplemented in GlassWritableDatabase.

Definition at line 933 of file glass_database.cc.

References GlassTable::cursor_get(), and synonym_table.

Referenced by GlassWritableDatabase::open_synonym_keylist().

◆ open_synonym_termlist()

TermList * GlassDatabase::open_synonym_termlist ( const string &  term) const
virtual

Open a termlist returning synonyms for a term.

If term has no synonyms, returns NULL.

Reimplemented from Xapian::Database::Internal.

Definition at line 927 of file glass_database.cc.

References GlassSynonymTable::open_termlist(), and synonym_table.

◆ open_tables()

bool GlassDatabase::open_tables ( int  flags)
private

◆ open_term_list()

TermList * GlassDatabase::open_term_list ( Xapian::docid  did) const
virtual

Open a term list.

This is a list of all the terms contained by a given document.

Parameters
didThe document id whose term list is being requested.
Returns
A pointer to the newly created term list. This object must be deleted by the caller after use.

Implements Xapian::Database::Internal.

Definition at line 843 of file glass_database.cc.

References Assert, GlassTermList, GlassTable::is_open(), LOGCALL, RETURN, termlist_table, and throw_termlist_table_close_exception().

◆ open_value_list()

ValueList * GlassDatabase::open_value_list ( Xapian::valueno  slot) const
virtual

Open a value stream.

This returns the value in a particular slot for each document.

Parameters
slotThe value slot.
Returns
Pointer to a new ValueList object which should be deleted by the caller once it is no longer needed.

Reimplemented from Xapian::Database::Internal.

Reimplemented in GlassWritableDatabase.

Definition at line 835 of file glass_database.cc.

References LOGCALL, and RETURN.

Referenced by GlassWritableDatabase::open_value_list().

◆ positionlist_count()

Xapian::termcount GlassDatabase::positionlist_count ( Xapian::docid  did,
const string &  term 
) const
virtual

◆ read_position_list()

void GlassDatabase::read_position_list ( GlassPositionList pos_list,
Xapian::docid  did,
const string &  term 
) const
virtual

◆ readahead_for_query()

void GlassDatabase::readahead_for_query ( const Xapian::Query query)
virtual

◆ reopen()

bool GlassDatabase::reopen ( )
privatevirtual

Re-open tables to recover from an overwritten condition, or just get most up-to-date version.

Reimplemented from Xapian::Database::Internal.

Definition at line 395 of file glass_database.cc.

References GlassTable::get_flags(), LOGCALL, open_tables(), postlist_table, readonly, and RETURN.

Referenced by write_changesets_to_fd().

◆ request_document()

void GlassDatabase::request_document ( Xapian::docid  ) const
virtual

Request and later collect a document from the database.

Multiple documents can be requested with request_document(), and then collected with collect_document(). Allows the backend to optimise (e.g. the remote backend can start requests for all the documents so they fetch in parallel).

If a backend doesn't support this, request_document() can be a no-op and collect_document() the same as open_document().

Reimplemented from Xapian::Database::Internal.

Definition at line 378 of file glass_database.cc.

References docdata_table, and GlassDocDataTable::readahead_for_document().

◆ send_whole_database()

void GlassDatabase::send_whole_database ( RemoteConnection conn,
double  end_time 
)
private

◆ set_revision_number()

void GlassDatabase::set_revision_number ( int  flags,
glass_revision_number_t  new_revision 
)
private

Set the revision number in the tables.

This updates the disk tables so that the currently open revision becomes the specified revision number.

Parameters
new_revisionThe new revision number to store. This must be greater than the current revision number. FIXME: If we support rewinding to a previous revision, maybe this needs to be greater than any previously used revision.

Definition at line 332 of file glass_database.cc.

References changes, GlassChanges::commit(), GlassTable::commit(), Glass::DOCDATA, docdata_table, GlassSpellingTable::flush_db(), GlassSynonymTable::flush_db(), GlassTable::flush_db(), GlassVersion::get_revision(), LOGCALL_VOID, GlassValueManager::merge_changes(), Glass::POSITION, position_table, Glass::POSTLIST, postlist_table, GlassVersion::root_to_set(), GlassVersion::set_spelling_wordfreq_upper_bound(), Glass::SPELLING, spelling_table, Xapian::Internal::str(), GlassTable::sync(), GlassVersion::sync(), Glass::SYNONYM, synonym_table, Glass::TERMLIST, termlist_table, value_manager, version_file, and GlassVersion::write().

Referenced by apply(), and modifications_failed().

◆ single_file()

bool GlassDatabase::single_file ( ) const
inline

Definition at line 309 of file glass_database.h.

References GlassVersion::single_file(), and version_file.

Referenced by compact().

◆ term_exists()

bool GlassDatabase::term_exists ( const string &  tname) const
virtual

Check whether a given term is in the database.

Parameters
tnameThe term whose presence is being checked.

Implements Xapian::Database::Internal.

Reimplemented in GlassWritableDatabase.

Definition at line 804 of file glass_database.cc.

References Assert, LOGCALL, postlist_table, RETURN, and GlassPostListTable::term_exists().

◆ throw_termlist_table_close_exception()

void GlassDatabase::throw_termlist_table_close_exception ( ) const

◆ write_changesets_to_fd()

void GlassDatabase::write_changesets_to_fd ( int  fd,
const string &  start_revision,
bool  need_whole_db,
Xapian::ReplicationInfo info 
)
virtual

Friends And Related Function Documentation

◆ GlassAllDocsPostList

friend class GlassAllDocsPostList
friend

Definition at line 63 of file glass_database.h.

Referenced by open_post_list(), and GlassWritableDatabase::open_post_list().

◆ GlassAllTermsList

friend class GlassAllTermsList
friend

Definition at line 62 of file glass_database.h.

Referenced by open_allterms().

◆ GlassPostList

friend class GlassPostList
friend

Definition at line 61 of file glass_database.h.

Referenced by open_post_list(), and GlassWritableDatabase::open_post_list().

◆ GlassTermList

friend class GlassTermList
friend

Definition at line 60 of file glass_database.h.

Referenced by get_unique_terms(), and open_term_list().

◆ GlassWritableDatabase

friend class GlassWritableDatabase
friend

Definition at line 59 of file glass_database.h.

Member Data Documentation

◆ changes

GlassChanges GlassDatabase::changes
private

◆ db_dir

std::string GlassDatabase::db_dir
private

Directory to store databases in.

Definition at line 68 of file glass_database.h.

Referenced by get_backend_info(), get_database_write_lock(), GlassDatabase(), send_whole_database(), and write_changesets_to_fd().

◆ docdata_table

GlassDocDataTable GlassDatabase::docdata_table
private

◆ lock

FlintLock GlassDatabase::lock
private

Lock object.

Definition at line 112 of file glass_database.h.

Referenced by close(), get_database_write_lock(), and locked().

◆ position_table

GlassPositionListTable GlassDatabase::position_table
mutableprivate

◆ postlist_table

GlassPostListTable GlassDatabase::postlist_table
mutableprivate

◆ readonly

bool GlassDatabase::readonly
private

Whether the database is readonly.

Definition at line 72 of file glass_database.h.

Referenced by GlassDatabase(), open_tables(), and reopen().

◆ spelling_table

GlassSpellingTable GlassDatabase::spelling_table
mutableprivate

◆ synonym_table

GlassSynonymTable GlassDatabase::synonym_table
mutableprivate

◆ termlist_table

GlassTermListTable GlassDatabase::termlist_table
private

◆ value_manager

GlassValueManager GlassDatabase::value_manager
mutableprivate

◆ version_file

GlassVersion GlassDatabase::version_file
private

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