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

The Collapser class tracks collapse keys and the documents they match. More...

#include <collapser.h>

+ Collaboration diagram for Collapser:

Public Member Functions

 Collapser (Xapian::valueno slot_, Xapian::doccount collapse_max_, std::vector< Result > &results_, MSetCmp mcmp_)
 
 operator bool () const
 Return true if collapsing is active for this match. More...
 
collapse_result check (Result &result, Xapian::Document::Internal &vsdoc)
 Check a new result. More...
 
void process (collapse_result action, Xapian::doccount item)
 Handle a new Result. More...
 
void result_has_moved (Xapian::doccount from, Xapian::doccount to)
 Process relocation of entry in results. More...
 
Xapian::doccount get_collapse_count (const std::string &collapse_key, int percent_threshold, double min_weight) const
 
Xapian::doccount get_docs_considered () const
 
Xapian::doccount get_dups_ignored () const
 
Xapian::doccount get_entries () const
 
Xapian::doccount get_matches_lower_bound () const
 
void finalise (double min_weight, int percent_threshold)
 

Public Attributes

Xapian::doccount old_item = 0
 Replaced item when REPLACE is returned by collapse(). More...
 

Private Member Functions

bool operator() (Xapian::doccount a, Xapian::doccount b) const
 Adapt mcmp to be usable with min_heap. More...
 

Private Attributes

std::unordered_map< std::string, CollapseDatatable
 Map from collapse key values to the items we're keeping for them. More...
 
Xapian::doccount entry_count = 0
 How many items we're currently keeping in table. More...
 
Xapian::doccount no_collapse_key = 0
 How many documents have we seen without a collapse key? More...
 
Xapian::doccount dups_ignored = 0
 How many documents with duplicate collapse keys we have ignored. More...
 
Xapian::doccount docs_considered = 0
 How many documents we've considered for collapsing. More...
 
Xapian::valueno slot
 The value slot we're getting collapse keys from. More...
 
Xapian::doccount collapse_max
 The maximum number of items to keep for each collapse key value. More...
 
std::vector< Result > & results
 
MSetCmp mcmp
 
CollapseDataptr = NULL
 Pointer to CollapseData when NEW or ADD is in progress. More...
 

Detailed Description

The Collapser class tracks collapse keys and the documents they match.

Definition at line 135 of file collapser.h.

Constructor & Destructor Documentation

◆ Collapser()

Collapser::Collapser ( Xapian::valueno  slot_,
Xapian::doccount  collapse_max_,
std::vector< Result > &  results_,
MSetCmp  mcmp_ 
)
inline

Definition at line 184 of file collapser.h.

Member Function Documentation

◆ check()

collapse_result Collapser::check ( Result result,
Xapian::Document::Internal vsdoc 
)

Check a new result.

If this method determines the action to take is NEW or ADD then the proto-mset should be updated and then process() called to complete the update (if the result doesn't actually get added, then it's OK not to follow up with a call to process()).

Parameters
resultThe new result.
vsdocDocument for getting values.
Returns
How to handle result: EMPTY, NEW, ADD, REJECT or REPLACE.

Definition at line 126 of file collapser.cc.

References ADD, CollapseData::check_item(), EMPTY, Result::get_collapse_key(), Result::get_docid(), Xapian::Document::Internal::get_value(), NEW, REJECT, REPLACE, and Result::set_collapse_key().

Referenced by ProtoMSet::process().

◆ finalise()

void Collapser::finalise ( double  min_weight,
int  percent_threshold 
)

Definition at line 237 of file collapser.cc.

Referenced by ProtoMSet::finalise().

◆ get_collapse_count()

Xapian::doccount Collapser::get_collapse_count ( const std::string &  collapse_key,
int  percent_threshold,
double  min_weight 
) const

Definition at line 185 of file collapser.cc.

References Assert.

◆ get_docs_considered()

Xapian::doccount Collapser::get_docs_considered ( ) const
inline

Definition at line 243 of file collapser.h.

References docs_considered.

