xapian-core  2.0.0
leafpostlist.cc
Go to the documentation of this file.
1 
4 /* Copyright (C) 2007,2009,2011,2013,2014,2017,2024 Olly Betts
5  * Copyright (C) 2009 Lemur Consulting Ltd
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License as
9  * published by the Free Software Foundation; either version 2 of the
10  * License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, see
19  * <https://www.gnu.org/licenses/>.
20  */
21 
22 #include <config.h>
23 
24 #include "xapian/weight.h"
25 
26 #include "leafpostlist.h"
27 #include "matcher/orpositionlist.h"
28 #include "omassert.h"
29 #include "debuglog.h"
30 
31 using namespace std;
32 
34 {
35  delete weight;
36 }
37 
38 double
40  Xapian::termcount unique_terms,
41  Xapian::termcount wdfdocmax) const
42 {
43  if (!weight) return 0;
44  double sumpart = weight->get_sumpart(get_wdf(), doclen,
45  unique_terms, wdfdocmax);
46  AssertRel(sumpart, <=, weight->get_maxpart());
47  return sumpart;
48 }
49 
50 double
52 {
53  return weight ? weight->get_maxpart() : 0;
54 }
55 
58 {
59  return weight ? 1 : 0;
60 }
61 
62 void
64 {
65  orposlist->add_poslist(read_position_list());
66 }
67 
68 bool
69 LeafPostList::open_nearby_postlist(std::string_view, bool, LeafPostList*&) const
70 {
71  return false;
72 }
Abstract base class for leaf postlists.
Definition: leafpostlist.h:40
Xapian::termcount count_matching_subqs() const
Count the number of leaf subqueries which match at the current position.
Definition: leafpostlist.cc:57
void gather_position_lists(OrPositionList *orposlist)
Gather PositionList* objects for a subtree.
Definition: leafpostlist.cc:63
double get_weight(Xapian::termcount doclen, Xapian::termcount unique_terms, Xapian::termcount wdfdocmax) const
Return the weight contribution for the current position.
Definition: leafpostlist.cc:39
virtual bool open_nearby_postlist(std::string_view term_, bool need_read_pos, LeafPostList *&pl) const
Open another postlist from the same database.
Definition: leafpostlist.cc:69
double recalc_maxweight()
Recalculate the upper bound on what get_weight() can return.
Definition: leafpostlist.cc:51
void add_poslist(PositionList *poslist)
Debug logging macros.
Abstract base class for leaf postlists.
unsigned XAPIAN_TERMCOUNT_BASE_TYPE termcount
A counts of terms.
Definition: types.h:64
Various assertion macros.
#define AssertRel(A, REL, B)
Definition: omassert.h:123
Merge two PositionList objects using an OR operation.
Weighting scheme API.