xapian-core  2.0.0
Classes | Public Member Functions | Private Member Functions | Private Attributes | Friends | List of all members
ProtoMSet Class Reference

#include <protomset.h>

+ Collaboration diagram for ProtoMSet:

Classes

class  MCmpAdaptor
 Adapt MSetCmp to be usable with min_heap. More...
 

Public Member Functions

 ProtoMSet (Xapian::doccount first_, Xapian::doccount max_items, Xapian::doccount check_at_least_, MSetCmp mcmp_, Xapian::Enquire::Internal::sort_setting sort_by_, Xapian::termcount total_subqs_, PostListTree &pltree_, Xapian::valueno collapse_key, Xapian::doccount collapse_max, int percent_threshold_, double percent_threshold_factor_, double max_possible_, bool stop_once_full_, double time_limit)
 
 ProtoMSet (const ProtoMSet &)=delete
 
ProtoMSetoperator= (const ProtoMSet &)=delete
 
Collapserget_collapser ()
 
bool full () const
 
double get_min_weight () const
 
void update_max_weight (double weight)
 
bool checked_enough ()
 
bool handle_min_weight_pending (bool finalising=false)
 Resolve a pending min_weight change. More...
 
bool early_reject (Result &new_item, bool calculated_weight, SpyMaster &spymaster, const Xapian::Document &doc)
 
bool process (Result &&new_item, ValueStreamDocument &vsdoc)
 Process new_item. More...
 
Xapian::doccount add (Result &&item)
 
void replace (Xapian::doccount old_item, Result &&b)
 
void set_new_min_weight (double min_wt)
 
void finalise_percentages ()
 
Xapian::MSet finalise (const Xapian::MatchDecider *mdecider, const std::vector< std::unique_ptr< LocalSubMatch >> &locals, const Xapian::VecUniquePtr< EstimateOp > &estimates)
 

Private Member Functions

Xapian::doccount size () const
 

Private Attributes

Xapian::doccount max_size
 Maximum size the ProtoMSet needs to grow to. More...
 
Xapian::doccount check_at_least
 
Xapian::Enquire::Internal::sort_setting sort_by
 
MSetCmp mcmp
 
double min_weight = 0.0
 Minimum threshold on the weight. More...
 
double max_weight = 0.0
 The highest document weight seen. More...
 
bool min_weight_pending = false
 
Xapian::doccount known_matching_docs = 0
 Count of how many known matching documents have been processed so far. More...
 
std::vector< Resultresults
 The items in the proto-MSet. More...
 
std::vector< Xapian::doccountmin_heap
 A heap of offsets into results. More...
 
Xapian::doccount first
 First entry wanted in MSet. More...
 
Xapian::termcount total_subqs
 How many weighted leaf subqueries there are. More...
 
Xapian::termcount max_weight_subqs_matched = 0
 The number of subqueries which matched to give max_weight. More...
 
int percent_threshold
 
double percent_threshold_factor
 
double percent_scale = 0.0
 
PostListTreepltree
 
Collapser collapser
 
double max_possible
 
bool stop_once_full
 
TimeOut timeout
 

Friends

class MCmpAdaptor
 

Detailed Description

Definition at line 38 of file protomset.h.

Constructor & Destructor Documentation

◆ ProtoMSet() [1/2]

ProtoMSet::ProtoMSet ( Xapian::doccount  first_,
Xapian::doccount  max_items,
Xapian::doccount  check_at_least_,
MSetCmp  mcmp_,
Xapian::Enquire::Internal::sort_setting  sort_by_,
Xapian::termcount  total_subqs_,
PostListTree pltree_,
Xapian::valueno  collapse_key,
Xapian::doccount  collapse_max,
int  percent_threshold_,
double  percent_threshold_factor_,
double  max_possible_,
bool  stop_once_full_,
double  time_limit 
)
inline

Definition at line 135 of file protomset.h.

References max_size, and results.

◆ ProtoMSet() [2/2]

