65 void init(
double factor_)
override;
82 std::string
name()
const override;
84 std::string serialise()
const override;
85 LazyWeight* unserialise(
const std::string& serialised)
const override;
90 double get_maxpart()
const override;
94 double get_maxextra()
const override;
113 string desc =
"LazyWeight(";
114 desc += real_wt->name();
155 return pl->resolve_lazy_termweight(real_wt, stats, qlen, wqf, factor);
168 LOGCALL(MATCH,
bool,
"LocalSubMatch::prepare_match", nowait | total_stats);
181 LOGCALL_VOID(MATCH,
"LocalSubMatch::start_match", first | maxitems | check_at_least | total_stats);
184 (void)check_at_least;
186 stats = &total_stats;
194 LOGCALL(MATCH,
PostList*,
"LocalSubMatch::get_postlist", matcher | total_subqs_ptr |
Literal(
"[total_subqs]"));
204 double factor = wt_factory->is_bool_weight_() ? 0.0 : 1.0;
209 AutoPtr<Xapian::Weight> extra_wt(wt_factory->clone());
211 extra_wt->init_(*stats, qlen);
212 if (extra_wt->get_maxextra() != 0.0) {
227 LOGCALL(MATCH,
PostList *,
"LocalSubMatch::make_synonym_postlist", or_pl | matcher | factor | wdf_disjoint);
234 AutoPtr<SynonymPostList> res(
new SynonymPostList(or_pl, matcher, len_lb,
236 AutoPtr<Xapian::Weight> wt(wt_factory->clone());
244 if (
usual(stats->collection_size != 0)) {
247 wt->init_(*stats, qlen, factor,
248 freqs.termfreq, freqs.reltermfreq, freqs.collfreq);
250 res->set_weight(wt.release());
263 LOGCALL(MATCH,
LeafPostList *,
"LocalSubMatch::open_post_list", term | wqf | factor | need_positions | qopt | lazy_weight);
265 bool weighted = (factor != 0.0 && !term.empty());
268 if (!term.empty() && !need_positions) {
269 if ((!weighted && !in_synonym) ||
270 !wt_factory->get_sumpart_needs_wdf_()) {
272 db->get_freqs(term, &sub_tf, NULL);
278 pl = db->open_post_list(
string());
294 pl = db->open_post_list(term);
299 auto res = stats->termfreqs.emplace(term,
TermFreqs());
305 &res.first->second.termfreq,
306 &res.first->second.collfreq);
313 wt->
init_(*stats, qlen, term, wqf, factor, pl);
320 wt =
new LazyWeight(pl, wt, stats, qlen, wqf, factor);
Abstract base class for postlists.
InvalidOperationError indicates the API was used in an invalid way.
A PostList which contains no entries.
A PostList which contains no entries.
const LeafPostList * get_hint_postlist() const
Xapian::Weight::Internal * stats
Xapian::Weight subclass which adds laziness.
#define LOGCALL_VOID(CATEGORY, FUNC, PARAMS)
virtual Xapian::doccount get_termfreq() const =0
Return the exact term frequency.
void set_hint_postlist(LeafPostList *new_hint)
Abstract base class for leaf postlists.
Xapian::Internal::intrusive_ptr< Internal > internal
virtual Weight * clone() const =0
Clone this object.
Abstract base class for leaf postlists.
LazyWeight(LeafPostList *pl_, Xapian::Weight *real_wt_, Xapian::Weight::Internal *stats_, Xapian::termcount qlen_, Xapian::termcount wqf__, double factor_)
virtual double get_maxpart() const =0
Return an upper bound on what get_sumpart() can return for any document.
bool prepare_match(bool nowait, Xapian::Weight::Internal &total_stats)
Fetch and collate statistics.
Hierarchy of classes which Xapian can throw as exceptions.
unsigned XAPIAN_TERMCOUNT_BASE_TYPE termcount
A counts of terms.
void set_termweight(const Xapian::Weight *weight_)
Set the weighting scheme to use during matching.
double get_sumextra(Xapian::termcount doclen, Xapian::termcount uniqterms) const override
Calculate the term-independent weight component for a document.
LazyWeight * clone() const override
Clone this object.
Xapian::termcount get_total_subqs() const
PostList * get_postlist(MultiMatch *matcher, Xapian::termcount *total_subqs_ptr, Xapian::Weight::Internal &total_stats)
Get PostList.
std::string name() const override
Return the name of this weighting scheme.
void init_(const Internal &stats, Xapian::termcount query_len_, const std::string &term, Xapian::termcount wqf_, double factor)
virtual TermFreqs get_termfreq_est_using_stats(const Xapian::Weight::Internal &stats) const
Get an estimate for the termfreq and reltermfreq, given the stats.
virtual Xapian::doccount get_termfreq_max() const =0
Get an upper bound on the number of documents indexed by this term.
virtual Xapian::doccount get_termfreq_est() const =0
Get an estimate of the number of documents indexed by this term.
Xapian::Weight::Internal class, holding database and term statistics.
Class to hold statistics for a given collection.
A postlist comprising several postlists SYNONYMed together.
Details passed around while building PostList tree from Query tree.
void accumulate_stats(const Xapian::Database::Internal &sub_db, const Xapian::RSet &rset)
Accumulate the rtermfreqs for terms in the query.
SubMatch class for a local database.
Combine subqueries, weighting as if they are synonyms.
virtual LeafPostList * open_nearby_postlist(const std::string &term_) const
Open another postlist from the same database.
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())
The frequencies for a term.
double get_maxextra() const override
Return an upper bound on what get_sumextra() can return for any document.
void set_term(const std::string &term_)
Set the term name.
unsigned XAPIAN_DOCID_BASE_TYPE doccount
A count of documents.
bool empty() const
Check if this query is Xapian::Query::MatchNothing.
LazyWeight * unserialise(const std::string &serialised) const override
Unserialise parameters.
LeafPostList * open_post_list(const std::string &term, Xapian::termcount wqf, double factor, bool need_positions, bool in_synonym, QueryOptimiser *qopt, bool lazy_weight)
Abstract base class for termlists.
std::string serialise() const override
Return this object's parameters serialised as a single string.
PostList * make_synonym_postlist(PostList *or_pl, MultiMatch *matcher, double factor, bool wdf_disjoint)
Convert a postlist into a synonym postlist.
Various assertion macros.
void init(double factor_) override
Allow the subclass to perform any initialisation it needs to.
double get_maxpart() const override
Return an upper bound on what get_sumpart() can return for any document.
Wrapper around standard unique_ptr template.
#define LOGCALL(CATEGORY, TYPE, FUNC, PARAMS)
void start_match(Xapian::doccount first, Xapian::doccount maxitems, Xapian::doccount check_at_least, Xapian::Weight::Internal &total_stats)
Start the match.
double get_sumpart(Xapian::termcount wdf, Xapian::termcount doclen, Xapian::termcount uniqterms) const override
Calculate the weight contribution for this object's term to a document.
Abstract base class for weighting schemes.