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;
165 t != doc.termlist_end();
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;
212 v != doc.values_end();
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) {
Xapian::Document get_document(Xapian::docid did) const
Get a document from the database, given its document id.
void dbcheck(const Xapian::Database &db, Xapian::doccount expected_doccount, Xapian::docid expected_lastdocid)
Check consistency of database and statistics.
TermIterator termlist_begin(Xapian::docid did) const
An iterator pointing to the start of the termlist for a given document.
#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.
Xapian::termcount get_doclength_lower_bound() const
Get a lower bound on the length of a document in this DB.
TermIterator allterms_end(const std::string &=std::string()) const
Corresponding end iterator to allterms_begin(prefix).
Xapian::docid get_lastdocid() const
Get the highest document id which has been used in the database.
a generic test suite engine
Xapian::doccount get_termfreq() const
Return the term frequency for the term at the current position.
Class for iterating over document values.
Convert types to std::string.
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_doccount() const
Get the number of documents in the database.
string docstats_to_string(const Xapian::Database &db, Xapian::docid did)
Convert statistics about a document to a string.
Xapian::doclength get_avlength() const
Get the average length of the documents in the database.
Class for iterating over a list of terms.
unsigned XAPIAN_TERMCOUNT_BASE_TYPE termcount
A counts of terms.
#define TEST_REL(A, REL, B)
Test a relation holds,e.g. TEST_REL(a,>,b);.
Class for iterating over a list of terms.
PositionIterator positionlist_end() const
Return an end PositionIterator for the current term.
Xapian::termcount get_doclength_upper_bound() const
Get an upper bound on the length of a document in this DB.
string docterms_to_string(const Xapian::Database &db, Xapian::docid did)
Convert the list of terms in a document to a string.
string postlist_to_string(const Xapian::Database &db, const string &tname)
Convert the list of postings in a postlist to a string.
ValueIterator valuestream_end(Xapian::valueno) const
Return end iterator corresponding to valuestream_begin().
string termstats_to_string(const Xapian::Database &db, const string &term)
Convert statistics about a term to a string.
string str(int value)
Convert int to std::string.
Xapian::termcount get_doclength(Xapian::docid did) const
Get the length of a document.
Class for iterating over term positions.
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().
#define TEST_EQUAL_DOUBLE(a, b)
Test two doubles for near equality.
ValueIterator valuestream_begin(Xapian::valueno slot) const
Return an iterator over the value in slot slot for each document.
bool term_exists(const std::string &tname) const
Check if a given term exists in the database.
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.
unsigned XAPIAN_DOCID_BASE_TYPE doccount
A count of documents.
std::string get_value_lower_bound(Xapian::valueno slot) const
Get a lower bound on the values stored in the given value slot.
unsigned XAPIAN_DOCID_BASE_TYPE docid
A unique identifier for a 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::doccount get_termfreq(const std::string &tname) const
Get the number of documents in the database indexed by a given term.
PositionIterator positionlist_begin() const
Return a PositionIterator for the current term.
A handle representing a document in a Xapian database.
Xapian::termcount positionlist_count() const
Return the length of the position list for the current position.
UnimplementedError indicates an attempt to use an unimplemented feature.
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.