1 /** @file extraweightpostlist.cc
2 * @brief PostList which adds on a term-independent weight contribution
4 /* Copyright 2017 Olly Betts
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License as
8 * published by the Free Software Foundation; either version 2 of the
9 * License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
23 #include "extraweightpostlist.h"
26 #include "postlisttree.h"
32 ExtraWeightPostList::get_weight(Xapian::termcount doclen
,
33 Xapian::termcount unique_terms
) const
35 /* Weight::get_sumextra() takes two parameters (document length and number
36 * of unique terms) but none of the currently implemented weighting schemes
37 * actually use the latter - it was added because it's likely to be wanted
38 * at some point, and so that we got all the incompatible changes needed to
39 * add support for the number of unique terms over with in one go.
41 double sum_extra
= weight
->get_sumextra(doclen
, unique_terms
);
42 AssertRel(sum_extra
,<=,max_extra
);
43 return pl
->get_weight(doclen
, unique_terms
) + sum_extra
;
47 ExtraWeightPostList::recalc_maxweight()
49 return pl
->recalc_maxweight() + max_extra
;
53 ExtraWeightPostList::next(double w_min
)
55 PostList
* res
= pl
->next(w_min
- max_extra
);
59 pltree
->force_recalc();
65 ExtraWeightPostList::skip_to(Xapian::docid
, double)
67 // ExtraWeightPostList's parent will be PostListTree which doesn't
68 // call skip_to() or check().
74 ExtraWeightPostList::get_description() const
76 string desc
= "ExtraWeightPostList(";
77 desc
+= pl
->get_description();
78 desc
+= ", max_extra=";
79 desc
+= str(max_extra
);