xapian-core  2.0.0
Public Types | Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes | Private Member Functions | Friends | List of all members
Xapian::Database::Internal Class Referenceabstract

Virtual base class for Database internals. More...

#include <databaseinternal.h>

+ Inheritance diagram for Xapian::Database::Internal:
+ Collaboration diagram for Xapian::Database::Internal:

Public Types

typedef Xapian::doccount size_type
 

Public Member Functions

virtual ~Internal ()
 We have virtual methods and want to be able to delete derived classes using a pointer to the base class, so we need a virtual destructor. More...
 
virtual size_type size () const
 
virtual void keep_alive ()
 
virtual void readahead_for_query (const Query &query) const
 
virtual doccount get_doccount () const =0
 
virtual docid get_lastdocid () const =0
 Return the last used document id of this (sub) database. More...
 
virtual totallength get_total_length () const =0
 Return the total length of all documents in this database. More...
 
virtual termcount get_doclength (docid did) const =0
 
virtual termcount get_unique_terms (docid did) const =0
 Get the number of unique terms in document. More...
 
virtual termcount get_wdfdocmax (docid did) const =0
 Get the max wdf in document. More...
 
virtual void get_freqs (std::string_view term, doccount *termfreq_ptr, termcount *collfreq_ptr) const =0
 Returns frequencies for a term. More...
 
virtual doccount get_value_freq (valueno slot) const =0
 Return the frequency of a given value slot. More...
 
virtual std::string get_value_lower_bound (valueno slot) const =0
 Get a lower bound on the values stored in the given value slot. More...
 
virtual std::string get_value_upper_bound (valueno slot) const =0
 Get an upper bound on the values stored in the given value slot. More...
 
virtual termcount get_doclength_lower_bound () const =0
 Get a lower bound on the length of a document in this DB. More...
 
virtual termcount get_doclength_upper_bound () const =0
 Get an upper bound on the length of a document in this DB. More...
 
virtual termcount get_wdf_upper_bound (std::string_view term) const =0
 Get an upper bound on the wdf of term term. More...
 
virtual termcount get_unique_terms_lower_bound () const
 Get a lower bound on the unique terms size of a document in this DB. More...
 
virtual termcount get_unique_terms_upper_bound () const
 Get an upper bound on the unique terms size of a document in this DB. More...
 
virtual bool term_exists (std::string_view term) const =0
 
virtual bool has_positions () const =0
 Check whether this database contains any positional information. More...
 
virtual PostListopen_post_list (std::string_view term) const =0
 Return a PostList suitable for use in a PostingIterator. More...
 
virtual LeafPostListopen_leaf_post_list (std::string_view term, bool need_read_pos) const =0
 Create a LeafPostList for use during a match. More...
 
virtual ValueListopen_value_list (valueno slot) const
 Open a value stream. More...
 
virtual TermListopen_term_list (docid did) const =0
 
virtual TermListopen_term_list_direct (docid did) const =0
 Like open_term_list() but without MultiTermList wrapper. More...
 
virtual TermListopen_allterms (std::string_view prefix) const =0
 
virtual PositionListopen_position_list (docid did, std::string_view term) const =0
 
virtual Document::Internalopen_document (docid did, bool lazy) const =0
 Open a handle on a document. More...
 
virtual TermListopen_spelling_termlist (std::string_view word) const
 Create a termlist tree from trigrams of word. More...
 
virtual TermListopen_spelling_wordlist () const
 Return a termlist which returns the words which are spelling correction targets. More...
 
virtual doccount get_spelling_frequency (std::string_view word) const
 Return the number of times word was added as a spelling. More...
 
virtual void add_spelling (std::string_view word, termcount freqinc) const
 Add a word to the spelling dictionary. More...
 
virtual termcount remove_spelling (std::string_view word, termcount freqdec) const
 Remove a word from the spelling dictionary. More...
 
virtual TermListopen_synonym_termlist (std::string_view term) const
 Open a termlist returning synonyms for a term. More...
 
virtual TermListopen_synonym_keylist (std::string_view prefix) const
 Open a termlist returning each term which has synonyms. More...
 
virtual void add_synonym (std::string_view term, std::string_view synonym) const
 Add a synonym for a term. More...
 
