66 void init(
double factor_)
override;
85 std::string
name()
const override;
87 std::string serialise()
const override;
88 LazyWeight* unserialise(
const std::string& serialised)
const override;
94 double get_maxpart()
const override;
99 double get_maxextra()
const override;
118 string desc =
"LazyWeight(";
119 desc += real_wt->name();
164 return pl->resolve_lazy_termweight(real_wt, stats, qlen, wqf, factor, shard);
177 LOGCALL(MATCH,
PostList *,
"LocalSubMatch::get_postlist", matcher | total_subqs_ptr);
180 return {
nullptr,
nullptr};
187 double factor = wt_factory.is_bool_weight_() ? 0.0 : 1.0;
193 unique_ptr<Xapian::Weight> extra_wt(wt_factory.clone());
195 extra_wt->init_(*total_stats, qlen, db);
196 if (extra_wt->get_maxextra() != 0.0) {
215 bool needs_doclen = wt_factory.get_sumpart_needs_doclength_();
218 unique_ptr<Xapian::Weight> wt(wt_factory.clone());
222 Assert(total_stats->collection_size);
223 wt->init_(*total_stats, qlen, factor,
227 res->set_weight(wt.release());
228 RETURN({res.release(), std::move(or_pl.
est)});
236 bool compound_weight,
243 bool weighted =
false;
248 pl = db->open_leaf_post_list(
term,
false);
250 weighted = (factor != 0.0);
253 pl = db->open_leaf_post_list(
term, need_positions);
256 if (pl && !need_positions) {
257 bool need_wdf = (weighted || compound_weight) &&
258 wt_factory.get_sumpart_needs_wdf_();
275 pl = db->open_leaf_post_list(
string(),
false);
290 if (pl && weighted) {
293 wt->
init_(*total_stats, qlen,
term, wqf, factor, db, pl);
300 wt =
new LazyWeight(pl, wt, total_stats, qlen, wqf, factor, db);
307 *termfreqs =
TermFreqs(total_stats->collection_size,
308 total_stats->rset_size,
309 total_stats->total_length);
310 }
else if (!lazy_weight) {
311 auto i = total_stats->termfreqs.find(
term);
312 Assert(i != total_stats->termfreqs.end());
313 *termfreqs = i->second;
318 RETURN({
nullptr,
nullptr});
static Xapian::Query query(Xapian::Query::op op, const string &t1=string(), const string &t2=string(), const string &t3=string(), const string &t4=string(), const string &t5=string(), const string &t6=string(), const string &t7=string(), const string &t8=string(), const string &t9=string(), const string &t10=string())
Class for estimating the total number of matching documents.
Xapian::Weight subclass which adds laziness.
double get_sumextra(Xapian::termcount doclen, Xapian::termcount uniqterms, Xapian::termcount wdfdocmax) const override
Calculate the term-independent weight component for a document.
double get_sumpart(Xapian::termcount wdf, Xapian::termcount doclen, Xapian::termcount uniqterms, Xapian::termcount wdfdocmax) const override
Calculate the weight contribution for this object's term to a document.
std::string name() const override
Return the name of this weighting scheme, e.g.
double get_maxextra() const override
Return an upper bound on what get_sumextra() can return for any document.
std::string serialise() const override
Return this object's parameters serialised as a single string.
const Xapian::Database::Internal * shard
LazyWeight * unserialise(const std::string &serialised) const override
Unserialise parameters.
LazyWeight(LeafPostList *pl_, Xapian::Weight *real_wt_, Xapian::Weight::Internal *stats_, Xapian::termcount qlen_, Xapian::termcount wqf__, double factor_, const Xapian::Database::Internal *shard_)
LazyWeight * clone() const override
Clone this object.
Xapian::Weight::Internal * stats
double get_maxpart() const override
Return an upper bound on what get_sumpart() can return for any document.
void init(double factor_) override
Allow the subclass to perform any initialisation it needs to.
Abstract base class for leaf postlists.
void set_term(std::string_view term_)
Set the term name.
void set_termweight(const Xapian::Weight *weight_)
Set the weighting scheme to use during matching.
virtual bool open_nearby_postlist(std::string_view term_, bool need_read_pos, LeafPostList *&pl) const
Open another postlist from the same database.
PostListAndEstimate open_post_list(const std::string &term, Xapian::termcount wqf, double factor, bool need_positions, bool compound_weight, Xapian::Internal::QueryOptimiser *qopt, bool lazy_weight, TermFreqs *termfreqs)
PostListAndEstimate get_postlist(PostListTree *matcher, Xapian::termcount *total_subqs_ptr)
Get PostList.
PostListAndEstimate make_synonym_postlist(PostListTree *pltree, PostListAndEstimate or_pl, double factor, const TermFreqs &termfreqs)
Convert a postlist into a synonym postlist.
A postlist comprising several postlists SYNONYMed together.
Virtual base class for Database internals.
Abstract base class for postlists.
Xapian::doccount get_termfreq() const
Get an estimate of the number of documents this PostList will return.
virtual void get_docid_range(docid &first, docid &last) const
Get the bounds on the range of docids this PostList can return.
Xapian::termcount get_total_subqs() const
void set_hint_postlist(LeafPostList *new_hint)
bool get_no_estimates() const
const LeafPostList * get_hint_postlist() const
InvalidOperationError indicates the API was used in an invalid way.
bool empty() const noexcept
Check if this query is Xapian::Query::MatchNothing.
Xapian::Internal::intrusive_ptr< Internal > internal
Class to hold statistics for a given collection.
Abstract base class for weighting schemes.
virtual Weight * clone() const =0
Clone this object.
virtual double get_maxpart() const =0
Return an upper bound on what get_sumpart() can return for any document.
void init_(const Internal &stats, Xapian::termcount query_len_, const std::string &term, Xapian::termcount wqf_, double factor, const Xapian::Database::Internal *shard, void *postlist)
Virtual base class for Database internals.
#define LOGCALL(CATEGORY, TYPE, FUNC, PARAMS)
Hierarchy of classes which Xapian can throw as exceptions.
Abstract base class for leaf postlists.
SubMatch class for a local database.
unsigned XAPIAN_TERMCOUNT_BASE_TYPE termcount
A counts of terms.
unsigned XAPIAN_DOCID_BASE_TYPE docid
A unique identifier for a document.
Various assertion macros.
Details passed around while building PostList tree from Query tree.
std::unique_ptr< EstimateOp > est
The frequencies for a term.
Xapian::doccount reltermfreq
Xapian::doccount termfreq
Xapian::termcount collfreq
Combine subqueries, weighting as if they are synonyms.
Abstract base class for termlists.
Xapian::Weight::Internal class, holding database and term statistics.