ProtoMSet::ProtoMSet ( const ProtoMSet )
delete

Member Function Documentation

◆ add()

Xapian::doccount ProtoMSet::add ( Result &&  item)
inline

◆ checked_enough()

bool ProtoMSet::checked_enough ( )
inline

◆ early_reject()

bool ProtoMSet::early_reject ( Result new_item,
bool  calculated_weight,
SpyMaster spymaster,
const Xapian::Document doc 
)
inline

◆ finalise()

Xapian::MSet ProtoMSet::finalise ( const Xapian::MatchDecider mdecider,
const std::vector< std::unique_ptr< LocalSubMatch >> &  locals,
const Xapian::VecUniquePtr< EstimateOp > &  estimates 
)
inline

◆ finalise_percentages()

void ProtoMSet::finalise_percentages ( )
inline

◆ full()

bool ProtoMSet::full ( ) const
inline

Definition at line 172 of file protomset.h.

References max_size, and size().

Referenced by add(), finalise(), and process().

◆ get_collapser()

Collapser& ProtoMSet::get_collapser ( )
inline

Definition at line 170 of file protomset.h.

References collapser.

◆ get_min_weight()

double ProtoMSet::get_min_weight ( ) const
inline

Definition at line 174 of file protomset.h.

References min_weight.

Referenced by Matcher::get_local_mset().

◆ handle_min_weight_pending()

bool ProtoMSet::handle_min_weight_pending ( bool  finalising = false)
inline

Resolve a pending min_weight change.

Only called when there's a percentage weight cut-off.

Definition at line 202 of file protomset.h.

References Assert, check_at_least, checked_enough(), collapser, Xapian::Enquire::Internal::DOCID, known_matching_docs, min_weight, min_weight_pending, Xapian::Enquire::Internal::REL, Xapian::Enquire::Internal::REL_VAL, Collapser::result_has_moved(), results, size(), and sort_by.

Referenced by add(), and finalise_percentages().

◆ operator=()

ProtoMSet& ProtoMSet::operator= ( const ProtoMSet )
delete

◆ process()

bool ProtoMSet::process ( Result &&  new_item,
ValueStreamDocument vsdoc 
)
inline

Process new_item.

Conceptually this is "add new_item", but taking into account collapsing.

Definition at line 301 of file protomset.h.

References add(), Assert, Collapser::check(), checked_enough(), collapser, EMPTY, full(), Collapser::old_item, Collapser::process(), REJECT, REPLACE, replace(), results, stop_once_full, and update_max_weight().

Referenced by Matcher::get_local_mset().

◆ replace()

void ProtoMSet::replace ( Xapian::doccount  old_item,
Result &&  b 
)
inline

Definition at line 408 of file protomset.h.

References Assert, min_heap, rare, results, and Heap::siftdown().

Referenced by process().

◆ set_new_min_weight()

void ProtoMSet::set_new_min_weight ( double  min_wt)
inline

◆ size()

Xapian::doccount ProtoMSet::size ( ) const
inlineprivate

Definition at line 132 of file protomset.h.

References results.

Referenced by add(), finalise(), full(), and handle_min_weight_pending().

◆ update_max_weight()

void ProtoMSet::update_max_weight ( double  weight)
inline

Friends And Related Function Documentation

◆ MCmpAdaptor

friend class MCmpAdaptor
friend

Definition at line 52 of file protomset.h.

Member Data Documentation

◆ check_at_least

Xapian::doccount ProtoMSet::check_at_least
private

Definition at line 60 of file protomset.h.

Referenced by checked_enough(), finalise(), and handle_min_weight_pending().

◆ collapser

Collapser ProtoMSet::collapser
private

◆ first

Xapian::doccount ProtoMSet::first
private

First entry wanted in MSet.

Definition at line 104 of file protomset.h.

Referenced by finalise().

◆ known_matching_docs

Xapian::doccount ProtoMSet::known_matching_docs = 0
private

Count of how many known matching documents have been processed so far.