Referenced by ProtoMSet::finalise().

◆ get_dups_ignored()

Xapian::doccount Collapser::get_dups_ignored ( ) const
inline

Definition at line 245 of file collapser.h.

References dups_ignored.

Referenced by ProtoMSet::finalise().

◆ get_entries()

Xapian::doccount Collapser::get_entries ( ) const
inline

Definition at line 247 of file collapser.h.

References entry_count.

◆ get_matches_lower_bound()

Xapian::doccount Collapser::get_matches_lower_bound ( ) const

Definition at line 212 of file collapser.cc.

Referenced by ProtoMSet::finalise().

◆ operator bool()

Collapser::operator bool ( ) const
inline

Return true if collapsing is active for this match.

Definition at line 194 of file collapser.h.

References collapse_max.

◆ operator()()

bool Collapser::operator() ( Xapian::doccount  a,
Xapian::doccount  b 
) const
inlineprivate

Adapt mcmp to be usable with min_heap.

Definition at line 176 of file collapser.h.

References mcmp, and results.

◆ process()

void Collapser::process ( collapse_result  action,
Xapian::doccount  item 
)

Handle a new Result.

Parameters
actionThe collapse_result returned by check().
itemThe new item (index into results).

Definition at line 164 of file collapser.cc.

References ADD, Assert, and NEW.

Referenced by ProtoMSet::process().

◆ result_has_moved()

void Collapser::result_has_moved ( Xapian::doccount  from,
Xapian::doccount  to 
)
inline

Process relocation of entry in results.

Parameters
fromThe old item (index into results).
toThe new item (index into results).

Definition at line 223 of file collapser.h.

References Assert, rare, CollapseData::result_has_moved(), results, and table.

Referenced by ProtoMSet::handle_min_weight_pending().

Member Data Documentation

◆ collapse_max

Xapian::doccount Collapser::collapse_max
private

The maximum number of items to keep for each collapse key value.

Definition at line 166 of file collapser.h.

Referenced by operator bool().

◆ docs_considered

Xapian::doccount Collapser::docs_considered = 0
private

How many documents we've considered for collapsing.

We use this statistic to improve matches_estimated (by considering the rate of collapsing).

Definition at line 160 of file collapser.h.

Referenced by get_docs_considered().

◆ dups_ignored

Xapian::doccount Collapser::dups_ignored = 0
private

How many documents with duplicate collapse keys we have ignored.

We use this statistic to improve matches_estimated (by considering the rate of collapsing) and matches_upper_bound.

Definition at line 153 of file collapser.h.

Referenced by get_dups_ignored().

◆ entry_count

Xapian::doccount Collapser::entry_count = 0
private

How many items we're currently keeping in table.

Definition at line 140 of file collapser.h.

Referenced by get_entries().

◆ mcmp

MSetCmp Collapser::mcmp
private

Definition at line 170 of file collapser.h.

Referenced by operator()().

◆ no_collapse_key

Xapian::doccount Collapser::no_collapse_key = 0
private

How many documents have we seen without a collapse key?

We use this statistic to improve matches_lower_bound.

Definition at line 146 of file collapser.h.

◆ old_item

Xapian::doccount Collapser::old_item = 0

Replaced item when REPLACE is returned by collapse().

Definition at line 182 of file collapser.h.

Referenced by ProtoMSet::process().

◆ ptr

CollapseData* Collapser::ptr = NULL
private

Pointer to CollapseData when NEW or ADD is in progress.

Definition at line 173 of file collapser.h.

◆ results

std::vector<Result>& Collapser::results
private

Definition at line 168 of file collapser.h.

Referenced by operator()(), and result_has_moved().

◆ slot

Xapian::valueno Collapser::slot
private

The value slot we're getting collapse keys from.

Definition at line 163 of file collapser.h.

◆ table

std::unordered_map<std::string, CollapseData> Collapser::table
private

Map from collapse key values to the items we're keeping for them.

Definition at line 137 of file collapser.h.

Referenced by result_has_moved().


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