27 #define XAPIAN_DEPRECATED(X) X 48 char * p =
const_cast<char *
>(s.c_str());
51 bool del = (*p ==
'!');
56 last = strtoul(p + 1, &p, 10);
58 if (*p && *p !=
' ') {
59 tout << p - s.c_str() << endl;
60 FAIL_TEST(
"Bad sparse db spec (expected space): " << s);
63 FAIL_TEST(
"Bad sparse db spec (first > last): " << s);
71 string id =
str(first);
74 doc.
add_term(
string(first % 7 + 1,
char((first % 26) +
'a')));
77 }
while (first++ < last);
79 if (*p ==
'\0')
break;
101 "5-7 24 76 987 1023-1027 9999 !9999");
112 "3000 999999 !999999");
298 const char * stubpath =
".stub/compactstub1";
299 const char * stubpathfile =
".stub/compactstub1/XAPIANDB";
300 mkdir(
".stub", 0755);
301 mkdir(stubpath, 0755);
302 ofstream stub(stubpathfile);
303 TEST(stub.is_open());
325 const char * stubpath =
".stub/compactstub2";
326 mkdir(
".stub", 0755);
327 ofstream stub(stubpath);
328 TEST(stub.is_open());
350 const char * stubpath =
".stub/compactstub3";
351 mkdir(
".stub", 0755);
352 ofstream stub(stubpath);
353 TEST(stub.is_open());
377 const char * stubpath =
".stub/compactstub4";
378 const char * stubpathfile =
".stub/compactstub4/XAPIANDB";
379 mkdir(
".stub", 0755);
380 mkdir(stubpath, 0755);
381 ofstream stub(stubpathfile);
382 TEST(stub.is_open());
546 "5-7 24 76 987 1023-1027 9999 !9999");
552 "3000 999999 !999999");
Xapian::docid add_document(const Xapian::Document &document)
Add a new document to the database.
static void make_sparse_db(Xapian::WritableDatabase &db, const string &s)
void dbcheck(const Xapian::Database &db, Xapian::doccount expected_doccount, Xapian::docid expected_lastdocid)
Check consistency of database and statistics.
#define TEST(a)
Test a condition, without an additional explanation for failure.
This class is used to access a database, or a group of databases.
test database contents and consistency.
InvalidOperationError indicates the API was used in an invalid way.
void set_multipass(bool multipass)
Set whether to merge postlists in multiple passes.
TermIterator allterms_end(const std::string &=std::string()) const
Corresponding end iterator to allterms_begin(prefix).
DEFINE_TESTCASE(compactoldnorenumber1, compact &&!multi)
a generic test suite engine
void set_destdir(const std::string &destdir)
Set where to write the output.
C++ function versions of useful Unix commands.
Convert types to std::string.
Utility functions for testing files.
static void make_missing_tables(Xapian::WritableDatabase &db, const string &)
void replace_document(Xapian::docid did, const Xapian::Document &document)
Replace a given document in the database.
static void make_all_tables2(Xapian::WritableDatabase &db, const string &)
Xapian::doccount get_doccount() const
Get the number of documents in the database.
void compact()
Perform the actual compaction/merging operation.
static void make_all_tables(Xapian::WritableDatabase &db, const string &)
test functionality of the Xapian API
void rm_rf(const string &filename)
Remove a directory and contents, just like the Unix "rm -rf" command.
Class for iterating over a list of terms.
Class for iterating over a list of terms.
#define TEST_NOT_EQUAL(a, b)
Test for non-equality of two things.
string get_database_path(const string &dbname)
static void check_sparse_uid_terms(const string &path)
This class provides read/write access to a database.
Xapian::TermIterator spellings_begin() const
An iterator which returns all the spelling correction targets.
std::ostringstream tout
The debug printing stream.
Public interfaces for the Xapian library.
Xapian::TermIterator synonym_keys_begin(const std::string &prefix=std::string()) const
An iterator which returns all terms which have synonyms.
Compact a database, or merge and compact several.
void delete_document(Xapian::docid did)
Delete a document from the database.
#define TEST_EXCEPTION(TYPE, CODE)
Check that CODE throws exactly Xapian exception TYPE.
Xapian::TermIterator synonym_keys_end(const std::string &=std::string()) const
Corresponding end iterator to synonym_keys_begin(prefix).
string str(int value)
Convert int to std::string.
void commit()
Commit any pending modifications made to the database.
TermIterator allterms_begin(const std::string &prefix=std::string()) const
An iterator which runs across all terms with a given prefix.
bool dir_exists(const char *path)
Test if a directory exists.
std::string get_compaction_output_path(const std::string &name)
#define FAIL_TEST(MSG)
Fail the current testcase with message MSG.
Xapian::Database get_database(const string &dbname)
unsigned XAPIAN_DOCID_BASE_TYPE doccount
A count of documents.
Xapian-specific test helper functions and macros.
void set_renumber(bool renumber)
Set whether to preserve existing document id values.
Xapian::TermIterator spellings_end() const
Corresponding end iterator to spellings_begin().
void add_synonym(const std::string &term, const std::string &synonym) const
Add a synonym for a term.
unsigned XAPIAN_DOCID_BASE_TYPE docid
A unique identifier for a document.
#define TEST_EQUAL(a, b)
Test for equality of two things.
static void make_multichunk_db(Xapian::WritableDatabase &db, const string &)
void set_data(const std::string &data)
Set data stored in the document.
void add_source(const std::string &srcdir)
Add a source database.
A handle representing a document in a Xapian database.
std::string get_uuid() const
Get a UUID for the database.
void add_spelling(const std::string &word, Xapian::termcount freqinc=1) const
Add a word to the spelling dictionary.
PostingIterator postlist_begin(const std::string &tname) const
An iterator pointing to the start of the postlist for a given term.
void add_term(const std::string &tname, Xapian::termcount wdfinc=1)
Add a term to the document, without positional information.