xapian-core  1.4.19
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 Member Functions

void keep_alive ()
 Send a keep-alive message. More...
 
void set_query (const Xapian::Query &query, Xapian::termcount qlen, Xapian::doccount collapse_max, Xapian::valueno collapse_key, 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_cutoff, double weight_cutoff, const Xapian::Weight *wtscheme, const Xapian::RSet &omrset, const vector< Xapian::Internal::opt_intrusive_ptr< Xapian::MatchSpy >> &matchspies)
 Set the query. More...
 
bool get_remote_stats (bool nowait, Xapian::Weight::Internal &out)
 Get the stats from the remote server. More...
 
void send_global_stats (Xapian::doccount first, Xapian::doccount maxitems, Xapian::doccount check_at_least, const Xapian::Weight::Internal &stats)
 Send the global stats to the remote server. More...
 
void get_mset (Xapian::MSet &mset, const vector< Xapian::Internal::opt_intrusive_ptr< Xapian::MatchSpy >> &matchspies)
 Get the MSet from the remote server. More...
 
TermListopen_metadata_keylist (const std::string &prefix) const
 Get remote metadata key list. More...
 
TermListopen_term_list (Xapian::docid did) const
 Get remote termlist. More...
 
TermListopen_allterms (const string &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...
 
LeafPostListopen_post_list (const string &tname) const
 Open a posting list. More...
 
Xapian::doccount read_post_list (const string &term, NetworkPostList &pl) const
 
PositionListopen_position_list (Xapian::docid did, const string &tname) const
 Open a position list for the given term in the given document. More...
 
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
 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...
 
bool term_exists (const string &tname) const
 Check if term exists. More...
 
void get_freqs (const string &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 (const string &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)
 Add a new document to the database. More...
 
void delete_document (Xapian::docid did)
 Delete a document in the database. More...
 
void delete_document (const std::string &unique_term)
 Delete any documents indexed by a term from the database. More...
 
void replace_document (Xapian::docid did, const Xapian::Document &doc)
 Replace a given document in the database. More...
 
Xapian::docid replace_document (const std::string &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...
 
string get_metadata (const string &key) const
 Get the metadata associated with a given key. More...
 
void set_metadata (const string &key, const string &value)
 Set the metadata associated with a given key. More...
 
void add_spelling (const std::string &, Xapian::termcount) const
 Add a word to the spelling dictionary. More...
 
void remove_spelling (const std::string &, Xapian::termcount freqdec) const
 Remove a word from the spelling dictionary. More...
 
int get_backend_info (string *path) const
 Get backend information about this database. 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 readahead_for_query (const Xapian::Query &query)
 
virtual ValueListopen_value_list (Xapian::valueno slot) const
 Open a value stream. More...
 
virtual TermListopen_spelling_termlist (const string &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 Xapian::doccount get_spelling_frequency (const string &word) const
 Return the number of times word was added as a spelling. More...
 
virtual TermListopen_synonym_termlist (const string &term) const
 Open a termlist returning synonyms for a term. More...
 
virtual TermListopen_synonym_keylist (const string &prefix) const
 Open a termlist returning each term which has synonyms. 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...
 
void begin_transaction (bool flushed)
 Begin a transaction. More...
 
void commit_transaction ()
 Commit a transaction. More...
 
void cancel_transaction ()
 Cancel a transaction. More...
 
virtual void write_changesets_to_fd (int fd, const std::string &start_revision, bool need_whole_db, Xapian::ReplicationInfo *info)
 Write a set of changesets to a file descriptor. More...
 
virtual string get_revision_info () const
 Get a string describing the current revision of the database. More...
 
virtual void invalidate_doc_object (Xapian::Document::Internal *obj) const
 Notify the database that document is no longer valid. More...
 
virtual void get_used_docid_range (Xapian::docid &first, Xapian::docid &last) const
 Find lowest and highest docids actually in use. More...
 
virtual void request_document (Xapian::docid) const
 Request and later collect a document from the database. More...
 
virtual Xapian::Document::Internalcollect_document (Xapian::docid did) const
 Request and later collect a document from the database. More...
 
- Public Member Functions inherited from Xapian::Internal::intrusive_base
 intrusive_base ()
 Construct with no references. More...
 

Protected Member Functions

 RemoteDatabase (int fd, double timeout_, const string &context_, 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, const string &data) const
 Send a message to the server. More...
 
void do_close ()
 Close the socket. More...
 
bool get_posting (Xapian::docid &did, double &w, string &value)
 
- 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

double timeout
 The timeout value used in network communications, in seconds. More...
 
- Protected Attributes inherited from Xapian::Database::Internal
enum Xapian::Database::Internal:: { ... }  transaction_state
 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...
 
int pending_reply = -1
 Are we currently expecting a reply? More...
 
string uuid
 The UUID of the remote database. More...
 
string context
 The context to return with any error messages. 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_UNIMPLEMENTED = -1, TRANSACTION_NONE = 0, TRANSACTION_UNFLUSHED = 1, TRANSACTION_FLUSHED = 2 }
 Transaction state. 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 45 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 ( int  fd,
double  timeout_,
const string &  context_,
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
fdThe file descriptor for the connection to the server.
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.
context_The context to return with any error messages.
writableIs this a WritableDatabase?
flagsXapian::DB_RETRY_LOCK or 0.

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

References Xapian::DB_RETRY_LOCK, encode_length(), MSG_MAX, MSG_WRITEACCESS, Xapian::Database::Internal::transaction_state, Xapian::Database::Internal::TRANSACTION_UNIMPLEMENTED, and update_stats().

Member Function Documentation

◆ add_document()

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

Add a new document to the database.

See WritableDatabase::add_document() for more information.

Reimplemented from Xapian::Database::Internal.

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

References Xapian::BAD_VALUENO, cached_stats_valid, decode_length(), get_message(), mru_slot, MSG_ADDDOCUMENT, REPLY_ADDDOCUMENT, send_message(), serialise_document(), and uncommitted_changes.

◆ add_spelling()

void RemoteDatabase::add_spelling ( const std::string &  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 909 of file remote-database.cc.

References dummy, encode_length(), get_message(), MSG_ADDSPELLING, 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 784 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.

◆ close()

void RemoteDatabase::close ( )
virtual

Close the database.

Implements Xapian::Database::Internal.

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

References do_close().

Referenced by ProgClient::run_program().

◆ commit()

void RemoteDatabase::commit ( )
virtual

Commit pending modifications to the database.

See WritableDatabase::commit() for more information.

Reimplemented from Xapian::Database::Internal.

Definition at line 770 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 ( Xapian::docid  did)
virtual

Delete a document in the database.

See WritableDatabase::delete_document() for more information.

Reimplemented from Xapian::Database::Internal.

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

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

◆ delete_document() [2/2]

void RemoteDatabase::delete_document ( const std::string &  unique_term)
virtual

Delete any documents indexed by a term from the database.

See WritableDatabase::delete_document() for more information.

Reimplemented from Xapian::Database::Internal.

Definition at line 830 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.

◆ do_close()

void RemoteDatabase::do_close ( )
protected

◆ get_backend_info()

int RemoteDatabase::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 291 of file remote-database.h.

References BACKEND_REMOTE.

◆ get_doccount()

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

Get the document count.

Implements Xapian::Database::Internal.

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

References cached_stats_valid, doccount, and update_stats().

◆ get_doclength()

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

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

References Assert, context, decode_length(), encode_length(), get_message(), MSG_DOCLENGTH, REPLY_DOCLENGTH, and send_message().

Referenced by NetworkPostList::NetworkPostList().

◆ 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.

Reimplemented from Xapian::Database::Internal.

Definition at line 515 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.

Reimplemented from Xapian::Database::Internal.

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

References doclen_ubound.

◆ get_freqs()

void RemoteDatabase::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.

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

References Assert, decode_length(), get_message(), MSG_COLLFREQ, MSG_FREQS, MSG_TERMFREQ, REPLY_COLLFREQ, REPLY_FREQS, REPLY_TERMFREQ, and send_message().

◆ get_lastdocid()

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

Get the last used docid.

Implements Xapian::Database::Internal.

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

References cached_stats_valid, lastdocid, and update_stats().

◆ get_message() [1/2]

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

◆ get_message() [2/2]

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

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

◆ get_message_or_done()

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

◆ get_metadata()

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

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

◆ get_mset()

void RemoteDatabase::get_mset ( Xapian::MSet mset,
const vector< Xapian::Internal::opt_intrusive_ptr< Xapian::MatchSpy >> &  matchspies 
)

Get the MSet from the remote server.

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

References decode_length_and_check(), get_message(), REPLY_RESULTS, and unserialise_mset().

Referenced by RemoteSubMatch::get_mset(), and RemoteSubMatch::get_postlist().

◆ get_posting()

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

◆ get_remote_stats()

bool RemoteDatabase::get_remote_stats ( bool  nowait,
Xapian::Weight::Internal out 
)

Get the stats from the remote server.

Returns
true if we got the remote stats; false if we should try again.

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

References get_message(), link, RemoteConnection::ready_to_read(), REPLY_STATS, and unserialise_stats().

Referenced by RemoteSubMatch::prepare_match().

◆ 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 420 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 term in document.

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

Implements Xapian::Database::Internal.

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

References Assert, context, decode_length(), encode_length(), get_message(), MSG_UNIQUETERMS, REPLY_UNIQUETERMS, and send_message().

Referenced by NetworkPostList::NetworkPostList().

◆ 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 881 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.
Exceptions
UnimplementedErrorThe frequency of the value isn't available for this database type.

Implements Xapian::Database::Internal.

Definition at line 494 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 the lower bound isn't available for the given database type, this will return the lowest possible bound - the empty string.

Parameters
slotThe value slot to examine.

Implements Xapian::Database::Internal.

Definition at line 501 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.

Parameters
slotThe value slot to examine.
Exceptions
UnimplementedErrorThe upper bound of the values isn't available for this database type.

Implements Xapian::Database::Internal.

Definition at line 508 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 ( const string &  term) const
virtual

Get an upper bound on the wdf of term term.

Reimplemented from Xapian::Database::Internal.

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

References doclen_ubound.

Referenced by NetworkPostList::NetworkPostList().

◆ has_positions()

bool RemoteDatabase::has_positions ( ) const
virtual

Check whether this database contains any positional information.

Implements Xapian::Database::Internal.

Definition at line 281 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 125 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 933 of file remote-database.cc.

◆ open_allterms()

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

◆ open_document()

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

◆ open_metadata_keylist()

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

◆ open_position_list()

PositionList * RemoteDatabase::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.

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

References decode_length(), encode_length(), get_message_or_done(), MSG_POSITIONLIST, REPLY_POSITIONLIST, and send_message().

Referenced by NetworkPostList::NetworkPostList(), and NetworkTermList::positionlist_begin().

◆ open_post_list()

LeafPostList * RemoteDatabase::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.

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

◆ open_term_list()

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

◆ operator=()

void RemoteDatabase::operator= ( const RemoteDatabase )
private

Don't allow assignment.

◆ read_post_list()

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

◆ read_value_stats()

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

◆ remove_spelling()

void RemoteDatabase::remove_spelling ( const std::string &  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.

Reimplemented from Xapian::Database::Internal.

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

References encode_length(), MSG_REMOVESPELLING, 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 288 of file remote-database.cc.

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

◆ replace_document() [1/2]

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

Replace a given document in the database.

See WritableDatabase::replace_document() for more information.

Reimplemented from Xapian::Database::Internal.

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

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

◆ replace_document() [2/2]

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

Replace any documents matching a term.

See WritableDatabase::replace_document() for more information.

Reimplemented from Xapian::Database::Internal.

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

References Xapian::BAD_VALUENO, cached_stats_valid, decode_length(), encode_length(), get_message(), mru_slot, MSG_REPLACEDOCUMENTTERM, REPLY_ADDDOCUMENT, send_message(), serialise_document(), and uncommitted_changes.

◆ send_global_stats()

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

Send the global stats to the remote server.

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

References encode_length(), MSG_GETMSET, send_message(), and serialise_stats().

Referenced by RemoteSubMatch::start_match().

◆ send_message()

void RemoteDatabase::send_message ( message_type  type,
const string &  data 
) const
protected

◆ set_metadata()

void RemoteDatabase::set_metadata ( const string &  key,
const string &  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 896 of file remote-database.cc.

References dummy, encode_length(), get_message(), MSG_SETMETADATA, REPLY_DONE, send_message(), and uncommitted_changes.

◆ set_query()

void RemoteDatabase::set_query ( const Xapian::Query query,
Xapian::termcount  qlen,
Xapian::doccount  collapse_max,
Xapian::valueno  collapse_key,
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_cutoff,
double  weight_cutoff,
const Xapian::Weight wtscheme,
const Xapian::RSet omrset,
const vector< Xapian::Internal::opt_intrusive_ptr< Xapian::MatchSpy >> &  matchspies 
)

Set the query.

Parameters
queryThe query.
qlenThe query length.
collapse_maxMax number of items with the same key to leave after collapsing (0 for don't collapse).
collapse_keyThe value number to collapse matches on.
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_cutoffPercentage cutoff.
weight_cutoffWeight cutoff.
wtschemeWeighting scheme.
omrsetThe rset.
matchspiesThe matchspies to use.

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

References encode_length(), MSG_QUERY, Xapian::Weight::name(), send_message(), Xapian::Weight::serialise(), Xapian::Query::serialise(), serialise_double(), and serialise_rset().

Referenced by MultiMatch::MultiMatch().

◆ term_exists()

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

Check if term exists.

Implements Xapian::Database::Internal.

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

References Assert, get_message(), MSG_TERMEXISTS, REPLY_TERMDOESNTEXIST, REPLY_TERMEXISTS, and send_message().

◆ 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

◆ context

string RemoteDatabase::context
private

The context to return with any error messages.

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

Referenced by get_doclength(), get_message(), get_unique_terms(), is_intermediate_reply(), open_term_list(), read_value_stats(), and update_stats().

◆ doccount

Xapian::doccount RemoteDatabase::doccount
mutableprivate

The remote document count, given at open.

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

Referenced by get_doccount(), open_allterms(), open_metadata_keylist(), 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 62 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 65 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 71 of file remote-database.h.

Referenced by has_positions(), and update_stats().

◆ lastdocid

Xapian::docid RemoteDatabase::lastdocid
mutableprivate

The remote last docid, given at open.

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

Referenced by get_lastdocid(), and update_stats().

◆ link

OwnedRemoteConnection RemoteDatabase::link
mutableprivate

The object which does the I/O.

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

Referenced by do_close(), get_message(), get_remote_stats(), and send_message().

◆ 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 104 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 98 of file remote-database.h.

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

◆ pending_reply

int RemoteDatabase::pending_reply = -1
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.

Unhelpfully the remote protocol in 1.4.x can send REPLY_DOCLENGTH in response to MSG_DOCLENGTH (when it's a final reply) or in response to MSG_TERMLIST (when further replies are expected). To allow use to distinguish these cases, pending_reply is set to the MSG_* code, or -1 if we're not currently expecting a reply.

Definition at line 87 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 159 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 68 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 112 of file remote-database.h.

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

◆ uuid

string RemoteDatabase::uuid
mutableprivate

The UUID of the remote database.

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

Referenced by get_uuid(), and update_stats().


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