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

RemoteDatabase is the baseclass for remote database implementations. More...

#include <remote-database.h>

+ Inheritance diagram for RemoteDatabase:
+ Collaboration diagram for RemoteDatabase:

Public Types

typedef Xapian::Internal::opt_intrusive_ptr< Xapian::MatchSpyopt_ptr_spy
 
- Public Types inherited from Xapian::Database::Internal
typedef Xapian::doccount size_type
 

Public Member Functions

Xapian::termcount positionlist_count (Xapian::docid did, std::string_view term) const
 Get the length of the position list. More...
 
void keep_alive ()
 Send a keep-alive message. More...
 
void set_query (const Xapian::Query &query, Xapian::termcount qlen, Xapian::valueno collapse_key, Xapian::doccount collapse_max, Xapian::Enquire::docid_order order, Xapian::valueno sort_key, Xapian::Enquire::Internal::sort_setting sort_by, bool sort_value_forward, double time_limit, int percent_threshold, double weight_threshold, const Xapian::Weight &wtscheme, const Xapian::RSet &omrset, const std::vector< opt_ptr_spy > &matchspies) const
 Set the query. More...
 
int get_read_fd () const
 Get the underlying fd this remote connection reads from. More...
 
void accumulate_remote_stats (Xapian::Weight::Internal &total) const
 Accumulate stats from the remote server. More...
 
void send_global_stats (Xapian::doccount first, Xapian::doccount maxitems, Xapian::doccount check_at_least, const Xapian::KeyMaker *sorter, const Xapian::Weight::Internal &stats) const
 Send the global stats to the remote server. More...
 
Xapian::MSet get_mset (const std::vector< opt_ptr_spy > &matchspies) const
 Get the MSet from the remote server. More...
 
TermListopen_metadata_keylist (std::string_view prefix) const
 Get remote metadata key list. More...
 
TermListopen_term_list (Xapian::docid did) const
 Get remote termlist. More...
 
TermListopen_term_list_direct (Xapian::docid did) const
 Like open_term_list() but without MultiTermList wrapper. More...
 
TermListopen_allterms (std::string_view prefix) const
 Iterate all terms. More...
 
bool has_positions () const
 Check whether this database contains any positional information. More...
 
bool reopen ()
 Reopen the database to the latest available revision. More...
 
void close ()
 Close the database. More...
 
PostListopen_post_list (std::string_view term) const
 Return a PostList suitable for use in a PostingIterator. More...
 
LeafPostListopen_leaf_post_list (std::string_view term, bool) const
 Create a LeafPostList for use during a match. More...
 
Xapian::doccount read_post_list (const std::string &term, NetworkPostList &pl) const
 
PositionListopen_position_list (Xapian::docid did, std::string_view tname) const
 
Xapian::Document::Internalopen_document (Xapian::docid did, bool lazy) const
 Get a remote document. More...
 
Xapian::doccount get_doccount () const
 Get the document count. More...
 
Xapian::docid get_lastdocid () const
 Get the last used docid. 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
 
Xapian::termcount get_unique_terms (Xapian::docid did) const
 Get the number of unique terms in document. More...
 
Xapian::termcount get_wdfdocmax (Xapian::docid did) const
 Get the max wdf in document. More...
 
bool term_exists (std::string_view term) const
 Check if term exists. More...
 
void get_freqs (std::string_view term, Xapian::doccount *termfreq_ptr, Xapian::termcount *collfreq_ptr) const
 Returns frequencies for a term. More...
 
void read_value_stats (Xapian::valueno slot) const
 Read the value statistics for a value from a remote database. 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 (std::string_view term) const
 Get an upper bound on the wdf of term term. More...
 
void commit ()
 Commit pending modifications to the database. More...
 
void cancel ()
 Cancel pending modifications to the database. More...
 
Xapian::docid add_document (const Xapian::Document &doc)
 
void delete_document (Xapian::docid did)
 
void delete_document (std::string_view unique_term)
 Delete any documents indexed by a term from the database. More...
 
void replace_document (Xapian::docid did, const Xapian::Document &doc)
 
Xapian::docid replace_document (std::string_view unique_term, const Xapian::Document &document)
 Replace any documents matching a term. More...
 