virtual void remove_synonym (std::string_view term, std::string_view synonym) const
 Remove a synonym for a term. More...
 
virtual void clear_synonyms (std::string_view term) const
 Clear all synonyms for a term. More...
 
virtual std::string get_metadata (std::string_view key) const
 Get the metadata associated with a given key. More...
 
virtual TermListopen_metadata_keylist (std::string_view prefix) const
 Open a termlist returning each metadata key. More...
 
virtual void set_metadata (std::string_view key, std::string_view value)
 Set the metadata associated with a given key. More...
 
virtual bool reopen ()
 Reopen the database to the latest available revision. More...
 
virtual void close ()=0
 Close the database. More...
 
virtual void commit ()
 Commit pending modifications to the database. More...
 
virtual void cancel ()
 Cancel pending modifications to the database. More...
 
virtual void begin_transaction (bool flushed)
 Begin transaction. More...
 
virtual void end_transaction (bool do_commit)
 End transaction. More...
 
virtual docid add_document (const Document &document)
 
virtual void delete_document (docid did)
 
virtual void delete_document (std::string_view unique_term)
 Delete any documents indexed by a term from the database. More...
 
virtual void replace_document (docid did, const Document &document)
 
virtual docid replace_document (std::string_view unique_term, const Document &document)
 Replace any documents matching a term. More...
 
virtual void request_document (docid did) const
 Request a document. More...
 
virtual void write_changesets_to_fd (int fd, std::string_view start_revision, bool need_whole_db, ReplicationInfo *info)
 Write a set of changesets to a file descriptor. More...
 
virtual Xapian::rev get_revision () const
 Get revision number of database (if meaningful). More...
 
virtual std::string get_uuid () const
 Get a UUID for the database. More...
 
virtual void invalidate_doc_object (Document::Internal *obj) const
 Notify the database that document is no longer valid. More...
 
virtual int get_backend_info (std::string *path) const =0
 Get backend information about this database. More...
 
virtual void get_used_docid_range (docid &first, docid &last) const
 Find lowest and highest docids actually in use. More...
 
virtual bool locked () const
 Return true if the database is open for writing. More...
 
virtual Internalupdate_lock (int flags)
 Lock a read-only database for writing or unlock a writable database. More...
 
virtual std::string reconstruct_text (Xapian::docid did, size_t length, std::string_view prefix, Xapian::termpos start_pos, Xapian::termpos end_pos) const
 
virtual std::string get_description () const =0
 Return a string describing this object. More...
 
- Public Member Functions inherited from Xapian::Internal::intrusive_base
 intrusive_base ()
 Construct with no references. More...
 

Protected Types

enum  transaction_state {
  TRANSACTION_READONLY = -2 , TRANSACTION_UNIMPLEMENTED = -1 , TRANSACTION_NONE = 0 , TRANSACTION_UNFLUSHED = 1 ,
  TRANSACTION_FLUSHED = 2
}
 Transaction state enum. More...
 

Protected Member Functions

 Internal (transaction_state transaction_support)
 Only constructable as a base class for derived classes. More...
 
bool is_read_only () const
 Test if this shard is read-only. More...
 
bool transaction_active () const
 Test if a transaction is currently active. More...
 
void dtor_called ()
 Helper to process uncommitted changes when a writable db is destroyed. More...
 

Protected Attributes

transaction_state state
 Current transaction state. More...
 

Private Member Functions

Internaloperator= (const Internal &)=delete
 Don't allow assignment. More...
 
 Internal (const Internal &)=delete
 Don't allow copying. More...
 
void dtor_called_ ()
 The "action required" helper for the dtor_called() helper. More...
 

Friends

class Database
 

Additional Inherited Members

- Public Attributes inherited from Xapian::Internal::intrusive_base
unsigned _refs
 Reference count. More...
 

Detailed Description

Virtual base class for Database internals.

Definition at line 58 of file databaseinternal.h.

Member Typedef Documentation

◆ size_type

Definition at line 126 of file databaseinternal.h.

Member Enumeration Documentation

◆ transaction_state

Transaction state enum.

Enumerator
TRANSACTION_READONLY 
TRANSACTION_UNIMPLEMENTED 
TRANSACTION_NONE 
TRANSACTION_UNFLUSHED 
TRANSACTION_FLUSHED 

