46 std::vector<std::string>
seen;
80 std::sort(myspy.
seen.begin(), myspy.
seen.end());
82 std::vector<std::string> seen2;
83 for ( ; i != spymset.
end(); ++i) {
85 seen2.push_back(doc.get_data());
87 std::sort(seen2.begin(), seen2.end());
90 std::vector<std::string>::const_iterator j = myspy.
seen.begin();
91 std::vector<std::string>::const_iterator j2 = seen2.begin();
92 for (; j != myspy.
seen.end(); ++j, ++j2) {
98 string resultrepr(
"|");
104 resultrepr +=
str(i.get_termfreq());
113 for (
int c = 1; c <= 25; ++c) {
117 for (
int factor = 1; factor <= c; ++factor) {
119 if (c % factor == 0) {
164 static const char *
const results[] = {
165 "|1:1|2:9|3:3|4:7|5:1|6:3|8:1|",
166 "|0:2|1:3|2:3|3:3|4:3|5:3|6:2|7:2|8:2|9:2|",
177 "Matchspy counts hits on remote and locally");
179 "Matchspy counts hits on remote and locally");
222 static const char *
const results[] = {
223 "|2:9|4:7|3:3|6:3|1:1|5:1|8:1|",
224 "|1:3|2:3|3:3|4:3|5:3|0:2|6:2|7:2|8:2|9:2|",
227 "|2:9|4:7|3:3|6:3|1:1|5:1|8:1|",
228 "|1:3|2:3|3:3|4:3|5:3|0:2|6:2|7:2|8:2|9:2|",
233 std::vector<Xapian::ValueCountMatchSpy *> spies;
234 spies.push_back(&spya0);
235 spies.push_back(&spya1);
236 spies.push_back(NULL);
237 spies.push_back(&spya3);
238 spies.push_back(&spyb0);
239 spies.push_back(&spyb1);
240 spies.push_back(NULL);
241 spies.push_back(&spyb3);
243 tout <<
"value " << v <<
'\n';
245 string allvals_str(
"|");
247 size_t allvals_size = 0;
250 ++i, ++allvals_size) {
253 allvals_str +=
str(i.get_termfreq());
256 tout << allvals_str <<
'\n';
259 for (
size_t count = 0; count < allvals_size; ++count) {
260 tout <<
"count " << count <<
'\n';
266 tout <<
"j " << j <<
'\n';
268 TEST_EQUAL(i.get_termfreq(), j.get_termfreq());
virtual std::string get_description() const
Return a string describing this object.
Xapian::doccount size() const
Return number of items in this MSet object.
Xapian::docid add_document(const Xapian::Document &document)
Add a new document to the database.
void add_value(Xapian::valueno slot, const std::string &value)
Add a new value.
virtual std::string serialise_results() const
Serialise the results of this match spy.
#define TEST(a)
Test a condition, without an additional explanation for failure.
virtual void merge_results(const std::string &serialised)
Unserialise some results, and merge them into this matchspy.
This class is used to access a database, or a group of databases.
void set_sort_by_value(Xapian::valueno sort_key, bool reverse)
Set the sorting to be by value only.
TermIterator values_end() const
End iterator corresponding to values_begin()
Abstract base class for match spies.
Xapian::docid get_lastdocid() const
Get the highest document id which has been used in the database.
size_t get_total() const
Return the total number of documents tallied.
void operator()(const Xapian::Document &doc, double)
Register a document with the match spy.
a generic test suite engine
virtual std::string serialise_results() const
Serialise the results of this match spy.
Class representing a list of search results.
MSet get_mset(Xapian::doccount first, Xapian::doccount maxitems, Xapian::doccount checkatleast=0, const RSet *omrset=0, const MatchDecider *mdecider=0) const
Get (a portion of) the match set for the current query.
Convert types to std::string.
static string values_to_repr(const Xapian::ValueCountMatchSpy &spy)
DEFINE_TESTCASE(matchspy1, backend &&!remote)
test functionality of the Xapian API
Class for iterating over a list of terms.
Xapian::Weight subclass implementing Coordinate Matching.
TermIterator top_values_begin(size_t maxvalues) const
Get an iterator over the most frequent values seen in the slot.
Base class for backend handling in test harness.
This class provides read/write access to a database.
std::ostringstream tout
The debug printing stream.
Iterator over a Xapian::MSet.
Registry for user subclasses.
Public interfaces for the Xapian library.
virtual std::string serialise() const
Return this object's parameters serialised as a single string.
#define TEST_EXCEPTION(TYPE, CODE)
Check that CODE throws exactly Xapian exception TYPE.
string str(int value)
Convert int to std::string.
MSetIterator begin() const
Return iterator pointing to the first item in this MSet.
MSetIterator end() const
Return iterator pointing to just after the last item in this MSet.
void operator()(const Xapian::Document &, double)
Register a document with the match spy.
TermIterator top_values_end(size_t) const
End iterator corresponding to top_values_begin()
TermIterator values_begin() const
Get an iterator over the values seen in the slot.
void set_query(const Xapian::Query &query, Xapian::termcount qlen=0)
Set the query to run.
size_t size() const
Return number of shards in this Database object.
static void make_matchspy2_db(Xapian::WritableDatabase &db, const string &)
Class for counting the frequencies of values in the matching documents.
Xapian::Database get_database(const string &dbname)
void add_matchspy(MatchSpy *spy)
Add a matchspy.
void XFAIL_FOR_BACKEND(const std::string &backend_prefix, const char *msg)
This class provides an interface to the information retrieval system for the purpose of searching...
Indicates a problem communicating with a remote database.
unsigned valueno
The number for a value slot in a document.
Xapian-specific test helper functions and macros.
#define TEST_STRINGS_EQUAL(a, b)
Test for equality of two strings.
void set_weighting_scheme(const Weight &weight_)
Set the weighting scheme to use for queries.
Class representing a query.
std::string get_data() const
Get data stored in the document.
virtual MatchSpy * unserialise(const std::string &serialised, const Registry &context) const
Unserialise parameters.
#define TEST_EQUAL(a, b)
Test for equality of two things.
virtual void merge_results(const std::string &serialised)
Unserialise some results, and merge them into this matchspy.
void set_data(const std::string &data)
Set data stored in the document.
std::vector< std::string > seen
A handle representing a document in a Xapian database.
UnimplementedError indicates an attempt to use an unimplemented feature.
void add_term(const std::string &tname, Xapian::termcount wdfinc=1)
Add a term to the document, without positional information.
virtual MatchSpy * clone() const
Clone the match spy.
virtual std::string name() const
Return the name of this match spy.