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

Class tracking information for a given value of the collapse key. More...

#include <collapser.h>

+ Collaboration diagram for CollapseData:

Public Member Functions

 CollapseData (Xapian::doccount item, Xapian::docid did)
 Construct with the given item. More...
 
collapse_result check_item (const std::vector< Result > &results, const Result &result, Xapian::doccount collapse_max, MSetCmp mcmp, Xapian::doccount &old_item)
 Check a new result with this collapse key value. More...
 
void set_item (Xapian::doccount item)
 Set item after constructing with a placeholder. More...
 
void add_item (const std::vector< Result > &results, Xapian::doccount item, Xapian::doccount collapse_max, MSetCmp mcmp)
 Complete update of new result with this collapse key value. More...
 
void result_has_moved (Xapian::doccount from, Xapian::doccount to)
 Process relocation of entry in results. More...
 
double get_next_best_weight () const
 The highest weight of a document we've rejected. More...
 
Xapian::doccount get_collapse_count () const
 The number of documents we've rejected. More...
 

Private Attributes

std::vector< std::pair< Xapian::doccount, Xapian::docid > > items
 Currently kept MSet entries for this value of the collapse key. More...
 
double next_best_weight = 0.0
 The highest weight of a document we've rejected. More...
 
Xapian::doccount collapse_count = 0
 The number of documents we've rejected. More...
 

Detailed Description

Class tracking information for a given value of the collapse key.

Definition at line 42 of file collapser.h.

Constructor & Destructor Documentation

◆ CollapseData()

CollapseData::CollapseData ( Xapian::doccount  item,
Xapian::docid  did 
)
inline

Construct with the given item.

Definition at line 65 of file collapser.h.

Member Function Documentation

◆ add_item()

void CollapseData::add_item ( const std::vector< Result > &  results,
Xapian::doccount  item,
Xapian::doccount  collapse_max,
MSetCmp  mcmp 
)

Complete update of new result with this collapse key value.

Parameters
resultsThe results so far.
itemThe new item (index into results).
collapse_maxMax no. of items for each collapse key value.
mcmpResult comparison functor.

Definition at line 106 of file collapser.cc.

References Result::get_docid(), and Heap::replace().

◆ check_item()

collapse_result CollapseData::check_item ( const std::vector< Result > &  results,
const Result result,
Xapian::doccount  collapse_max,
MSetCmp  mcmp,
Xapian::doccount old_item 
)

Check a new result with this collapse key value.

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

Parameters
resultsThe results so far.
resultThe new result.
collapse_maxMax no. of items for each collapse key value.
mcmpResult comparison functor.
[out]old_itemItem to be replaced (when REPLACE is returned).
Returns
How to handle result: ADD, REJECT or REPLACE.

Definition at line 33 of file collapser.cc.

References ADD, Result::get_docid(), Result::get_weight(), Heap::make(), REJECT, Heap::replace(), and REPLACE.

Referenced by Collapser::check().

◆ get_collapse_count()

Xapian::doccount CollapseData::get_collapse_count ( ) const
inline

The number of documents we've rejected.

Definition at line 131 of file collapser.h.

References collapse_count.

◆ get_next_best_weight()

double CollapseData::get_next_best_weight ( ) const
inline

The highest weight of a document we've rejected.

Definition at line 128 of file collapser.h.

References next_best_weight.

◆ result_has_moved()

void CollapseData::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 113 of file collapser.h.

References Assert, and items.

Referenced by Collapser::result_has_moved().

◆ set_item()

void CollapseData::set_item ( Xapian::doccount  item)

Set item after constructing with a placeholder.

Parameters
itemThe new item (index into results).

Definition at line 98 of file collapser.cc.

References AssertEq.

Member Data Documentation

◆ collapse_count

Xapian::doccount CollapseData::collapse_count = 0
private

The number of documents we've rejected.

Definition at line 61 of file collapser.h.

Referenced by get_collapse_count().

◆ items

std::vector<std::pair<Xapian::doccount, Xapian::docid> > CollapseData::items
private

Currently kept MSet entries for this value of the collapse key.

If collapse_max > 1, then this is a min-heap once collapse_count > 0.

The first member of the pair is the index into proto_mset.results and the second is the docid of the entry (used to detect if the entry in proto_mset.results we were referring to has been dropped).

FIXME: We expect collapse_max to be small, so perhaps we should preallocate space for that many entries and/or allocate space in larger blocks to divvy up?

Definition at line 55 of file collapser.h.

Referenced by result_has_moved().

◆ next_best_weight

double CollapseData::next_best_weight = 0.0
private

The highest weight of a document we've rejected.

Definition at line 58 of file collapser.h.

Referenced by get_next_best_weight().


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