std::string get_uuid () const
 Get a UUID for the database. More...
 
std::string get_metadata (std::string_view key) const
 Get the metadata associated with a given key. More...
 
void set_metadata (std::string_view key, std::string_view value)
 Set the metadata associated with a given key. More...
 
void request_document (Xapian::docid did) const
 Request a document. More...
 
void add_spelling (std::string_view word, Xapian::termcount freqinc) const
 Add a word to the spelling dictionary. More...
 
TermListopen_synonym_termlist (std::string_view term) const
 Open a termlist returning synonyms for a term. More...
 
TermListopen_synonym_keylist (std::string_view prefix) const
 Open a termlist returning each term which has synonyms. More...
 
void add_synonym (std::string_view word, std::string_view synonym) const
 Add a synonym for a term. More...
 
void remove_synonym (std::string_view word, std::string_view synonym) const
 Remove a synonym for a term. More...
 
void clear_synonyms (std::string_view word) const
 Clear all synonyms for a term. More...
 
Xapian::termcount remove_spelling (std::string_view word, Xapian::termcount freqdec) const
 Remove a word from the spelling dictionary. More...
 
int get_backend_info (std::string *path) const
 Get backend information about this database. More...
 
bool locked () const
 Return true if the database is open for writing. More...
 
std::string reconstruct_text (Xapian::docid did, size_t length, std::string_view prefix, Xapian::termpos start_pos, Xapian::termpos end_pos) const
 
std::string get_description () const
 Return a string describing this object. More...
 
- Public Member Functions inherited from Xapian::Database::Internal
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 readahead_for_query (const Query &query) const
 
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 ValueListopen_value_list (valueno slot) const
 Open a value stream. 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 begin_transaction (bool flushed)
 Begin transaction. More...
 
virtual void end_transaction (bool do_commit)
 End transaction. 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 void invalidate_doc_object (Document::Internal *obj) const
 Notify the database that document is no longer valid. More...
 
virtual void get_used_docid_range (docid &first, docid &last) const
 Find lowest and highest docids actually in use. More...
 
virtual Internalupdate_lock (int flags)
 Lock a read-only database for writing or unlock a writable database. More...
 
- Public Member Functions inherited from Xapian::Internal::intrusive_base
 intrusive_base ()
 Construct with no references. More...
 

Protected Member Functions

 RemoteDatabase (std::pair< int, std::string > fd_and_context, double timeout_, bool writable, int flags)
 Constructor. More...
 
reply_type get_message (std::string &message, reply_type required_type, reply_type required_type2) const
 Receive a message from the server. More...
 
void get_message (std::string &message, reply_type required_type) const
 
bool get_message_or_done (std::string &message, reply_type required_type) const
 
void send_message (message_type type, std::string_view data) const
 Send a message to the server. More...
 
void do_close ()
 Close the socket. More...
 
bool get_posting (Xapian::docid &did, double &w, std::string &value)
 
- Protected Member Functions inherited from Xapian::Database::Internal
 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

double timeout
 The timeout value used in network communications, in seconds. More...
 
- Protected Attributes inherited from Xapian::Database::Internal
transaction_state state
 Current transaction state. More...
 

Private Member Functions

void operator= (const RemoteDatabase &)
 Don't allow assignment. More...
 
 RemoteDatabase (const RemoteDatabase &)
 Don't allow copying. More...
 
bool update_stats (message_type msg_code=MSG_UPDATE, const std::string &body=std::string()) const
 

Private Attributes

OwnedRemoteConnection link
 The object which does the I/O. More...
 
Xapian::doccount doccount
 The remote document count, given at open. More...
 
Xapian::docid lastdocid
 The remote last docid, given at open. 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::totallength total_length
 The total length of all documents in this database. More...
 
bool has_positional_info
 Has positional information? More...
 
bool pending_reply = false
 Are we currently expecting a reply? More...
 
std::string uuid
 The UUID of the remote database. More...
 
bool cached_stats_valid
 
ValueStats mru_valstats
 The most recently used value statistics. More...
 
Xapian::valueno mru_slot
 The value slot for the most recently used value statistics. More...
 
