38 bool need_comma =
false;
58 bool need_comma =
false;
68 if (!posrepr.empty()) {
69 posrepr =
", pos=[" + posrepr +
"]";
72 result +=
"(" +
str(*p) +
73 ", doclen=" +
str(p.get_doclength()) +
74 ", wdf=" +
str(p.get_wdf()) +
85 bool need_comma =
false;
92 if (!posrepr.empty()) {
93 posrepr =
", pos=[" + posrepr +
"]";
97 result +=
"Term(" + *t +
", wdf=" +
str(t.get_wdf()) + posrepr;
135 unsigned long totlen = 0;
140 map<string, string> posting_reprs;
141 map<Xapian::valueno, string> value_reprs;
154 if (doclen < doclen_lower_bound)
155 doclen_lower_bound = doclen;
156 if (doclen > doclen_upper_bound)
157 doclen_upper_bound = doclen;
171 if (wdf) ++found_unique_terms;
194 if (!posrepr.empty()) {
195 posrepr =
",[" + posrepr +
"]";
197 string posting_repr =
"(" +
str(did) +
"," +
202 map<string, string>::iterator i = posting_reprs.find(*t);
203 if (i == posting_reprs.end()) {
204 posting_reprs[*t] = posting_repr;
206 i->second +=
"," + posting_repr;
214 TEST((*v).size() != 0);
215 string value_repr =
"(" +
str(did) +
"," + *v +
")";
218 map<Xapian::valueno, string>::iterator i;
219 i = value_reprs.find(v.get_valueno());
220 if (i == value_reprs.end()) {
221 value_reprs[v.get_valueno()] = value_repr;
223 i->second +=
"," + value_repr;
229 TEST_EQUAL(expected_termcount, found_termcount);
234 TEST_REL(unique_terms, >=, found_unique_terms);
235 TEST_REL(unique_terms, <=, found_termcount);
244 map<string, string>::const_iterator i;
249 TEST(i != posting_reprs.end());
256 bool need_comma =
false;
265 cf_count += p.get_wdf();
269 if (!posrepr.empty()) {
270 posrepr =
",[" + posrepr +
"]";
272 posting_repr +=
"(" +
str(*p) +
"," +
273 str(p.get_wdf()) +
"/" +
274 str(p.get_doclength()) + posrepr +
")";
275 if (wdf_upper_bound < p.get_wdf())
276 wdf_upper_bound = p.get_wdf();
286 TEST(i == posting_reprs.end());
288 map<Xapian::valueno, string>::const_iterator j;
289 for (j = value_reprs.begin(); j != value_reprs.end(); ++j) {
291 string value_lower_bound;
292 string value_upper_bound;
297 value_lower_bound = *v;
298 value_upper_bound = *v;
302 if (*v > value_upper_bound) {
303 value_upper_bound = *v;
305 if (*v < value_lower_bound) {
306 value_lower_bound = *v;
309 value_repr +=
"(" +
str(v.get_docid()) +
"," + *v +
")";
321 if (expected_doccount == 0) {
This class is used to access a database, or a group of databases.
Xapian::termcount get_wdf_upper_bound(const std::string &term) const
Get an upper bound on the wdf of term term.
PostingIterator postlist_begin(const std::string &tname) const
An iterator pointing to the start of the postlist for a given term.
ValueIterator valuestream_begin(Xapian::valueno slot) const
Return an iterator over the value in slot slot for each document.
ValueIterator valuestream_end(Xapian::valueno) const
Return end iterator corresponding to valuestream_begin().
Xapian::doclength get_avlength() const
Get the average length of the documents in the database.
PostingIterator postlist_end(const std::string &) const
Corresponding end iterator to postlist_begin().
Xapian::termcount get_doclength_lower_bound() const
Get a lower bound on the length of a document in this DB.
TermIterator termlist_begin(Xapian::docid did) const
An iterator pointing to the start of the termlist for a given document.
Xapian::termcount get_collection_freq(const std::string &tname) const
Return the total number of occurrences of the given term.
std::string get_value_upper_bound(Xapian::valueno slot) const
Get an upper bound on the values stored in the given value slot.
Xapian::doccount get_termfreq(const std::string &tname) const
Get the number of documents in the database indexed by a given term.
Xapian::termcount get_doclength(Xapian::docid did) const
Get the length of a document.
std::string get_value_lower_bound(Xapian::valueno slot) const
Get a lower bound on the values stored in the given value slot.
TermIterator allterms_begin(const std::string &prefix=std::string()) const
An iterator which runs across all terms with a given prefix.
bool term_exists(const std::string &tname) const
Check if a given term exists in the database.
TermIterator allterms_end(const std::string &=std::string()) const
Corresponding end iterator to allterms_begin(prefix).
Xapian::doccount get_doccount() const
Get the number of documents in the database.
Xapian::Document get_document(Xapian::docid did) const
Get a document from the database, given its document id.
Xapian::docid get_lastdocid() const
Get the highest document id which has been used in the database.
TermIterator termlist_end(Xapian::docid) const
Corresponding end iterator to termlist_begin().
Xapian::termcount get_doclength_upper_bound() const
Get an upper bound on the length of a document in this DB.
Xapian::termcount get_unique_terms(Xapian::docid did) const
Get the number of unique terms in document.
A handle representing a document in a Xapian database.
ValueIterator values_begin() const
Iterator for the values in this document.
TermIterator termlist_end() const
Equivalent end iterator for termlist_begin().
ValueIterator values_end() const
Equivalent end iterator for values_begin().
Xapian::termcount termlist_count() const
The length of the termlist - i.e.
TermIterator termlist_begin() const
Start iterating the terms in this document.
Xapian::termcount values_count() const
Count the values in this document.
Class for iterating over term positions.
Class for iterating over a list of terms.
Class for iterating over a list of terms.
Xapian::doccount get_termfreq() const
Return the term frequency for the term at the current position.
Xapian::termcount positionlist_count() const
Return the length of the position list for the current position.
PositionIterator positionlist_end() const
Return an end PositionIterator for the current term.
Xapian::termcount get_wdf() const
Return the wdf for the term at the current position.
PositionIterator positionlist_begin() const
Return a PositionIterator for the current term.
UnimplementedError indicates an attempt to use an unimplemented feature.
Class for iterating over document values.
test database contents and consistency.
string str(int value)
Convert int to std::string.
unsigned XAPIAN_TERMCOUNT_BASE_TYPE termcount
A counts of terms.
unsigned XAPIAN_DOCID_BASE_TYPE doccount
A count of documents.
unsigned XAPIAN_DOCID_BASE_TYPE docid
A unique identifier for a document.
Convert types to std::string.
#define TEST_REL(A, REL, B)
Test a relation holds,e.g. TEST_REL(a,>,b);.
string docterms_to_string(const Xapian::Database &db, Xapian::docid did)
Convert the list of terms in a document to a string.
void dbcheck(const Xapian::Database &db, Xapian::doccount expected_doccount, Xapian::docid expected_lastdocid)
Check consistency of database and statistics.
string postlist_to_string(const Xapian::Database &db, const string &tname)
Convert the list of postings in a postlist to a string.
string termstats_to_string(const Xapian::Database &db, const string &term)
Convert statistics about a term to a string.
string positions_to_string(Xapian::PositionIterator &it, const Xapian::PositionIterator &end, Xapian::termcount *count)
Convert the list of positions in a positionlist to a string.
string docstats_to_string(const Xapian::Database &db, Xapian::docid did)
Convert statistics about a document to a string.
a generic test suite engine
#define TEST_EQUAL(a, b)
Test for equality of two things.
#define TEST_EQUAL_DOUBLE(a, b)
Test two doubles for near equality.
#define TEST(a)
Test a condition, without an additional explanation for failure.