36 if (items.size() < collapse_max) {
37 items.push_back(item);
38 items.back().collapse_key = string();
44 if (collapse_count == 0 && collapse_max != 1) {
48 make_heap(items.begin(), items.end(), mcmp);
52 if (mcmp(items.front(), item)) {
54 if (item.
wt > next_best_weight) next_best_weight = item.
wt;
58 next_best_weight = items.front().wt;
60 items.push_back(item);
61 push_heap(items.begin(), items.end(), mcmp);
62 pop_heap(items.begin(), items.end(), mcmp);
63 swap(old_item, items.back());
92 if (oldkey == table.end()) {
101 res = collapse_data.
add_item(item, collapse_max, mcmp, old_item);
112 double min_weight)
const 114 auto key = table.find(collapse_key);
116 Assert(key != table.end());
118 if (!percent_cutoff) {
120 return key->second.get_collapse_count();
123 if (key->second.get_next_best_weight() < min_weight) {
142 return matches_lower_bound;
149 for (
auto i = table.begin(); i != table.end(); ++i) {
150 if (i->second.get_collapse_count() > max_kept) {
151 max_kept = i->second.get_collapse_count();
152 if (max_kept == collapse_max) {
153 return matches_lower_bound;
157 return matches_lower_bound + (collapse_max - max_kept);
collapse_result process(Xapian::Internal::MSetItem &item, PostList *postlist, Xapian::Document::Internal &vsdoc, MSetCmp mcmp)
Handle a new MSetItem.
Abstract base class for postlists.
collapse_result add_item(const Xapian::Internal::MSetItem &item, Xapian::doccount collapse_max, MSetCmp mcmp, Xapian::Internal::MSetItem &old_item)
Handle a new MSetItem with this collapse key value.
A document in the database, possibly plus modifications.
Collapse documents with the same collapse key during the match.
virtual const std::string * get_collapse_key() const
If the collapse key is already known, return it.
bool(* MSetCmp)(const Xapian::Internal::MSetItem &, const Xapian::Internal::MSetItem &)
double wt
Weight calculated.
string collapse_key
Value which was used to collapse upon.
An item resulting from a query.
string get_value(Xapian::valueno slot) const
Get value by value number.
collapse_result
Enumeration reporting how a document was handled by the Collapser.
Xapian::doccount get_collapse_count(const std::string &collapse_key, int percent_cutoff, double min_weight) const
unsigned XAPIAN_DOCID_BASE_TYPE doccount
A count of documents.
Xapian::doccount get_matches_lower_bound() const
Various assertion macros.
Class tracking information for a given value of the collapse key.