Used to implement "check_at_least".

Definition at line 92 of file protomset.h.

Referenced by add(), checked_enough(), early_reject(), finalise(), and handle_min_weight_pending().

◆ max_possible

double ProtoMSet::max_possible
private

Definition at line 126 of file protomset.h.

Referenced by finalise().

◆ max_size

Xapian::doccount ProtoMSet::max_size
private

Maximum size the ProtoMSet needs to grow to.

This is the maximum rank we care about.

Definition at line 58 of file protomset.h.

Referenced by checked_enough(), full(), and ProtoMSet().

◆ max_weight

double ProtoMSet::max_weight = 0.0
private

The highest document weight seen.

This weight may not actually be present in results if we're not sorting primarily by relevance, or if min_weight > max_weight.

Definition at line 84 of file protomset.h.

Referenced by add(), finalise(), finalise_percentages(), set_new_min_weight(), and update_max_weight().

◆ max_weight_subqs_matched

Xapian::termcount ProtoMSet::max_weight_subqs_matched = 0
private

The number of subqueries which matched to give max_weight.

Definition at line 114 of file protomset.h.

Referenced by finalise_percentages(), and update_max_weight().

◆ mcmp

MSetCmp ProtoMSet::mcmp
private

Definition at line 64 of file protomset.h.

Referenced by add(), early_reject(), finalise(), and ProtoMSet::MCmpAdaptor::operator()().

◆ min_heap

std::vector<Xapian::doccount> ProtoMSet::min_heap
private

A heap of offsets into results.

Created lazily once we actually need it.

Definition at line 101 of file protomset.h.

Referenced by add(), early_reject(), replace(), and set_new_min_weight().

◆ min_weight

double ProtoMSet::min_weight = 0.0
private

Minimum threshold on the weight.

If the primary result ordering is by decreasing relevance (i.e. sort_by is REL or REL_VAL) then once the min_heap kicks in this threshold is raised to the lowest weight in the proto-mset.

Enquire::set_cutoff() can also affect min_weight - an absolute threshold determines the initial value; a percentage threshold raises the threshold each time max_weight increases (unless it's already higher than the value the percentage threshold results in).

Definition at line 77 of file protomset.h.

Referenced by add(), finalise(), get_min_weight(), handle_min_weight_pending(), and set_new_min_weight().

◆ min_weight_pending

bool ProtoMSet::min_weight_pending = false
private

◆ percent_scale

double ProtoMSet::percent_scale = 0.0
private

Definition at line 120 of file protomset.h.

Referenced by finalise(), and finalise_percentages().

◆ percent_threshold

int ProtoMSet::percent_threshold
private

Definition at line 116 of file protomset.h.

Referenced by finalise(), finalise_percentages(), and update_max_weight().

◆ percent_threshold_factor

double ProtoMSet::percent_threshold_factor
private

Definition at line 118 of file protomset.h.

Referenced by finalise(), finalise_percentages(), and update_max_weight().

◆ pltree

PostListTree& ProtoMSet::pltree
private

Definition at line 122 of file protomset.h.

Referenced by early_reject(), and update_max_weight().

◆ results

std::vector<Result> ProtoMSet::results
private

◆ sort_by

Xapian::Enquire::Internal::sort_setting ProtoMSet::sort_by
private

Definition at line 62 of file protomset.h.

Referenced by add(), and handle_min_weight_pending().

◆ stop_once_full

bool ProtoMSet::stop_once_full
private

Definition at line 128 of file protomset.h.

Referenced by process().

◆ timeout

TimeOut ProtoMSet::timeout
private

Definition at line 130 of file protomset.h.

Referenced by checked_enough().

◆ total_subqs

Xapian::termcount ProtoMSet::total_subqs
private

How many weighted leaf subqueries there are.

Used for scaling percentages when the highest weighted document doesn't "match all terms".

Definition at line 111 of file protomset.h.

Referenced by finalise_percentages().


The documentation for this class was generated from the following file: