35 #define COUNT_CLOSEDEXC(CODE) \ 38 } catch (const Xapian::DatabaseClosedError &) { \ 42 #define IF_NOT_CLOSEDEXC(CODE) \ 47 } catch (const Xapian::DatabaseClosedError &) { \ 51 } while (false); if (hadexc) 86 int closedexc_count = 0;
92 "This is a test document used with"));
144 bool advanced =
false;
201 return closedexc_count;
212 int closedexc_count = iters.
perform();
225 for (
int i = 0; i != 6; ++i) {
226 fds.push_back(dup(1));
233 closedexc_count = iters.
perform();
265 const string & uuid = db.
get_uuid();
349 bool advanced =
false;
370 bool advanced =
false;
392 FAIL_TEST(
"Expected DatabaseClosedError wasn't thrown");
Xapian::Document get_document(Xapian::docid did) const
Get a document from the database, given its document id.
Xapian::docid add_document(const Xapian::Document &document)
Add a new document to the database.
PositionIterator positionlist_end(Xapian::docid, const std::string &) const
Corresponding end iterator to positionlist_begin().
TermIterator termlist_begin(Xapian::docid did) const
An iterator pointing to the start of the termlist for a given document.
Indicates an attempt to access a closed database.
void cancel_transaction()
Abort the transaction currently in progress, discarding the pending modifications made to the databas...
#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.
void remove_spelling(const std::string &word, Xapian::termcount freqdec=1) const
Remove a word from the spelling dictionary.
InvalidOperationError indicates the API was used in an invalid way.
PositionIterator positionlist_begin(Xapian::docid did, const std::string &tname) const
An iterator pointing to the start of the position list for a given term in a given document...
virtual std::string get_description() const
Return a string describing this object.
Xapian::termcount get_doclength_lower_bound() const
Get a lower bound on the length of a document in this DB.
bool has_positions() const
Does this database have any positional information?
TermIterator allterms_end(const std::string &=std::string()) const
Corresponding end iterator to allterms_begin(prefix).
Xapian::WritableDatabase get_writable_database(const string &dbname)
Xapian::PostingIterator pl2
Xapian::docid get_lastdocid() const
Get the highest document id which has been used in the database.
void begin_transaction(bool flushed=true)
Begin a transaction.
Xapian::doccount get_termfreq() const
Return the term frequency for the term at the current position.
bool reopen()
Re-open the database.
Xapian::PostingIterator pl1
std::string get_value_upper_bound(Xapian::valueno slot) const
Get an upper bound on the values stored in the given value slot.
void replace_document(Xapian::docid did, const Xapian::Document &document)
Replace a given document in the database.
void set_metadata(const std::string &key, const std::string &metadata)
Set the user-specified metadata associated with a given key.
#define IF_NOT_CLOSEDEXC(CODE)
Xapian::doccount get_doccount() const
Get the number of documents in the database.
std::string get_metadata(const std::string &key) const
Get the user-specified metadata associated with a given key.
Xapian::WritableDatabase get_named_writable_database(const std::string &name, const std::string &source)
test functionality of the Xapian API
Xapian::doclength get_avlength() const
Get the average length of the documents in the database.
Class for iterating over a list of terms.
Xapian::PositionIterator pil1
#define TEST_REL(A, REL, B)
Test a relation holds,e.g. TEST_REL(a,>,b);.
Class for iterating over a list of terms.
#define TEST_NOT_EQUAL(a, b)
Test for non-equality of two things.
Xapian::termcount get_doclength_upper_bound() const
Get an upper bound on the length of a document in this DB.
void remove_synonym(const std::string &term, const std::string &synonym) const
Remove a synonym for a term.
std::string get_named_writable_database_path(const std::string &name)
DatabaseLockError indicates failure to lock a database.
const int DB_OPEN
Open an existing database.
This class provides read/write access to a database.
Xapian::TermIterator spellings_begin() const
An iterator which returns all the spelling correction targets.
void setup(Xapian::Database db_)
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.
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::termcount get_doclength(Xapian::docid did) const
Get the length of a document.
void commit()
Commit any pending modifications made to the database.
Xapian::Database get_writable_database_as_database()
Class for iterating over term positions.
Xapian::TermIterator tlend
Xapian::termcount get_wdf() const
Return the wdf for the term at the current position.
TermIterator allterms_begin(const std::string &prefix=std::string()) const
An iterator which runs across all terms with a given prefix.
TermIterator termlist_end(Xapian::docid) const
Corresponding end iterator to termlist_begin().
Xapian::TermIterator synonyms_begin(const std::string &term) const
An iterator which returns all the synonyms for a given term.
ValueIterator valuestream_begin(Xapian::valueno slot) const
Return an iterator over the value in slot slot for each document.
#define COUNT_CLOSEDEXC(CODE)
std::string get_spelling_suggestion(const std::string &word, unsigned max_edit_distance=2) const
Suggest a spelling correction.
bool term_exists(const std::string &tname) const
Check if a given term exists in the database.
void clear_synonyms(const std::string &term) const
Remove all synonyms for a term.
#define FAIL_TEST(MSG)
Fail the current testcase with message MSG.
Xapian::Database get_database(const string &dbname)
Xapian::TermIterator atl1
Xapian::termcount get_doclength() const
Return the length of the document at the current position.
std::string get_value_lower_bound(Xapian::valueno slot) const
Get a lower bound on the values stored in the given value slot.
Xapian-specific test helper functions and macros.
void commit_transaction()
Complete the transaction currently in progress.
DEFINE_TESTCASE(closedb1, backend)
Xapian::TermIterator atlend
Xapian::TermIterator metadata_keys_begin(const std::string &prefix=std::string()) const
An iterator which returns all user-specified metadata keys.
void keep_alive()
Send a "keep-alive" to remote databases to stop them timing out.
<unistd.h>, but with compat.
void add_synonym(const std::string &term, const std::string &synonym) const
Add a synonym for a term.
std::string get_data() const
Get data stored in the document.
#define TEST_EQUAL(a, b)
Test for equality of two things.
Xapian::termcount get_unique_terms(Xapian::docid did) const
Get the number of unique terms in document.
PostingIterator postlist_end(const std::string &) const
Corresponding end iterator to postlist_begin().
Xapian::PositionIterator pilend
std::string get_value(Xapian::valueno slot) const
Get value by number.
Xapian::PostingIterator pl1end
virtual void close()
Close the database.
TermIterator termlist_begin() const
Start iterating the terms in this document.
Xapian::doccount get_termfreq(const std::string &tname) const
Get the number of documents in the database indexed by a given term.
Xapian::doccount get_value_freq(Xapian::valueno slot) const
Return the frequency of a given value slot.
A handle representing a document in a Xapian database.
Xapian::termcount get_unique_terms() const
Return the number of unique terms in the current document.
std::string get_uuid() const
Get a UUID for the database.
Xapian::PostingIterator pl2end
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.
Xapian::termcount get_collection_freq(const std::string &tname) const
Return the total number of occurrences of the given term.
Xapian::termcount get_wdf_upper_bound(const std::string &term) const
Get an upper bound on the wdf of term term.