Definition at line 72 of file databaseinternal.h.

Constructor & Destructor Documentation

◆ Internal() [1/2]

Xapian::Database::Internal::Internal ( const Internal )
privatedelete

Don't allow copying.

◆ Internal() [2/2]

Xapian::Database::Internal::Internal ( transaction_state  transaction_support)
inlineprotected

Only constructable as a base class for derived classes.

Parameters
transaction_supportOne of:
  • TRANSACTION_READONLY - read-only shard
  • TRANSACTION_UNIMPLEMENTED - writable but no transaction support
  • TRANSACTION_NONE - writable with transaction support

Definition at line 87 of file databaseinternal.h.

◆ ~Internal()

virtual Xapian::Database::Internal::~Internal ( )
inlinevirtual

We have virtual methods and want to be able to delete derived classes using a pointer to the base class, so we need a virtual destructor.

Definition at line 124 of file databaseinternal.h.

Member Function Documentation

◆ add_document()

Xapian::docid Xapian::Database::Internal::add_document ( const Document document)
virtual

◆ add_spelling()

void Xapian::Database::Internal::add_spelling ( std::string_view  word,
Xapian::termcount  freqinc 
) const
virtual

Add a word to the spelling dictionary.

If the word is already present, its frequency is increased.

Parameters
wordThe word to add.
freqincHow much to increase its frequency by.

Reimplemented in RemoteDatabase, MultiDatabase, HoneyDatabase, GlassWritableDatabase, and EmptyDatabase.

Definition at line 307 of file databaseinternal.cc.

◆ add_synonym()

void Xapian::Database::Internal::add_synonym ( std::string_view  term,
std::string_view  synonym 
) const
virtual

Add a synonym for a term.

If synonym is already a synonym for term, then no action is taken.

Reimplemented in RemoteDatabase, GlassWritableDatabase, MultiDatabase, HoneyDatabase, and EmptyDatabase.

Definition at line 337 of file databaseinternal.cc.

◆ begin_transaction()

void Xapian::Database::Internal::begin_transaction ( bool  flushed)
virtual

Begin transaction.

Reimplemented in MultiDatabase, and EmptyDatabase.

Definition at line 117 of file databaseinternal.cc.

References invalid_operation().

◆ cancel()

void Xapian::Database::Internal::cancel ( )
virtual

Cancel pending modifications to the database.

Reimplemented in RemoteDatabase, MultiDatabase, InMemoryDatabase, GlassWritableDatabase, GlassDatabase, and EmptyDatabase.

Definition at line 109 of file databaseinternal.cc.

References invalid_operation().

◆ clear_synonyms()

void Xapian::Database::Internal::clear_synonyms ( std::string_view  term) const
virtual

Clear all synonyms for a term.

If term has no synonyms, no action is taken.

Reimplemented in RemoteDatabase, GlassWritableDatabase, MultiDatabase, HoneyDatabase, and EmptyDatabase.

Definition at line 349 of file databaseinternal.cc.

◆ close()

virtual void Xapian::Database::Internal::close ( )
pure virtual

◆ commit()

void Xapian::Database::Internal::commit ( )
virtual

Commit pending modifications to the database.

Reimplemented in RemoteDatabase, MultiDatabase, InMemoryDatabase, GlassWritableDatabase, and EmptyDatabase.

Definition at line 101 of file databaseinternal.cc.

References invalid_operation().

◆ delete_document() [1/2]

void Xapian::Database::Internal::delete_document ( Xapian::docid  did)
virtual

◆ delete_document() [2/2]

void Xapian::Database::Internal::delete_document ( std::string_view  unique_term)
virtual

Delete any documents indexed by a term from the database.

Reimplemented in RemoteDatabase, MultiDatabase, and EmptyDatabase.

Definition at line 191 of file databaseinternal.cc.

References invalid_operation().

◆ dtor_called()

void Xapian::Database::Internal::dtor_called ( )
inlineprotected

Helper to process uncommitted changes when a writable db is destroyed.

The destructor of a derived writable database class needs to call this method - we can't call it from our own destructor because we need to be able to call methods in the derived class, but that's no longer valid by the time our destructor runs, as that happens after the destructor of the derived class has run.

