xapian-core
1.4.27
|
Implementation of RemoteDatabase using a spawned server. More...
#include <progclient.h>
Public Member Functions | |
ProgClient (const std::string &progname, const std::string &arg, double timeout, bool writable, int flags) | |
Constructor. More... | |
~ProgClient () | |
Destructor. More... | |
Public Member Functions inherited from RemoteDatabase | |
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... | |
TermList * | open_metadata_keylist (const std::string &prefix) const |
Get remote metadata key list. More... | |
TermList * | open_term_list (Xapian::docid did) const |
Get remote termlist. More... | |
TermList * | open_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... | |
LeafPostList * | open_post_list (const string &tname) const |
Open a posting list. More... | |
Xapian::doccount | read_post_list (const string &term, NetworkPostList &pl) const |
PositionList * | open_position_list (Xapian::docid did, const string &tname) const |
Open a position list for the given term in the given document. More... | |
Xapian::Document::Internal * | open_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 ValueList * | open_value_list (Xapian::valueno slot) const |
Open a value stream. More... | |
virtual TermList * | open_spelling_termlist (const string &word) const |
Create a termlist tree from trigrams of word. More... | |
virtual TermList * | open_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 TermList * | open_synonym_termlist (const string &term) const |
Open a termlist returning synonyms for a term. More... | |
virtual TermList * | open_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::Internal * | collect_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... | |
Private Member Functions | |
void | operator= (const ProgClient &) |
Don't allow assignment. More... | |
ProgClient (const ProgClient &) | |
Don't allow copying. More... | |
Static Private Member Functions | |
static int | run_program (const std::string &progname, const std::string &args, pid_t &child) |
Start the child process. More... | |
static std::string | get_progcontext (const std::string &progname, const std::string &args) |
Generate context string for Xapian::Error exception objects. More... | |
Private Attributes | |
pid_t | child |
Process id of the child process. 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... | |
Protected Member Functions inherited from RemoteDatabase | |
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 inherited from RemoteDatabase | |
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... | |
Implementation of RemoteDatabase using a spawned server.
ProgClient spawns a child process to connect to the server - for example, an ssh command to run the server on a remote host. Communication with the child process is via a pipe.
Definition at line 34 of file progclient.h.
|
private |
Don't allow copying.
ProgClient::ProgClient | ( | const std::string & | progname, |
const std::string & | arg, | ||
double | timeout, | ||
bool | writable, | ||
int | flags | ||
) |
Constructor.
progname | The program used to create the connection. |
args | Any arguments to the program. |
timeout | Timeout for communication (in seconds). |
writable | Is this a WritableDatabase? |
flags | Xapian::DB_RETRY_LOCK or 0. |
Definition at line 67 of file progclient.cc.
References LOGCALL_CTOR.
ProgClient::~ProgClient | ( | ) |
Destructor.
Definition at line 258 of file progclient.cc.
References child, and RemoteDatabase::do_close().
|
staticprivate |
Generate context string for Xapian::Error exception objects.
progname | The program used to create the connection. |
args | Any arguments to the program. |
Note: this method is used from constructors so has been made static to avoid problems with trying to use uninitialised member variables. In particular, it can't be made a virtual method of the base class.
Definition at line 77 of file progclient.cc.
References LOGCALL_STATIC, and RETURN.
Referenced by run_program().
|
private |
Don't allow assignment.
|
staticprivate |
Start the child process.
progname | The program used to create the connection. |
args | Any arguments to the program. |
child | Reference to store the child process pid/HANDLE in. |
Note: this method is called early on during class construction before any member variables or even the base class have been initialised. To help avoid accidentally trying to use member variables, this method has been deliberately made "static".
Definition at line 84 of file progclient.cc.
References child, RemoteDatabase::close(), Xapian::Internal::closefrom(), get_progcontext(), LOGCALL_STATIC, O_BINARY, Xapian::InMemory::open(), RETURN, SNPRINTF, SOCK_CLOEXEC, and split_words().
|
private |
Process id of the child process.
Definition at line 43 of file progclient.h.
Referenced by run_program(), and ~ProgClient().