bool uncommitted_changes = false
 True if there are (or may be) uncommitted changes. More...
 

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_state {
  TRANSACTION_READONLY = -2 , TRANSACTION_UNIMPLEMENTED = -1 , TRANSACTION_NONE = 0 , TRANSACTION_UNFLUSHED = 1 ,
  TRANSACTION_FLUSHED = 2
}
 Transaction state enum. More...
 

Detailed Description

RemoteDatabase is the baseclass for remote database implementations.

A subclass of this class is required which opens a TCP connection or pipe to the remote database server. This subclass works in combination with the RemoteSubMatch class during the match process.

Definition at line 47 of file remote-database.h.

Member Typedef Documentation

◆ opt_ptr_spy

Definition at line 171 of file remote-database.h.

Constructor & Destructor Documentation

◆ RemoteDatabase() [1/2]

RemoteDatabase::RemoteDatabase ( const RemoteDatabase )
private

Don't allow copying.

◆ RemoteDatabase() [2/2]

RemoteDatabase::RemoteDatabase ( std::pair< int, std::string >  fd_and_context,
double  timeout_,
bool  writable,
int  flags 
)
protected

Constructor.

The constructor is protected so that raw instances can't be created - a derived class must be instantiated which has code in the constructor to open the socket.

Parameters
fd_and_contextA std::pair containing the file descriptor for the connection to the server and a context string to return with any error messages. (These are passed together so the caller can return them from a single helper function easily).
timeout_The timeout used with the network operations. Generally a Xapian::NetworkTimeoutError exception will be thrown if the remote end doesn't respond for this length of time (in seconds). A timeout of 0 means that operations will never timeout.
writableIs this a WritableDatabase?
flagsXapian::DB_RETRY_LOCK or 0.

Member Function Documentation

◆ accumulate_remote_stats()

void RemoteDatabase::accumulate_remote_stats ( Xapian::Weight::Internal total) const

Accumulate stats from the remote server.

Definition at line 727 of file remote-database.cc.

References get_message(), p, REPLY_STATS, and unserialise_stats().

Referenced by RemoteSubMatch::prepare_match().

◆ add_document()

Xapian::docid RemoteDatabase::add_document ( const Xapian::Document doc)
virtual

◆ add_spelling()

void RemoteDatabase::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 from Xapian::Database::Internal.

Definition at line 939 of file remote-database.cc.

References get_message(), MSG_ADDSPELLING, pack_uint(), REPLY_DONE, send_message(), and uncommitted_changes.

◆ add_synonym()

void RemoteDatabase::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 from Xapian::Database::Internal.

Definition at line 993 of file remote-database.cc.

References get_message(), MSG_ADDSYNONYM, pack_string(), REPLY_DONE, send_message(), and uncommitted_changes.

◆ cancel()

void RemoteDatabase::cancel ( )
virtual

Cancel pending modifications to the database.

Reimplemented from Xapian::Database::Internal.

Definition at line 797 of file remote-database.cc.

References Xapian::BAD_VALUENO, cached_stats_valid, dummy, get_message(), mru_slot, MSG_CANCEL, REPLY_DONE, send_message(), and uncommitted_changes.

◆ clear_synonyms()

void RemoteDatabase::clear_synonyms ( std::string_view  term) const
virtual

Clear all synonyms for a term.

If term has no synonyms, no action is taken.

Reimplemented from Xapian::Database::Internal.

Definition at line 1017 of file remote-database.cc.

References get_message(), MSG_CLEARSYNONYMS, REPLY_DONE, send_message(), and uncommitted_changes.

◆ close()

void RemoteDatabase::close ( )
virtual

Close the database.

Implements Xapian::Database::Internal.

Definition at line 286 of file remote-database.cc.

References do_close().

◆ commit()

void RemoteDatabase::commit ( )
virtual

Commit pending modifications to the database.

Reimplemented from Xapian::Database::Internal.

Definition at line 783 of file remote-database.cc.

References get_message(), MSG_COMMIT, REPLY_DONE, send_message(), and uncommitted_changes.

Referenced by do_close().

◆ delete_document() [1/2]

void RemoteDatabase::delete_document ( std::string_view  unique_term)
virtual

