47 : num_docs(num_docs_), last_docid(last_docid_), did(0)
52 : num_docs(db.get_doccount()), last_docid(db.get_lastdocid()), did(0)
55 PostingSource*
clone()
const override {
68 void next(
double wt)
override {
71 if (did % 2 == 0) ++did;
77 if (did % 2 == 0) ++did;
82 return did > last_docid;
147 : num_docs(num_docs_), last_docid(last_docid_), did(0)
154 : num_docs(db.get_doccount()), last_docid(db.get_lastdocid()), did(0)
157 PostingSource*
clone()
const override {
166 return (did % 2) ? 1000 : 0.001;
176 void next(
double wt)
override {
188 return did > last_docid;
194 return "MyOddWeightingPostingSource";
210 mset_expect_order(mset, 1, 3, 5, 7, 9, 11, 13, 15, 17, 2);
252 : num_docs(num_docs_), last_docid(last_docid_), did(0)
258 PostingSource*
clone()
const override {
269 FAIL_TEST(
"MyDontAskWeightPostingSource::get_weight() called");
279 void next(
double wt)
override {
291 return did > last_docid;
297 return "MyDontAskWeightPostingSource";
307 tout <<
"OP_SCALE_WEIGHT 0\n";
313 tout <<
"OP_FILTER\n";
322 tout <<
"BoolWeight\n";
343 tout <<
"OP_FILTER\n";
352 tout <<
"OP_FILTER other way\n";
461 : did(0), maxid_accessed(maxid_accessed_) { }
466 if (did > maxid_accessed) {
467 FAIL_TEST(
"ChangeMaxweightPostingSource::get_weight() called "
468 "for docid " +
str(did) +
", max id accessed "
469 "should be " +
str(maxid_accessed));
480 set_maxweight(5 - did);
485 set_maxweight(5 - did);
488 bool at_end()
const override {
return did >= 5; }
491 return "ChangeMaxweightPostingSource";
595 #ifdef HAVE_TIMER_CREATE
596 class SlowDecreasingValueWeightPostingSource
601 SlowDecreasingValueWeightPostingSource(
int & count_)
602 :
Xapian::DecreasingValueWeightPostingSource(0), count(count_) { }
604 SlowDecreasingValueWeightPostingSource* clone()
const override {
605 return new SlowDecreasingValueWeightPostingSource(count);
608 void next(
double min_wt)
override {
618 for (
int wt = 20; wt > 0; --wt) {
630 #ifndef HAVE_TIMER_CREATE
631 SKIP_TEST(
"Enquire::set_time_limit() not implemented for this platform");
634 make_matchtimelimit1_db);
637 SlowDecreasingValueWeightPostingSource src(count);
659 :
Xapian::DecreasingValueWeightPostingSource(0),
660 doclen_lb(doclen_lb_),
661 doclen_ub(doclen_ub_) { }
701 : clone_count(clone_count_)
704 PostingSource*
clone()
const override {
764 PostingSource*
clone()
const override {
771 if (shard_index == 0) {
781 return last_docid / 2;
786 void next(
double wt)
override {
789 if (did > last_docid) did = 0;
795 if (did > last_docid) did = 0;
805 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},
DEFINE_TESTCASE(externalsource1, backend &&!remote &&!multi)
static const testcase testcases[]
Xapian::Database get_database(const string &dbname)
test functionality of the Xapian API
Xapian::doccount get_termfreq_max() const override
An upper 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.
void next(double) override
Advance the current position to the next matching document.
void reset(const Xapian::Database &, Xapian::doccount) override
Set this PostingSource to the start of the list of postings.
bool at_end() const override
Return true if the current position is past the last entry in this list.
void skip_to(Xapian::docid to_did, double) override
Advance to the specified docid.
double get_weight() const override
Return the weight contribution for the current document.
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.
string get_description() const override
Return a string describing this object.
ChangeMaxweightPostingSource(Xapian::docid maxid_accessed_)
Xapian::docid maxid_accessed
Xapian::doccount & doclen_ub
CheckBoundsPostingSource(Xapian::doccount &doclen_lb_, Xapian::doccount &doclen_ub_)
void reset(const Xapian::Database &database, Xapian::doccount shard_index) override
Set this PostingSource to the start of the list of postings.
Xapian::doccount & doclen_lb
CheckBoundsPostingSource * clone() const override
Clone the posting source.
Xapian::doccount get_termfreq_min() const override
A lower bound on the number of documents this object can return.
CloneTestPostingSource(int &clone_count_)
void reset(const Xapian::Database &, Xapian::doccount) override
Set this PostingSource to the start of the list of postings.
void skip_to(Xapian::docid, double) override
Advance to the specified docid.
string get_description() const override
Return a string describing this object.
void next(double) override
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.
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.
Xapian::docid get_docid() const override
Return the current docid.
PostingSource * clone() const override
Clone the posting source.
PostingSource subclass for injecting tf bounds and estimate.
Xapian::doccount get_termfreq_max() const override
An upper bound on the number of documents this object can return.
void skip_to(Xapian::docid, double) override
Advance to the specified docid.
EstimatePS(Xapian::doccount lb_, Xapian::doccount est_, Xapian::doccount ub_)
string get_description() const override
Return a string describing this object.
PostingSource * clone() const override
Clone the posting source.
void next(double) override
Advance the current position to the next matching document.
bool at_end() const override
Return true if the current position is past the last entry in this list.
void reset(const Xapian::Database &, Xapian::doccount) override
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.
Xapian::doccount get_termfreq_est() const override
An estimate of 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::doccount last_docid
Xapian::docid get_docid() const override
Return the current docid.
string get_description() const override
Return a string describing this object.
Xapian::doccount get_termfreq_max() const override
An upper 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.
double get_weight() const override
Return the weight contribution for the current document.
void skip_to(Xapian::docid to_did, double wt) override
Advance to the specified docid.
void next(double wt) override
Advance the current position to the next matching document.
void reset(const Xapian::Database &db, Xapian::doccount) override
Set this PostingSource to the start of the list of postings.
MyDontAskWeightPostingSource(Xapian::doccount num_docs_, Xapian::doccount last_docid_)
bool at_end() const override
Return true if the current position is past the last entry in this list.
MyDontAskWeightPostingSource()
Xapian::doccount num_docs
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.
Xapian::doccount num_docs
MyOddPostingSource(const Xapian::Database &db)
Xapian::doccount get_termfreq_est() const override
An estimate of the number of documents this object can return.
Xapian::doccount last_docid
Xapian::doccount get_termfreq_max() const override
An upper bound on the number of documents this object can return.
void skip_to(Xapian::docid to_did, double wt) override
Advance to the specified docid.
void reset(const Xapian::Database &, Xapian::doccount) override
Set this PostingSource to the start of the list of postings.
PostingSource * clone() const override
Clone the posting source.
MyOddPostingSource(Xapian::doccount num_docs_, Xapian::doccount last_docid_)
Xapian::docid get_docid() const override
Return the current docid.
bool at_end() const override
Return true if the current position is past the last entry in this list.
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::doccount get_termfreq_min() const override
A lower bound on the number of documents this object can return.
MyOddWeightingPostingSource(Xapian::doccount num_docs_, Xapian::doccount last_docid_)
string get_description() const override
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 next(double wt) override
Advance the current position to the next matching document.
void skip_to(Xapian::docid to_did, double wt) override
Advance to the specified docid.
PostingSource * clone() const override
Clone the posting source.
double get_weight() const override
Return the weight contribution for the current document.
void init(const Xapian::Database &) override
Older method which did the same job as reset().
MyOddWeightingPostingSource(const Xapian::Database &db)
Xapian::doccount num_docs
Xapian::doccount get_termfreq_est() const override
An estimate of the number of documents this object can return.
Xapian::doccount last_docid
Xapian::docid get_docid() const override
Return the current docid.
Xapian::docid get_docid() const override
Return the current docid.
OnlyTheFirstPostingSource(bool allow_clone_)
Xapian::doccount get_termfreq_min() const override
A lower bound on the number of documents this object can return.
void next(double wt) override
Advance the current position to the next matching document.
bool at_end() const override
Return true if the current position is past the last entry in this list.
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.
void skip_to(Xapian::docid to_did, double wt) override
Advance to the specified docid.
void reset(const Xapian::Database &db, Xapian::doccount shard_index) override
Set this PostingSource to the start of the list of postings.
PostingSource * clone() const override
Clone the posting source.
Xapian::doccount last_docid
Xapian::doccount get_termfreq_max() const override
An upper bound on the number of documents this object can return.
Class implementing a "boolean" weighting scheme.
An indexed database of documents.
Xapian::termcount get_doclength_lower_bound() const
Get a lower bound on the length of a document in this DB.
Xapian::doccount get_doccount() const
Get the number of documents in the database.
Xapian::docid get_lastdocid() const
Get the highest document id which has been used in the database.
Xapian::termcount get_doclength_upper_bound() const
Get an upper bound on the length of a document in this DB.
Read weights from a value which is known to decrease as docid increases.
void reset(const Database &db_, Xapian::doccount shard_index) override
Set this PostingSource to the start of the list of postings.
void next(double min_wt) override
Advance the current position to the next matching document.
Class representing a document.
void add_value(Xapian::valueno slot, std::string_view value)
Add a value to a slot in this document.
void set_weighting_scheme(const Weight &weight)
Set the weighting scheme to use.
MSet get_mset(doccount first, doccount maxitems, doccount checkatleast=0, const RSet *rset=NULL, const MatchDecider *mdecider=NULL) const
Run the query.
void set_time_limit(double time_limit)
Set a time limit for the match.
void set_cutoff(int percent_threshold, double weight_threshold=0)
Set lower bounds on percentage and/or weight.
void set_query(const Query &query, termcount query_length=0)
Set the query.
void set_docid_order(docid_order order)
Set sort order for document IDs.
@ DESCENDING
docids sort in descending order.
A posting source which returns a fixed weight for all documents.
Xapian::docid get_docid() const override
Return the current docid.
void next(double min_wt) override
Advance the current position to the next matching document.
bool at_end() const override
Return true if the current position is past the last entry in this list.
void reset(const Database &db_, Xapian::doccount shard_index) override
Set this PostingSource to the start of the list of postings.
void skip_to(Xapian::docid min_docid, double min_wt) override
Advance to the specified docid.
bool check(Xapian::docid min_docid, double min_wt) override
Check if the specified docid occurs.
InvalidArgumentError indicates an invalid parameter value was passed to the API.
InvalidOperationError indicates the API was used in an invalid way.
Iterator over a Xapian::MSet.
Class representing a list of search results.
Xapian::doccount size() const
Return number of items in this MSet object.
double get_max_possible() const
The maximum possible weight any document could achieve.
bool empty() const
Return true if this MSet object is empty.
std::string get_description() const
Return a string describing this object.
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.
Xapian::doccount get_matches_estimated() const
Estimate of the total number of matching documents.
Base class which provides an "external" source of postings.
PostingSource * release()
Start reference counting this object.
double get_maxweight() const noexcept
Return the currently set upper bound on what get_weight() can return.
Class representing a query.
@ OP_SCALE_WEIGHT
Scale the weight contributed by a subquery.
@ OP_AND_MAYBE
Match the first subquery taking extra weight from other subqueries.
@ OP_AND
Match only documents which all subqueries match.
@ OP_OR
Match documents which at least one subquery matches.
@ OP_FILTER
Match like OP_AND but only taking weight from the first subquery.
UnimplementedError indicates an attempt to use an unimplemented feature.
void skip_to(Xapian::docid min_docid, double min_wt)
Advance to the specified docid.
Xapian::doccount get_termfreq_est() const
An estimate of the number of documents this object can return.
Xapian::doccount get_termfreq_max() const
An upper bound on the number of documents this object can return.
bool at_end() const
Return true if the current position is past the last entry in this list.
Xapian::doccount get_termfreq_min() const
A lower bound on the number of documents this object can return.
Xapian::docid get_docid() const
Return the current docid.
A posting source which reads weights from a value slot.
void reset(const Database &db_, Xapian::doccount shard_index)
Set this PostingSource to the start of the list of postings.
This class provides read/write access to a database.
Xapian::docid add_document(const Xapian::Document &doc)
Add a document to the database.
void sleep(double t)
Sleep until the time represented by this object.
string str(int value)
Convert int to std::string.
The Xapian namespace contains public interfaces for the Xapian library.
std::string sortable_serialise(double value)
Convert a floating point number to a string, preserving sort order.
unsigned XAPIAN_DOCID_BASE_TYPE doccount
A count of documents.
unsigned XAPIAN_DOCID_BASE_TYPE docid
A unique identifier for a document.
<unistd.h>, but with compat.
Convert types to std::string.
#define TEST_REL(A, REL, B)
Test a relation holds,e.g. TEST_REL(a,>,b);.
std::ostringstream tout
The debug printing stream.
#define FAIL_TEST(MSG)
Fail the current testcase with message MSG.
#define SKIP_TEST(MSG)
Skip the current testcase with message MSG.
#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.
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)
Xapian-specific test helper functions and macros.
#define TEST_EXCEPTION(TYPE, CODE)
Check that CODE throws exactly Xapian exception TYPE.
Public interfaces for the Xapian library.