If a transaction is active, it is cancelled. Otherwise we attempt to commit uncommitted changes, but because it is not safe to throw exceptions from destructors, this method will catch and discard any exceptions.

Definition at line 114 of file databaseinternal.h.

References dtor_called_(), and state.

Referenced by GlassWritableDatabase::~GlassWritableDatabase(), and InMemoryDatabase::~InMemoryDatabase().

◆ dtor_called_()

void Xapian::Database::Internal::dtor_called_ ( )
private

The "action required" helper for the dtor_called() helper.

Definition at line 83 of file databaseinternal.cc.

References AssertEq.

Referenced by dtor_called().

◆ end_transaction()

void Xapian::Database::Internal::end_transaction ( bool  do_commit)
virtual

End transaction.

Parameters
do_commitIf true, commits the transaction; if false, cancels the transaction.

Reimplemented in MultiDatabase.

Definition at line 141 of file databaseinternal.cc.

References invalid_operation().

Referenced by RemoteDatabase::do_close().

◆ get_backend_info()

virtual int Xapian::Database::Internal::get_backend_info ( std::string *  path) const
pure virtual

Get backend information about this database.

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

Implemented in GlassDatabase, RemoteDatabase, MultiDatabase, InMemoryDatabase, HoneyDatabase, and EmptyDatabase.

Referenced by backend_mismatch().

◆ get_description()

virtual std::string Xapian::Database::Internal::get_description ( ) const
pure virtual

Return a string describing this object.

Implemented in RemoteDatabase, MultiDatabase, InMemoryDatabase, HoneyDatabase, GlassDatabase, and EmptyDatabase.

◆ get_doccount()

virtual doccount Xapian::Database::Internal::get_doccount ( ) const
pure virtual

◆ get_doclength()

virtual termcount Xapian::Database::Internal::get_doclength ( docid  did) const
pure virtual

◆ get_doclength_lower_bound()

virtual termcount Xapian::Database::Internal::get_doclength_lower_bound ( ) const
pure virtual

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

This bound does not include any zero-length documents.

Implemented in RemoteDatabase, MultiDatabase, InMemoryDatabase, HoneyDatabase, GlassDatabase, and EmptyDatabase.

Referenced by Xapian::Weight::Internal::accumulate_stats(), and Xapian::Weight::init_().

◆ get_doclength_upper_bound()

virtual termcount Xapian::Database::Internal::get_doclength_upper_bound ( ) const
pure virtual

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

Implemented in RemoteDatabase, MultiDatabase, InMemoryDatabase, HoneyDatabase, GlassDatabase, and EmptyDatabase.

Referenced by Xapian::Weight::Internal::accumulate_stats(), and Xapian::Weight::init_().

◆ get_freqs()

virtual void Xapian::Database::Internal::get_freqs ( std::string_view  term,
doccount termfreq_ptr,
termcount collfreq_ptr 
) const
pure 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)

Implemented in MultiDatabase, EmptyDatabase, RemoteDatabase, InMemoryDatabase, HoneyDatabase, GlassWritableDatabase, and GlassDatabase.

Referenced by Xapian::Weight::Internal::accumulate_stats(), MultiTermList::get_termfreq(), and LocalSubMatch::register_lazy_postlist_for_stats().

◆ get_lastdocid()

virtual docid Xapian::Database::Internal::get_lastdocid ( ) const
pure virtual

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

Implemented in RemoteDatabase, MultiDatabase, InMemoryDatabase, HoneyDatabase, GlassDatabase, and EmptyDatabase.

◆ get_metadata()

string Xapian::Database::Internal::get_metadata ( std::string_view  key) const
virtual

Get the metadata associated with a given key.

See Database::get_metadata() for more information.

Reimplemented in RemoteDatabase, MultiDatabase, InMemoryDatabase, HoneyDatabase, GlassDatabase, and EmptyDatabase.

Definition at line 355 of file databaseinternal.cc.

◆ get_revision()

Xapian::rev Xapian::Database::Internal::get_revision ( ) const
virtual

Get revision number of database (if meaningful).

Reimplemented in MultiDatabase, HoneyDatabase, GlassDatabase, and EmptyDatabase.