Delete any documents indexed by a term from the database.

Reimplemented from Xapian::Database::Internal.

Definition at line 847 of file remote-database.cc.

References Xapian::BAD_VALUENO, cached_stats_valid, dummy, get_message(), mru_slot, MSG_DELETEDOCUMENTTERM, REPLY_DONE, send_message(), and uncommitted_changes.

◆ delete_document() [2/2]

void RemoteDatabase::delete_document ( Xapian::docid  did)
virtual

◆ do_close()

void RemoteDatabase::do_close ( )
protected

◆ get_backend_info()

int RemoteDatabase::get_backend_info ( std::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 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.

Implements Xapian::Database::Internal.

Definition at line 324 of file remote-database.h.

References BACKEND_REMOTE, RemoteConnection::get_context(), and link.

◆ get_description()

string RemoteDatabase::get_description ( ) const
virtual

Return a string describing this object.

Implements Xapian::Database::Internal.

Definition at line 1052 of file remote-database.cc.

References RemoteConnection::get_context(), and link.

◆ get_doccount()

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

Get the document count.

Implements Xapian::Database::Internal.

Definition at line 402 of file remote-database.cc.

References cached_stats_valid, doccount, and update_stats().

Referenced by term_exists().

◆ get_doclength()

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

◆ get_doclength_lower_bound()

Xapian::termcount RemoteDatabase::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.

Implements Xapian::Database::Internal.

Definition at line 519 of file remote-database.cc.

References doclen_lbound.

◆ get_doclength_upper_bound()

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

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

Implements Xapian::Database::Internal.

Definition at line 525 of file remote-database.cc.

References doclen_ubound.

◆ get_freqs()

void RemoteDatabase::get_freqs ( std::string_view  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.

Definition at line 437 of file remote-database.cc.

References Assert, RemoteConnection::get_context(), get_message(), link, MSG_COLLFREQ, MSG_FREQS, MSG_TERMFREQ, p, REPLY_COLLFREQ, REPLY_FREQS, REPLY_TERMFREQ, send_message(), term, unpack_uint(), and unpack_uint_last().

◆ get_lastdocid()

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

Get the last used docid.

Implements Xapian::Database::Internal.

Definition at line 409 of file remote-database.cc.

References cached_stats_valid, lastdocid, and update_stats().

◆ get_message() [1/2]

void RemoteDatabase::get_message ( std::string &  message,
reply_type  required_type 
) const
inlineprotected

Definition at line 139 of file remote-database.h.

References get_message().

◆ get_message() [2/2]

reply_type RemoteDatabase::get_message ( std::string &  message,
reply_type  required_type,
reply_type  required_type2 
) const
protected

◆ get_message_or_done()

bool RemoteDatabase::get_message_or_done ( std::string &  message,
reply_type  required_type 
) const
inlineprotected

Definition at line 144 of file remote-database.h.

References get_message(), and REPLY_DONE.

Referenced by open_document(), and update_stats().

◆ get_metadata()

string RemoteDatabase::get_metadata ( std::string_view  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 907 of file remote-database.cc.

References get_message(), MSG_GETMETADATA, REPLY_METADATA, and send_message().

◆ get_mset()

Xapian::MSet RemoteDatabase::get_mset ( const std::vector< opt_ptr_spy > &  matchspies) const

Get the MSet from the remote server.

Definition at line 763 of file remote-database.cc.

References get_message(), Xapian::MSet::internal, p, REPLY_RESULTS, and unpack_string().

Referenced by RemoteSubMatch::get_mset().

◆ get_posting()

bool RemoteDatabase::get_posting ( Xapian::docid did,
double &  w,
std::string &  value 
)
protected

◆ get_read_fd()

int RemoteDatabase::get_read_fd ( ) const
inline

Get the underlying fd this remote connection reads from.

This allows the matcher to efficiently wait for remote databases to be ready in parallel using poll() or select().

Definition at line 212 of file remote-database.h.

References RemoteConnection::get_read_fd(), and link.

Referenced by RemoteSubMatch::get_read_fd().

◆ get_total_length()

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

Return the total length of all documents in this database.

Implements Xapian::Database::Internal.

Definition at line 416 of file remote-database.cc.

References cached_stats_valid, total_length, and update_stats().

◆ get_unique_terms()

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

Get the number of unique terms in document.

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

Implements Xapian::Database::Internal.

Definition at line 559 of file remote-database.cc.

References Assert, RemoteConnection::get_context(), get_message(), link, MSG_UNIQUETERMS, p, pack_uint_last(), REPLY_UNIQUETERMS, send_message(), and unpack_uint_last().

◆ get_uuid()

string RemoteDatabase::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 901 of file remote-database.cc.

References uuid.

◆ get_value_freq()

Xapian::doccount RemoteDatabase::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.

Definition at line 498 of file remote-database.cc.

References ValueStats::freq, mru_valstats, and read_value_stats().

◆ get_value_lower_bound()

std::string RemoteDatabase::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.

Definition at line 505 of file remote-database.cc.

References ValueStats::lower_bound, mru_valstats, and read_value_stats().

◆ get_value_upper_bound()

std::string RemoteDatabase::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.

Definition at line 512 of file remote-database.cc.

References mru_valstats, read_value_stats(), and ValueStats::upper_bound.

◆ get_wdf_upper_bound()

Xapian::termcount RemoteDatabase::get_wdf_upper_bound ( std::string_view  term) const
virtual

Get an upper bound on the wdf of term term.

Implements Xapian::Database::Internal.

Definition at line 531 of file remote-database.cc.

References doclen_ubound.

◆ get_wdfdocmax()

Xapian::termcount RemoteDatabase::get_wdfdocmax ( Xapian::docid  did) const
virtual

Get the max wdf in document.

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

Implements Xapian::Database::Internal.

Definition at line 577 of file remote-database.cc.

References Assert, RemoteConnection::get_context(), get_message(), link, MSG_WDFDOCMAX, p, pack_uint_last(), REPLY_WDFDOCMAX, send_message(), and unpack_uint_last().

◆ has_positions()

bool RemoteDatabase::has_positions ( ) const
virtual

Check whether this database contains any positional information.

Implements Xapian::Database::Internal.

Definition at line 272 of file remote-database.cc.

References cached_stats_valid, has_positional_info, and update_stats().

◆ keep_alive()

void RemoteDatabase::keep_alive ( )
virtual

Send a keep-alive message.

Reimplemented from Xapian::Database::Internal.

Definition at line 143 of file remote-database.cc.

References get_message(), MSG_KEEPALIVE, REPLY_DONE, and send_message().

◆ locked()

bool RemoteDatabase::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 1027 of file remote-database.cc.

◆ open_allterms()

TermList * RemoteDatabase::open_allterms ( std::string_view  prefix) const
virtual

Iterate all terms.

Implements Xapian::Database::Internal.

Definition at line 193 of file remote-database.cc.

References get_message(), MSG_ALLTERMS, REPLY_ALLTERMS, and send_message().

◆ open_document()

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

◆ open_leaf_post_list()

LeafPostList * RemoteDatabase::open_leaf_post_list ( std::string_view  term,
bool  need_read_pos 
) const
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.

Implements Xapian::Database::Internal.

Definition at line 235 of file remote-database.cc.

References Assert.

◆ open_metadata_keylist()

TermList * RemoteDatabase::open_metadata_keylist ( std::string_view  prefix) const
virtual

Get remote metadata key list.

Reimplemented from Xapian::Database::Internal.

Definition at line 151 of file remote-database.cc.

References get_message(), MSG_METADATAKEYLIST, REPLY_METADATAKEYLIST, and send_message().

◆ open_position_list()

PositionList * RemoteDatabase::open_position_list ( Xapian::docid  did,
std::string_view  tname 
) const
virtual

◆ open_post_list()

PostList * RemoteDatabase::open_post_list ( std::string_view  term) const
virtual

◆ open_synonym_keylist()

TermList * RemoteDatabase::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 from Xapian::Database::Internal.

Definition at line 984 of file remote-database.cc.

References get_message(), MSG_SYNONYMKEYLIST, REPLY_SYNONYMKEYLIST, and send_message().

◆ open_synonym_termlist()

TermList * RemoteDatabase::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 from Xapian::Database::Internal.

Definition at line 975 of file remote-database.cc.

References get_message(), MSG_SYNONYMTERMLIST, REPLY_SYNONYMTERMLIST, and send_message().

◆ open_term_list()

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

◆ open_term_list_direct()

TermList * RemoteDatabase::open_term_list_direct ( Xapian::docid  did) const
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.

Implements Xapian::Database::Internal.

Definition at line 187 of file remote-database.cc.

References open_term_list().

◆ operator=()

void RemoteDatabase::operator= ( const RemoteDatabase )
private

Don't allow assignment.

◆ positionlist_count()

Xapian::termcount RemoteDatabase::positionlist_count ( Xapian::docid  did,
std::string_view  term 
) const

◆ read_post_list()

Xapian::doccount RemoteDatabase::read_post_list ( const std::string &  term,
NetworkPostList pl 
) const

◆ read_value_stats()

void RemoteDatabase::read_value_stats ( Xapian::valueno  slot) const

◆ reconstruct_text()

string RemoteDatabase::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 RemoteDatabase::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 from Xapian::Database::Internal.

Definition at line 953 of file remote-database.cc.

References RemoteConnection::get_context(), get_message(), link, MSG_REMOVESPELLING, p, pack_uint(), REPLY_REMOVESPELLING, send_message(), uncommitted_changes, and unpack_uint_last().

◆ remove_synonym()

void RemoteDatabase::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 from Xapian::Database::Internal.

Definition at line 1005 of file remote-database.cc.

References get_message(), MSG_REMOVESYNONYM, pack_string(), REPLY_DONE, send_message(), and uncommitted_changes.

◆ reopen()

bool RemoteDatabase::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 from Xapian::Database::Internal.

Definition at line 279 of file remote-database.cc.

References Xapian::BAD_VALUENO, mru_slot, MSG_REOPEN, and update_stats().

◆ replace_document() [1/2]

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

◆ replace_document() [2/2]

void RemoteDatabase::replace_document ( Xapian::docid  did,
const Xapian::Document doc 
)
virtual

◆ request_document()

void RemoteDatabase::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 from Xapian::Database::Internal.

Definition at line 929 of file remote-database.cc.

References get_message(), MSG_REQUESTDOCUMENT, pack_uint(), REPLY_DONE, and send_message().

◆ send_global_stats()

void RemoteDatabase::send_global_stats ( Xapian::doccount  first,
Xapian::doccount  maxitems,
Xapian::doccount  check_at_least,
const Xapian::KeyMaker sorter,
const Xapian::Weight::Internal stats 
) const

◆ send_message()

void RemoteDatabase::send_message ( message_type  type,
std::string_view  data 
) const
protected

◆ set_metadata()

void RemoteDatabase::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 from Xapian::Database::Internal.

Definition at line 916 of file remote-database.cc.

References get_message(), MSG_SETMETADATA, pack_string(), REPLY_DONE, send_message(), and uncommitted_changes.

◆ set_query()

void RemoteDatabase::set_query ( const Xapian::Query query,
Xapian::termcount  qlen,
Xapian::valueno  collapse_key,
Xapian::doccount  collapse_max,
Xapian::Enquire::docid_order  order,
Xapian::valueno  sort_key,
Xapian::Enquire::Internal::sort_setting  sort_by,
bool  sort_value_forward,
double  time_limit,
int  percent_threshold,
double  weight_threshold,
const Xapian::Weight wtscheme,
const Xapian::RSet omrset,
const std::vector< opt_ptr_spy > &  matchspies 
) const

Set the query.

Parameters
queryThe query.
qlenThe query length.
collapse_keyThe value number to collapse matches on.
collapse_maxMax number of items with the same key to leave after collapsing (0 for don't collapse).
orderSort order for docids.
sort_keyThe value number to sort on.
sort_byWhich order to apply sorts in.
sort_value_forwardSort order for values.
time_limit_Seconds to reduce check_at_least after (or <= 0 for no limit).
percent_thresholdLower bound on percentage score.
weight_thresholdLower bound on weight.
wtschemeWeighting scheme.
omrsetThe rset.
matchspiesThe matchspies to use.

Definition at line 677 of file remote-database.cc.

References MSG_QUERY, Xapian::Weight::name(), pack_bool(), pack_string(), pack_uint(), query(), Xapian::Enquire::Internal::REL, send_message(), Xapian::Query::serialise(), Xapian::Weight::serialise(), serialise_double(), and serialise_rset().

◆ term_exists()

bool RemoteDatabase::term_exists ( std::string_view  term) const
virtual

◆ update_stats()

bool RemoteDatabase::update_stats ( message_type  msg_code = MSG_UPDATE,
const std::string &  body = std::string() 
) const
private

Member Data Documentation

◆ cached_stats_valid

bool RemoteDatabase::cached_stats_valid
mutableprivate

◆ doccount

Xapian::doccount RemoteDatabase::doccount
mutableprivate

The remote document count, given at open.

Definition at line 58 of file remote-database.h.

Referenced by get_doccount(), open_post_list(), open_term_list(), and update_stats().

◆ doclen_lbound

Xapian::termcount RemoteDatabase::doclen_lbound
mutableprivate

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

Definition at line 64 of file remote-database.h.

Referenced by get_doclength_lower_bound(), and update_stats().

◆ doclen_ubound

Xapian::termcount RemoteDatabase::doclen_ubound
mutableprivate

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

Definition at line 67 of file remote-database.h.

Referenced by get_doclength_upper_bound(), get_wdf_upper_bound(), and update_stats().

◆ has_positional_info

bool RemoteDatabase::has_positional_info
mutableprivate

Has positional information?

Definition at line 73 of file remote-database.h.

Referenced by has_positions(), positionlist_count(), and update_stats().

◆ lastdocid

Xapian::docid RemoteDatabase::lastdocid
mutableprivate

The remote last docid, given at open.

Definition at line 61 of file remote-database.h.

Referenced by get_lastdocid(), open_post_list(), and update_stats().

◆ link

OwnedRemoteConnection RemoteDatabase::link
mutableprivate

◆ mru_slot

Xapian::valueno RemoteDatabase::mru_slot
mutableprivate

The value slot for the most recently used value statistics.

Set to BAD_VALUENO if no value statistics have yet been looked up.

Definition at line 97 of file remote-database.h.

Referenced by add_document(), cancel(), delete_document(), read_value_stats(), reopen(), and replace_document().

◆ mru_valstats

ValueStats RemoteDatabase::mru_valstats
mutableprivate

The most recently used value statistics.

Definition at line 91 of file remote-database.h.

Referenced by get_value_freq(), get_value_lower_bound(), get_value_upper_bound(), and read_value_stats().

◆ pending_reply

bool RemoteDatabase::pending_reply = false
mutableprivate

Are we currently expecting a reply?

Our caller might send a message but then an exception (from another shard or locally) might cause it not to try to read the reply before sending another message. This flag allows us to detect that situation and discard the unwanted reply rather than trying to read it as the response to the new message.

Definition at line 83 of file remote-database.h.

Referenced by get_message(), and send_message().

◆ timeout

double RemoteDatabase::timeout
protected

The timeout value used in network communications, in seconds.

Definition at line 158 of file remote-database.h.

Referenced by get_message(), and send_message().

◆ total_length

Xapian::totallength RemoteDatabase::total_length
mutableprivate

The total length of all documents in this database.

Definition at line 70 of file remote-database.h.

Referenced by get_total_length(), and update_stats().

◆ uncommitted_changes

bool RemoteDatabase::uncommitted_changes = false
mutableprivate

True if there are (or may be) uncommitted changes.

Used to optimise away commit()/cancel() calls. These can be explicit, but also can happen implicitly when the WritableDatabase destructor is called.

Definition at line 105 of file remote-database.h.

Referenced by add_document(), add_spelling(), add_synonym(), cancel(), clear_synonyms(), commit(), delete_document(), remove_spelling(), remove_synonym(), replace_document(), and set_metadata().

◆ uuid

std::string RemoteDatabase::uuid
mutableprivate

The UUID of the remote database.

Definition at line 86 of file remote-database.h.

Referenced by get_uuid(), and update_stats().


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