xapian-core
1.4.27
|
#include <backendmanager.h>
Public Member Functions | |
BackendManager (const std::string &datadir_, const std::string &dbtype_) | |
Constructor. More... | |
virtual | ~BackendManager () |
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... | |
const std::string & | get_dbtype () const |
Get the database type currently in use. More... | |
const std::string & | get_datadir () const |
Get the directory to store data in. More... | |
Xapian::Database | get_database (const std::vector< std::string > &files) |
Get a database instance of the current type. More... | |
Xapian::Database | get_database (const std::string &file) |
Get a database instance of the current type, single file case. More... | |
Xapian::Database | get_database (const std::string &dbname, void(*gen)(Xapian::WritableDatabase &, const std::string &), const std::string &arg) |
Get a database instance of the current type, generated case. More... | |
virtual Xapian::Database | get_database_by_path (const std::string &path) |
Get a database instance by path. More... | |
std::string | get_database_path (const std::vector< std::string > &files) |
Get the path of a database instance, if such a thing exists. More... | |
std::string | get_database_path (const std::string &file) |
Get the path of a database instance, if such a thing exists (single file case). More... | |
std::string | get_database_path (const std::string &dbname, void(*gen)(Xapian::WritableDatabase &, const std::string &), const std::string &arg) |
Get the path of a generated database instance. More... | |
virtual Xapian::WritableDatabase | get_writable_database (const std::string &name, const std::string &file) |
Get a writable database instance. More... | |
virtual Xapian::WritableDatabase | get_remote_writable_database (std::string args) |
Get a remote Xapian::WritableDatabase instance with specified args. More... | |
virtual std::string | get_writable_database_path (const std::string &name) |
Get the path of a writable database instance, if such a thing exists. More... | |
virtual Xapian::WritableDatabase | get_generated_database (const std::string &name) |
Get a generated writable database instance. More... | |
virtual std::string | get_generated_database_path (const std::string &name) |
Get the path to use for generating a database, if supported. More... | |
virtual void | finalise_generated_database (const std::string &name) |
Finalise the generated database. More... | |
virtual Xapian::Database | get_remote_database (const std::vector< std::string > &files, unsigned int timeout) |
Get a remote database instance with the specified timeout. More... | |
virtual std::string | get_writable_database_args (const std::string &path, unsigned int timeout) |
Get the args for opening a writable remote database with the specified timeout. More... | |
virtual Xapian::Database | get_writable_database_as_database () |
Create a Database object for the last opened WritableDatabase. More... | |
virtual Xapian::WritableDatabase | get_writable_database_again () |
Create a WritableDatabase object for the last opened WritableDatabase. More... | |
virtual std::string | get_writable_database_path_again () |
Get the path of the last opened WritableDatabase. More... | |
virtual std::string | get_compaction_output_path (const std::string &name) |
Get a path to compact a database to. More... | |
virtual void | clean_up () |
Called after each test, to perform any necessary cleanup. More... | |
Static Public Member Functions | |
static const char * | get_xapian_progsrv_command () |
Get the command line required to run xapian-progsrv. More... | |
Protected Member Functions | |
void | index_files_to_database (Xapian::WritableDatabase &database, const std::vector< std::string > &files) |
Index data from zero or more text files into a database. More... | |
bool | create_dir_if_needed (const std::string &dirname) |
Create the directory dirname if needed. More... | |
virtual Xapian::Database | do_get_database (const std::vector< std::string > &files) |
Virtual method implementing get_database(). More... | |
virtual std::string | do_get_database_path (const std::vector< std::string > &files) |
Virtual method implementing get_database_path(). More... | |
Private Attributes | |
std::string | datadir |
The current data directory. More... | |
std::string | dbtype |
The backend database type (set by subclass ctor). More... | |
Definition at line 42 of file backendmanager.h.
|
inline |
|
virtual |
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 78 of file backendmanager.cc.
Referenced by BackendManager().
|
virtual |
Called after each test, to perform any necessary cleanup.
May be called more than once for a given test in some cases.
Reimplemented in BackendManagerRemoteTcp.
Definition at line 290 of file backendmanager.cc.
Referenced by test_driver::do_run_tests(), get_datadir(), and test_driver::runtest().
|
protected |
Create the directory dirname if needed.
Returns true if the directory was created and false if it was already there. Throws an exception if there was an error (eg not a directory).
Definition at line 60 of file backendmanager.cc.
References dir_exists().
Referenced by BackendManagerChert::BackendManagerChert(), BackendManagerGlass::BackendManagerGlass(), BackendManagerMulti::BackendManagerMulti(), BackendManagerSingleFile::BackendManagerSingleFile(), and BackendManagerSingleFile::finalise_generated_database().
|
protectedvirtual |
Virtual method implementing get_database().
If we just called this get_database() then each subclass which defined it would also need to un-hide the non-virtual overloaded method with "using get_database(const std::string&);" or similar.
Reimplemented in BackendManagerRemoteProg, BackendManagerRemoteTcp, and BackendManagerInMemory.
Definition at line 87 of file backendmanager.cc.
|
protectedvirtual |
Virtual method implementing get_database_path().
If we just called this get_database_path() then each subclass which defined it would also need to un-hide the non-virtual overloaded method with "using get_database_path(const std::string&);" or similar.
Reimplemented in BackendManagerMulti, BackendManagerSingleFile, BackendManagerChert, and BackendManagerGlass.
Definition at line 81 of file backendmanager.cc.
|
virtual |
Finalise the generated database.
Reimplemented in BackendManagerSingleFile.
Definition at line 242 of file backendmanager.cc.
Referenced by get_datadir().
|
virtual |
Get a path to compact a database to.
Reimplemented in BackendManagerMulti, BackendManagerSingleFile, BackendManagerChert, and BackendManagerGlass.
Definition at line 230 of file backendmanager.cc.
Referenced by get_compaction_output_path(), and get_datadir().
Xapian::Database BackendManager::get_database | ( | const std::vector< std::string > & | files | ) |
Get a database instance of the current type.
Definition at line 93 of file backendmanager.cc.
Referenced by DEFINE_TESTCASE(), BackendManagerSingleFile::do_get_database_path(), get_database(), and get_datadir().
Xapian::Database BackendManager::get_database | ( | const std::string & | file | ) |
Get a database instance of the current type, single file case.
Definition at line 99 of file backendmanager.cc.
Xapian::Database BackendManager::get_database | ( | const std::string & | dbname, |
void(*)(Xapian::WritableDatabase &, const std::string &) | gen, | ||
const std::string & | arg | ||
) |
Get a database instance of the current type, generated case.
dbname | The name of the database (base on your testcase name). |
gen | Generator function - should index data to the empty WritableDatabase provided. |
arg | String argument to pass to gen - it's up to you how to make use of this (or just ignore it if you don't need it). |
Definition at line 105 of file backendmanager.cc.
References gen, get_writable_database(), path_exists(), and rm_rf().
|
virtual |
Get a database instance by path.
Reimplemented in BackendManagerRemoteProg, and BackendManagerRemoteTcp.
Definition at line 184 of file backendmanager.cc.
Referenced by get_datadir().
string BackendManager::get_database_path | ( | const std::vector< std::string > & | files | ) |
Get the path of a database instance, if such a thing exists.
Definition at line 190 of file backendmanager.cc.
Referenced by get_database_path(), get_datadir(), and BackendManagerRemote::get_remote_database_args().
string BackendManager::get_database_path | ( | const std::string & | file | ) |
Get the path of a database instance, if such a thing exists (single file case).
Definition at line 196 of file backendmanager.cc.
std::string BackendManager::get_database_path | ( | const std::string & | dbname, |
void(*)(Xapian::WritableDatabase &, const std::string &) | gen, | ||
const std::string & | arg | ||
) |
Get the path of a generated database instance.
Definition at line 151 of file backendmanager.cc.
References gen, path_exists(), and rm_rf().
|
inline |
Get the directory to store data in.
Definition at line 88 of file backendmanager.h.
References clean_up(), datadir, finalise_generated_database(), gen, get_compaction_output_path(), get_database(), get_database_by_path(), get_database_path(), get_generated_database(), get_generated_database_path(), get_remote_database(), get_remote_writable_database(), get_writable_database(), get_writable_database_again(), get_writable_database_args(), get_writable_database_as_database(), get_writable_database_path(), get_writable_database_path_again(), and get_xapian_progsrv_command().
Referenced by BackendManagerMulti::createdb_multi().
|
inline |
Get the database type currently in use.
Definition at line 84 of file backendmanager.h.
References dbtype.
Referenced by TestRunner::do_tests_for_backend_(), get_dbtype(), ApiTestRunner::run(), and PerfTestLogger::testcase_begin().
|
virtual |
Get a generated writable database instance.
Reimplemented in BackendManagerRemote, and BackendManagerSingleFile.
Definition at line 224 of file backendmanager.cc.
References get_writable_database().
Referenced by get_datadir(), and BackendManagerSingleFile::get_generated_database().
|
virtual |
Get the path to use for generating a database, if supported.
Reimplemented in BackendManagerRemote, BackendManagerMulti, BackendManagerSingleFile, BackendManagerChert, BackendManagerGlass, and BackendManagerInMemory.
Definition at line 236 of file backendmanager.cc.
Referenced by BackendManagerSingleFile::finalise_generated_database(), and get_datadir().
|
virtual |
Get a remote database instance with the specified timeout.
Reimplemented in BackendManagerRemoteProg, BackendManagerMulti, and BackendManagerRemoteTcp.
Definition at line 246 of file backendmanager.cc.
References get_dbtype().
Referenced by get_datadir(), and get_remote_database().
|
virtual |
Get a remote Xapian::WritableDatabase instance with specified args.
Reimplemented in BackendManagerRemoteProg.
Definition at line 208 of file backendmanager.cc.
References get_dbtype().
Referenced by BackendManagerMulti::createdb_multi(), and get_datadir().
|
virtual |
Get a writable database instance.
Reimplemented in BackendManagerMulti, BackendManagerSingleFile, BackendManagerRemoteProg, BackendManagerRemoteTcp, BackendManagerChert, BackendManagerGlass, and BackendManagerInMemory.
Definition at line 202 of file backendmanager.cc.
Referenced by DEFINE_TESTCASE(), get_datadir(), BackendManagerRemote::get_generated_database(), get_named_writable_database(), get_writable_database(), and BackendManagerRemote::get_writable_database_args().
|
virtual |
Create a WritableDatabase object for the last opened WritableDatabase.
Reimplemented in BackendManagerMulti, BackendManagerRemoteProg, BackendManagerRemoteTcp, BackendManagerChert, and BackendManagerGlass.
Definition at line 272 of file backendmanager.cc.
References get_dbtype().
Referenced by get_datadir(), and get_writable_database_again().
|
virtual |
Get the args for opening a writable remote database with the specified timeout.
Reimplemented in BackendManagerRemote.
Definition at line 255 of file backendmanager.cc.
References get_dbtype().
Referenced by get_datadir().
|
virtual |
Create a Database object for the last opened WritableDatabase.
Reimplemented in BackendManagerRemoteProg, and BackendManagerRemoteTcp.
Definition at line 266 of file backendmanager.cc.
Referenced by get_datadir(), and get_writable_database_as_database().
|
virtual |
Get the path of a writable database instance, if such a thing exists.
Reimplemented in BackendManagerMulti, BackendManagerChert, and BackendManagerGlass.
Definition at line 218 of file backendmanager.cc.
Referenced by get_datadir(), BackendManagerRemote::get_generated_database_path(), get_named_writable_database_path(), and BackendManagerRemote::get_writable_database_args().
|
virtual |
Get the path of the last opened WritableDatabase.
Reimplemented in BackendManagerMulti, BackendManagerChert, and BackendManagerGlass.
Definition at line 281 of file backendmanager.cc.
References get_dbtype().
Referenced by get_datadir(), BackendManagerRemote::get_writable_database_again_args(), and BackendManagerRemote::get_writable_database_as_database_args().
|
static |
Get the command line required to run xapian-progsrv.
Definition at line 295 of file backendmanager.cc.
References XAPIAN_PROGSRV.
Referenced by BackendManagerMulti::createdb_multi(), DEFINE_TESTCASE(), and get_datadir().
|
protected |
Index data from zero or more text files into a database.
Definition at line 49 of file backendmanager.cc.
References FileIndexer::index_to().
Referenced by BackendManagerChert::do_get_database_path(), BackendManagerGlass::do_get_database_path(), BackendManagerGlass::get_writable_database(), and BackendManagerChert::get_writable_database().
|
private |
The current data directory.
Definition at line 44 of file backendmanager.h.
Referenced by get_datadir().
|
private |
The backend database type (set by subclass ctor).
Definition at line 47 of file backendmanager.h.
Referenced by get_dbtype().