Definition at line 396 of file databaseinternal.cc.

◆ get_spelling_frequency()

Xapian::doccount Xapian::Database::Internal::get_spelling_frequency ( std::string_view  word) const
virtual

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

Reimplemented in MultiDatabase, HoneyDatabase, GlassDatabase, and EmptyDatabase.

Definition at line 298 of file databaseinternal.cc.

◆ get_total_length()

virtual totallength Xapian::Database::Internal::get_total_length ( ) const
pure virtual

Return the total length of all documents in this database.

Implemented in RemoteDatabase, MultiDatabase, InMemoryDatabase, HoneyDatabase, GlassDatabase, and EmptyDatabase.

Referenced by Xapian::Weight::Internal::accumulate_stats().

◆ get_unique_terms()

virtual termcount Xapian::Database::Internal::get_unique_terms ( docid  did) const
pure virtual

Get the number of unique terms in document.

Parameters
didThe document id of the document to return this value for.

Implemented in RemoteDatabase, MultiDatabase, InMemoryDatabase, HoneyDatabase, GlassWritableDatabase, GlassDatabase, and EmptyDatabase.

Referenced by PostListTree::get_doc_stats().

◆ get_unique_terms_lower_bound()

Xapian::termcount Xapian::Database::Internal::get_unique_terms_lower_bound ( ) const
virtual

Get a lower bound on the unique terms size of a document in this DB.

Reimplemented in MultiDatabase, HoneyDatabase, and GlassDatabase.

Definition at line 69 of file databaseinternal.cc.

Referenced by Xapian::Weight::Internal::accumulate_stats(), and Xapian::Weight::init_().

◆ get_unique_terms_upper_bound()

Xapian::termcount Xapian::Database::Internal::get_unique_terms_upper_bound ( ) const
virtual

Get an upper bound on the unique terms size of a document in this DB.

Reimplemented in MultiDatabase, and HoneyDatabase.

Definition at line 75 of file databaseinternal.cc.

Referenced by Xapian::Weight::Internal::accumulate_stats(), and Xapian::Weight::init_().

◆ get_used_docid_range()

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

Find lowest and highest docids actually in use.

Used during local matching and compaction, so only needs to be implemented by backends which support one or both of these.

For example, EmptyDatabase, MultiDatabase and RemoteDatabase don't need to implement this (empty shards are skipped early by the matcher; sharded databases are handled explicitly by the matcher rather than via the "multi" backend; matching for remote shards runs as a local match on the remote).

Reimplemented in InMemoryDatabase, HoneyDatabase, and GlassDatabase.

Definition at line 414 of file databaseinternal.cc.

Referenced by LocalSubMatch::resolve().

◆ get_uuid()

string Xapian::Database::Internal::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 in RemoteDatabase, MultiDatabase, HoneyDatabase, and GlassDatabase.

Definition at line 402 of file databaseinternal.cc.

◆ get_value_freq()

virtual doccount Xapian::Database::Internal::get_value_freq ( valueno  slot) const
pure 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.

Implemented in RemoteDatabase, MultiDatabase, InMemoryDatabase, HoneyDatabase, GlassWritableDatabase, GlassDatabase, and EmptyDatabase.

Referenced by Xapian::Internal::QueryValueRange::postlist(), Xapian::Internal::QueryValueLE::postlist(), and Xapian::Internal::QueryValueGE::postlist().

◆ get_value_lower_bound()

virtual std::string Xapian::Database::Internal::get_value_lower_bound ( valueno  slot) const
pure 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.

Implemented in RemoteDatabase, MultiDatabase, InMemoryDatabase, HoneyDatabase, GlassWritableDatabase, GlassDatabase, and EmptyDatabase.

Referenced by Xapian::Internal::QueryValueRange::postlist(), Xapian::Internal::QueryValueLE::postlist(), and Xapian::Internal::QueryValueGE::postlist().

◆ get_value_upper_bound()

virtual std::string Xapian::Database::Internal::get_value_upper_bound ( valueno  slot) const
pure 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.

Implemented in RemoteDatabase, MultiDatabase, InMemoryDatabase, HoneyDatabase, GlassWritableDatabase, GlassDatabase, and EmptyDatabase.

Referenced by Xapian::Internal::QueryValueRange::postlist(), Xapian::Internal::QueryValueLE::postlist(), and Xapian::Internal::QueryValueGE::postlist().

◆ get_wdf_upper_bound()

virtual termcount Xapian::Database::Internal::get_wdf_upper_bound ( std::string_view  term) const
pure virtual

Get an upper bound on the wdf of term term.

Implemented in RemoteDatabase, MultiDatabase, InMemoryDatabase, HoneyDatabase, GlassDatabase, and EmptyDatabase.

◆ get_wdfdocmax()

virtual termcount Xapian::Database::Internal::get_wdfdocmax ( docid  did) const
pure virtual

Get the max wdf in document.

Parameters
didThe document id of the document to return this value for.

Implemented in RemoteDatabase, MultiDatabase, InMemoryDatabase, HoneyDatabase, GlassDatabase, and EmptyDatabase.

Referenced by PostListTree::get_doc_stats().

◆ has_positions()

virtual bool Xapian::Database::Internal::has_positions ( ) const
pure virtual

◆ invalidate_doc_object()

void Xapian::Database::Internal::invalidate_doc_object ( Document::Internal obj) const
virtual

Notify the database that document is no longer valid.

This is used to invalidate references to a document kept by a database for doing lazy updates. If we moved to using a weak_ptr instead we wouldn't need a special method for this, but it would involve a fair bit of reorganising of other parts of the code.

Reimplemented in MultiDatabase, GlassWritableDatabase, and EmptyDatabase.

Definition at line 408 of file databaseinternal.cc.

◆ is_read_only()

bool Xapian::Database::Internal::is_read_only ( ) const
inlineprotected

Test if this shard is read-only.

Definition at line 94 of file databaseinternal.h.

References state, and TRANSACTION_READONLY.

Referenced by Xapian::Database::add_database_(), and RemoteDatabase::do_close().

◆ keep_alive()

void Xapian::Database::Internal::keep_alive ( )
virtual

Reimplemented in RemoteDatabase, and MultiDatabase.

Definition at line 58 of file databaseinternal.cc.

◆ locked()

bool Xapian::Database::Internal::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 in RemoteDatabase, MultiDatabase, InMemoryDatabase, and GlassDatabase.

Definition at line 421 of file databaseinternal.cc.

◆ open_allterms()

virtual TermList* Xapian::Database::Internal::open_allterms ( std::string_view  prefix) const
pure virtual

◆ open_document()

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

Open a handle on a document.

The returned handle provides access to document data and document values.

Parameters
didThe document id to open.
lazyIf true, there's no need to check that this document actually exists (only a hint - the backend may still check). Used to avoid unnecessary work when we already know that the requested document exists.
Returns
A new document object, owned by the caller.

Implemented in RemoteDatabase, MultiDatabase, InMemoryDatabase, HoneyDatabase, GlassWritableDatabase, GlassDatabase, and EmptyDatabase.

Referenced by Xapian::Database::get_document().

◆ open_leaf_post_list()

virtual LeafPostList* Xapian::Database::Internal::open_leaf_post_list ( std::string_view  term,
bool  need_read_pos 
) const
pure virtual

Create a LeafPostList for use during a match.

Parameters
termThe term to open a postlist for, or the empty string to create an all-docs postlist.
need_read_posDoes the postlist need to support read_position_list()? Note that open_position_list() may still be called even if need_read_pos is false.

Implemented in RemoteDatabase, MultiDatabase, InMemoryDatabase, HoneyDatabase, GlassWritableDatabase, GlassDatabase, and EmptyDatabase.

◆ open_metadata_keylist()

