48 : num_docs(num_docs_), last_docid(last_docid_), did(0)
53 : num_docs(db.get_doccount()), last_docid(db.get_lastdocid()), did(0)
56 PostingSource*
clone()
const override {
69 void next(
double wt)
override {
72 if (did % 2 == 0) ++did;
78 if (did % 2 == 0) ++did;
83 return did > last_docid;
148 : num_docs(num_docs_), last_docid(last_docid_), did(0)
155 : num_docs(db.get_doccount()), last_docid(db.get_lastdocid()), did(0)
158 PostingSource*
clone()
const override {
165 return (did % 2) ? 1000 : 0.001;
175 void next(
double wt)
override {
187 return did > last_docid;
193 return "MyOddWeightingPostingSource";
209 mset_expect_order(mset, 1, 3, 5, 7, 9, 11, 13, 15, 17, 2);
251 : num_docs(num_docs_), last_docid(last_docid_), did(0)
257 PostingSource*
clone()
const override {
268 FAIL_TEST(
"MyDontAskWeightPostingSource::get_weight() called");
278 void next(
double wt)
override {
290 return did > last_docid;
296 return "MyDontAskWeightPostingSource";
306 tout <<
"OP_SCALE_WEIGHT 0\n";
312 tout <<
"OP_FILTER\n";
321 tout <<
"BoolWeight\n";
342 tout <<
"OP_FILTER\n";
351 tout <<
"OP_FILTER other way\n";
460 : did(0), maxid_accessed(maxid_accessed_) { }
465 if (did > maxid_accessed) {
466 FAIL_TEST(
"ChangeMaxweightPostingSource::get_weight() called " 467 "for docid " +
str(did) +
", max id accessed " 468 "should be " +
str(maxid_accessed));
479 set_maxweight(5 - did);
484 set_maxweight(5 - did);
487 bool at_end()
const override {
return did >= 5; }
490 return "ChangeMaxweightPostingSource";
600 :
Xapian::DecreasingValueWeightPostingSource(0), count(count_) { }
606 void next(
double min_wt)
override {
616 for (
int wt = 20; wt > 0; --wt) {
627 #ifndef HAVE_TIMER_CREATE 628 SKIP_TEST(
"Enquire::set_time_limit() not implemented for this platform");
655 :
Xapian::DecreasingValueWeightPostingSource(0),
656 doclen_lb(doclen_lb_),
657 doclen_ub(doclen_ub_) { }
695 : clone_count(clone_count_)
698 PostingSource*
clone()
const override {
760 PostingSource*
clone()
const override {
766 if (shard_index == 0) {
777 return last_docid / 2;
782 void next(
double wt)
override {
785 if (did > last_docid) did = 0;
791 if (did > last_docid) did = 0;
801 return "OnlyTheFirstPostingSource";
842 : lb(lb_), est(est_), ub(ub_)
845 PostingSource*
clone()
const override {
858 FAIL_TEST(
"EstimatePS::next() shouldn't be called");
862 FAIL_TEST(
"EstimatePS::skip_to() shouldn't be called");
870 FAIL_TEST(
"EstimatePS::get_docid() shouldn't be called");
882 {411, 424, 439, 420},
885 {411, 426, 439, 430},
886 {123, 351, 439, 400},
893 {411, 416, 439, 420},
894 {411, 412, 439, 420},
896 {111, 133, 138, 130},
897 {111, 137, 138, 130},
899 {411, 415, 419, 415},
The Xapian namespace contains public interfaces for the Xapian library.
void init(const Xapian::Database &) override
Set this PostingSource to the start of the list of postings.
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.
bool check(Xapian::docid min_docid, double min_wt)
Check if the specified docid occurs.
void skip_to(Xapian::docid min_docid, double min_wt)
Advance to the specified docid.
void add_value(Xapian::valueno slot, const std::string &value)
Add a new value.
Xapian::docid maxid_accessed
double get_weight() const override
Return the weight contribution for the current document.
OnlyTheFirstPostingSource(bool allow_clone_)
double get_max_possible() const
The maximum possible weight any document could achieve.
void set_docid_order(docid_order order)
Set sort order for document IDs.
PostingSource * clone() const override
Clone the posting source.
bool at_end() const override
Return true if the current position is past the last entry in this list.
#define TEST(a)
Test a condition, without an additional explanation for failure.
Xapian::doccount get_termfreq_min() const
A lower bound on the number of documents this object can return.
This class is used to access a database, or a group of databases.
bool at_end() const override
Return true if the current position is past the last entry in this list.
void next(double min_wt) override
Advance the current position to the next matching document.
std::string get_description() const
Return a string describing this object.
bool at_end() const override
Return true if the current position is past the last entry in this list.
void set_cutoff(int percent_cutoff, double weight_cutoff=0)
Set the percentage and/or weight cutoffs.
bool at_end() const override
Return true if the current position is past the last entry in this list.
EstimatePS(Xapian::doccount lb_, Xapian::doccount est_, Xapian::doccount ub_)
Xapian::doccount get_termfreq_est() const override
An estimate of the number of documents this object can return.
InvalidOperationError indicates the API was used in an invalid way.
Xapian::docid get_docid() const override
Return the current docid.
Xapian::docid get_docid() const
Return the current docid.
string get_description() const override
Return a string describing this object.
Xapian::doccount get_termfreq_est() const override
An estimate of the number of documents this object can return.
Xapian::termcount get_doclength_lower_bound() const
Get a lower bound on the length of a document in this DB.
bool empty() const
Return true if this MSet object is empty.
Xapian::doccount get_termfreq_min() const override
A lower bound on the number of documents this object can return.
Xapian::doccount get_termfreq_est() const override
An estimate of the number of documents this object can return.
PostingSource * clone() const override
Clone the posting source.
Xapian::docid get_lastdocid() const
Get the highest document id which has been used in the database.
bool at_end() const
Return true if the current position is past the last entry in this list.
void sleep(double t)
Sleep until the time represented by this object.
void next(double wt) override
Advance the current position to the next matching document.
string get_description() const override
Return a string describing this object.
void init(const Database &db_)
Set this PostingSource to the start of the list of postings.
Xapian::docid get_docid() const override
Return the current docid.
Xapian::doccount get_termfreq_min() const override
A lower bound on the number of documents this object can return.
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.
void skip_to(Xapian::docid to_did, double) override
Advance to the specified docid.
Convert types to std::string.
static double est(double l, double r, double n)
std::string sortable_serialise(double value)
Convert a floating point number to a string, preserving sort order.
MyOddWeightingPostingSource(Xapian::doccount num_docs_, Xapian::doccount last_docid_)
ChangeMaxweightPostingSource(Xapian::docid maxid_accessed_)
Xapian::doccount & doclen_ub
void init(const Xapian::Database &database) override
Set this PostingSource to the start of the list of postings.
string get_description() const override
Return a string describing this object.
void init(const Xapian::Database &) override
Set this PostingSource to the start of the list of postings.
Xapian::doccount get_doccount() const
Get the number of documents in the database.
Xapian::docid get_docid() const override
Return the current docid.
PostingSource * clone() const override
Clone the posting source.
Xapian::doccount num_docs
Xapian::doccount num_docs
void skip_to(Xapian::docid to_did, double wt) override
Advance to the specified docid.
double get_weight() const override
Return the weight contribution for the current document.
Xapian::doccount last_docid
Read weights from a value which is known to decrease as docid increases.
test functionality of the Xapian API
void skip_to(Xapian::docid to_did, double wt) override
Advance to the specified docid.
Xapian::doccount get_termfreq_max() const override
An upper bound on the number of documents this object can return.
void init(const Xapian::Database &) override
Set this PostingSource to the start of the list of postings.
Xapian::doccount last_docid
#define TEST_REL(A, REL, B)
Test a relation holds,e.g. TEST_REL(a,>,b);.
Xapian::doccount get_termfreq_max() const override
An upper bound on the number of documents this object can return.
MyOddWeightingPostingSource(const Xapian::Database &db)
InvalidArgumentError indicates an invalid parameter value was passed to the API.
Xapian::termcount get_doclength_upper_bound() const
Get an upper bound on the length of a document in this DB.
DEFINE_TESTCASE(externalsource1, backend &&!remote &&!multi)
void next(double) override
Advance the current position to the next matching document.
string get_description() const override
Return a string describing this object.
Class implementing a "boolean" weighting scheme.
PostingSource * clone() const override
Clone the posting source.
void skip_to(Xapian::docid to_did, double wt) override
Advance to the specified docid.
bool at_end() const override
Return true if the current position is past the last entry in this list.
Xapian::doccount get_termfreq_max() const override
An upper bound on the number of documents this object can return.
This class provides read/write access to a database.
Xapian::docid get_docid() const override
Return the current docid.
Xapian::doccount get_termfreq_est() const
An estimate of the number of documents this object can return.
std::ostringstream tout
The debug printing stream.
Iterator over a Xapian::MSet.
Scale the weight contributed by a subquery.
Match the first subquery taking extra weight from other subqueries.
Public interfaces for the Xapian library.
Match like OP_AND but only taking weight from the first subquery.
MyDontAskWeightPostingSource()
Xapian::doccount get_termfreq_est() const override
An estimate of the number of documents this object can return.
bool at_end() const override
Return true if the current position is past the last entry in this list.
A posting source which returns a fixed weight for all documents.
void set_time_limit(double time_limit)
Set a time limit for the match.
#define TEST_EXCEPTION(TYPE, CODE)
Check that CODE throws exactly Xapian exception TYPE.
Xapian::doccount get_termfreq_est() const override
An estimate of the number of documents this object can return.
Xapian::doccount get_termfreq_max() const override
An upper bound on the number of documents this object can return.
void init(const Xapian::Database &db) override
Set this PostingSource to the start of the list of postings.
bool at_end() const
Return true if the current position is past the last entry in this list.
Xapian::doccount get_termfreq_est() const override
An estimate of the number of documents this object can return.
MyOddPostingSource(Xapian::doccount num_docs_, Xapian::doccount last_docid_)
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.
static Xapian::doccount shard_index
void skip_to(Xapian::docid min_docid, double min_wt)
Advance to the specified docid.
Xapian::doccount get_termfreq_max() const override
An upper bound on the number of documents this object can return.
Xapian::doccount last_docid
Xapian::doccount get_termfreq_min() const override
A lower bound on the number of documents this object can return.
Xapian::doccount get_termfreq_max() const override
An upper bound on the number of documents this object can return.
Xapian::docid get_docid() const override
Return the current docid.
void init(const Database &db_)
Set this PostingSource to the start of the list of postings.
Base class which provides an "external" source of postings.
void init(const Xapian::Database &) override
Set this PostingSource to the start of the list of postings.
void skip_to(Xapian::docid to_did, double wt) override
Advance to the specified docid.
Xapian::docid get_docid() const override
Return the current docid.
#define TEST_EQUAL_DOUBLE(a, b)
Test two doubles for near equality.
void skip_to(Xapian::docid, double) override
Advance to the specified docid.
PostingSource * clone() const override
Clone the posting source.
CheckBoundsPostingSource(Xapian::doccount &doclen_lb_, Xapian::doccount &doclen_ub_)
void set_query(const Xapian::Query &query, Xapian::termcount qlen=0)
Set the query to run.
void next(double) override
Advance the current position to the next matching document.
void next(double wt) override
Advance the current position to the next matching document.
Xapian::doccount get_termfreq_min() const override
A lower bound on the number of documents this object can return.
A posting source which reads weights from a value slot.
#define FAIL_TEST(MSG)
Fail the current testcase with message MSG.
Match only documents which all subqueries match.
Xapian::Database get_database(const string &dbname)
Xapian::doccount last_docid
Xapian::doccount get_matches_estimated() const
Estimate of the total number of matching documents.
string get_description() const override
Return a string describing this object.
void skip_to(Xapian::docid, double) override
Advance to the specified docid.
double get_weight() const override
Return the weight contribution for the current document.
Xapian::doccount get_termfreq_min() const override
A lower bound on the number of documents this object can return.
MyOddPostingSource(const Xapian::Database &db)
#define SKIP_TEST(MSG)
Skip the current testcase with message MSG.
This class provides an interface to the information retrieval system for the purpose of searching...
unsigned XAPIAN_DOCID_BASE_TYPE doccount
A count of documents.
CloneTestPostingSource(int &clone_count_)
void init(const Xapian::Database &db_)
Set this PostingSource to the start of the list of postings.
Xapian::doccount & doclen_lb
Xapian::doccount get_termfreq_est() const override
An estimate of the number of documents this object can return.
PostingSource subclass for injecting tf bounds and estimate.
Xapian::docid get_docid() const
Return the current docid.
Match documents which at least one subquery matches.
void init(const Xapian::Database &db) override
Set this PostingSource to the start of the list of postings.
Xapian-specific test helper functions and macros.
PostingSource * clone() const override
Clone the posting source.
bool at_end() const override
Return true if the current position is past the last entry in this list.
MyDontAskWeightPostingSource(Xapian::doccount num_docs_, Xapian::doccount last_docid_)
Xapian::doccount num_docs
Xapian::doccount get_termfreq_max() const
An upper bound on the number of documents this object can return.
PostingSource * release()
Start reference counting this object.
<unistd.h>, but with compat.
void init(const Xapian::Database &) override
Set this PostingSource to the start of the list of postings.
void mset_expect_order(const Xapian::MSet &A, Xapian::docid d1, Xapian::docid d2, Xapian::docid d3, Xapian::docid d4, Xapian::docid d5, Xapian::docid d6, Xapian::docid d7, Xapian::docid d8, Xapian::docid d9, Xapian::docid d10, Xapian::docid d11, Xapian::docid d12)
double get_maxweight() const
Return the currently set upper bound on what get_weight() can return.
void next(double min_wt)
Advance the current position to the next matching document.
Xapian::doccount get_termfreq_max() const override
An upper bound on the number of documents this object can return.
SlowDecreasingValueWeightPostingSource * clone() const override
Clone the posting source.
void next(double min_wt)
Advance the current position to the next matching document.
string get_description() const override
Return a string describing this object.
void set_weighting_scheme(const Weight &weight_)
Set the weighting scheme to use for queries.
unsigned XAPIAN_DOCID_BASE_TYPE docid
A unique identifier for a document.
Class representing a query.
string get_description() const override
Return a string describing this object.
void next(double wt) override
Advance the current position to the next matching document.
static void make_matchtimelimit1_db(Xapian::WritableDatabase &db, const string &)
#define TEST_EQUAL(a, b)
Test for equality of two things.
SlowDecreasingValueWeightPostingSource(int &count_)
void next(double) override
Advance the current position to the next matching document.
Xapian::docid get_docid() const override
Return the current docid.
CheckBoundsPostingSource * clone() const override
Clone the posting source.
void next(double wt) override
Advance the current position to the next matching document.
A handle representing a document in a Xapian database.
UnimplementedError indicates an attempt to use an unimplemented feature.
Xapian::doccount get_termfreq_min() const override
A lower bound on the number of documents this object can return.
Xapian::doccount get_termfreq_min() const override
A lower bound on the number of documents this object can return.
docids sort in descending order.
static const testcase testcases[]