TermList * Xapian::Database::Internal::open_metadata_keylist ( std::string_view  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 in RemoteDatabase, MultiDatabase, InMemoryDatabase, HoneyDatabase, GlassDatabase, and EmptyDatabase.

Definition at line 361 of file databaseinternal.cc.

Referenced by Xapian::Database::metadata_keys_begin().

◆ open_position_list()

virtual PositionList* Xapian::Database::Internal::open_position_list ( docid  did,
std::string_view  term 
) const
pure virtual

◆ open_post_list()

virtual PostList* Xapian::Database::Internal::open_post_list ( std::string_view  term) const
pure virtual

◆ open_spelling_termlist()

TermList * Xapian::Database::Internal::open_spelling_termlist ( std::string_view  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 in MultiDatabase, HoneyDatabase, GlassDatabase, and EmptyDatabase.

Definition at line 280 of file databaseinternal.cc.

Referenced by Xapian::Database::get_spelling_suggestion().

◆ open_spelling_wordlist()

TermList * Xapian::Database::Internal::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 in MultiDatabase, HoneyDatabase, GlassWritableDatabase, GlassDatabase, and EmptyDatabase.

Definition at line 289 of file databaseinternal.cc.

Referenced by Xapian::Database::spellings_begin().

◆ open_synonym_keylist()

TermList * Xapian::Database::Internal::open_synonym_keylist ( std::string_view  prefix) const
virtual

Open a termlist returning each term which has synonyms.

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

Reimplemented in RemoteDatabase, MultiDatabase, HoneyDatabase, GlassWritableDatabase, GlassDatabase, and EmptyDatabase.

Definition at line 328 of file databaseinternal.cc.

Referenced by Xapian::Database::synonym_keys_begin().

◆ open_synonym_termlist()

TermList * Xapian::Database::Internal::open_synonym_termlist ( std::string_view  term) const
virtual

Open a termlist returning synonyms for a term.

If term has no synonyms, returns NULL.

Reimplemented in RemoteDatabase, MultiDatabase, HoneyDatabase, GlassDatabase, and EmptyDatabase.

Definition at line 319 of file databaseinternal.cc.

Referenced by Xapian::Database::synonyms_begin().

◆ open_term_list()

virtual TermList* Xapian::Database::Internal::open_term_list ( docid  did) const
pure virtual

◆ open_term_list_direct()

virtual TermList* Xapian::Database::Internal::open_term_list_direct ( docid  did) const
pure virtual

Like open_term_list() but without MultiTermList wrapper.

MultiDatabase::open_term_list() wraps the returns TermList in a MultiTermList, but we don't want that for query expansion.

Implemented in RemoteDatabase, MultiDatabase, InMemoryDatabase, HoneyDatabase, GlassDatabase, and EmptyDatabase.

◆ open_value_list()

ValueList * Xapian::Database::Internal::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 in MultiDatabase, HoneyDatabase, GlassWritableDatabase, GlassDatabase, and EmptyDatabase.

Definition at line 274 of file databaseinternal.cc.

Referenced by Xapian::Database::valuestream_begin().

◆ operator=()

Internal& Xapian::Database::Internal::operator= ( const Internal )
privatedelete

Don't allow assignment.

◆ readahead_for_query()

void Xapian::Database::Internal::readahead_for_query ( const Query query) const
virtual

Reimplemented in HoneyDatabase, and GlassDatabase.

Definition at line 64 of file databaseinternal.cc.

◆ reconstruct_text()

string Xapian::Database::Internal::reconstruct_text ( Xapian::docid  did,
size_t  length,
std::string_view  prefix,
Xapian::termpos  start_pos,
Xapian::termpos  end_pos 
) const
virtual

◆ remove_spelling()

Xapian::termcount Xapian::Database::Internal::remove_spelling ( std::string_view  word,
Xapian::termcount  freqdec 
) const
virtual

Remove a word from the spelling dictionary.

The word's frequency is decreased, and if would become zero or less then the word is removed completely.

Parameters
wordThe word to remove.
freqdecHow much to decrease its frequency by.
Returns
Any freqdec not "used up".

Reimplemented in RemoteDatabase, MultiDatabase, HoneyDatabase, GlassWritableDatabase, and EmptyDatabase.

Definition at line 313 of file databaseinternal.cc.

◆ remove_synonym()

void Xapian::Database::Internal::remove_synonym ( std::string_view  term,
std::string_view  synonym 
) const
virtual

Remove a synonym for a term.

If synonym isn't a synonym for term, then no action is taken.

Reimplemented in RemoteDatabase, GlassWritableDatabase, MultiDatabase, HoneyDatabase, and EmptyDatabase.

Definition at line 343 of file databaseinternal.cc.

◆ reopen()

bool Xapian::Database::Internal::reopen ( )
virtual

Reopen the database to the latest available revision.

Database backends which don't support simultaneous update and reading probably don't need to do anything here.

Reimplemented in RemoteDatabase, MultiDatabase, InMemoryDatabase, HoneyDatabase, and GlassDatabase.

Definition at line 375 of file databaseinternal.cc.

◆ replace_document() [1/2]

void Xapian::Database::Internal::replace_document ( Xapian::docid  did,
const Document document 
)
virtual

◆ replace_document() [2/2]

Xapian::docid Xapian::Database::Internal::replace_document ( std::string_view  unique_term,
const Document document 
)
virtual

Replace any documents matching a term.

Reimplemented in RemoteDatabase, MultiDatabase, and EmptyDatabase.

Definition at line 235 of file databaseinternal.cc.

References invalid_operation().

◆ request_document()

void Xapian::Database::Internal::request_document ( Xapian::docid  did) const
virtual

Request a document.

This tells the database that we're going to want a particular document soon. It's just a hint which the backend may ignore, but for glass it issues a preread hint on the file with the document data in, and for the remote backend it might cause the document to be fetched asynchronously (this isn't currently implemented though).

It can be called for multiple documents in turn, and a common usage pattern would be to iterate over an MSet and request the documents, then iterate over it again to actually get and display them.

The default implementation is a no-op.

Reimplemented in GlassDatabase, RemoteDatabase, MultiDatabase, and HoneyDatabase.

Definition at line 384 of file databaseinternal.cc.

◆ set_metadata()

void Xapian::Database::Internal::set_metadata ( std::string_view  key,
std::string_view  value 
)
virtual

Set the metadata associated with a given key.

See WritableDatabase::set_metadata() for more information.

Reimplemented in RemoteDatabase, MultiDatabase, InMemoryDatabase, HoneyDatabase, GlassWritableDatabase, and EmptyDatabase.

Definition at line 369 of file databaseinternal.cc.

◆ size()

Database::Internal::size_type Xapian::Database::Internal::size ( ) const
virtual

Reimplemented in MultiDatabase, and EmptyDatabase.

Definition at line 52 of file databaseinternal.cc.

Referenced by Xapian::Database::add_database_().

◆ term_exists()

virtual bool Xapian::Database::Internal::term_exists ( std::string_view  term) const
pure virtual

◆ transaction_active()

bool Xapian::Database::Internal::transaction_active ( ) const
inlineprotected

Test if a transaction is currently active.

Definition at line 99 of file databaseinternal.h.

References state.

Referenced by GlassWritableDatabase::check_flush_threshold(), GlassWritableDatabase::close(), GlassWritableDatabase::commit(), and RemoteDatabase::do_close().

◆ update_lock()

Database::Internal * Xapian::Database::Internal::update_lock ( int  flags)
virtual

Lock a read-only database for writing or unlock a writable database.

This is the internal method behind Database::lock() and Database::unlock().

In the unlocking case, the writable database is closed. In the locking case, the read-only database is left open.

Parameters
flagsXapian::DB_READONLY_ to unlock, otherwise the flags to use when opening from writing.
Returns
The new Database::Internal object (or the current object if no action is required - e.g. unlock on a read-only database).

Reimplemented in InMemoryDatabase, GlassWritableDatabase, and GlassDatabase.

Definition at line 427 of file databaseinternal.cc.

Referenced by Xapian::Database::lock(), and Xapian::Database::unlock().

◆ write_changesets_to_fd()

void Xapian::Database::Internal::write_changesets_to_fd ( int  fd,
std::string_view  start_revision,
bool  need_whole_db,
ReplicationInfo info 
)
virtual

Write a set of changesets to a file descriptor.

This call may reopen the database, leaving it pointing to a more recent version of the database.

Reimplemented in MultiDatabase, GlassDatabase, and EmptyDatabase.

Definition at line 389 of file databaseinternal.cc.

Friends And Related Function Documentation

◆ Database

friend class Database
friend

Definition at line 59 of file databaseinternal.h.

Member Data Documentation

◆ state

transaction_state Xapian::Database::Internal::state
protected

Current transaction state.

Definition at line 91 of file databaseinternal.h.

Referenced by dtor_called(), is_read_only(), and transaction_active().


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