xapian-core  2.0.0
valuegepostlist.cc
Go to the documentation of this file.
1 
4 /* Copyright 2007,2008,2011,2013,2025,2026 Olly Betts
5  * Copyright 2008 Lemur Consulting Ltd
6  * Copyright 2010 Richard Boulton
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, see
20  * <https://www.gnu.org/licenses/>.
21  */
22 
23 #include <config.h>
24 
25 #include "valuegepostlist.h"
26 
27 #include "estimateop.h"
28 #include "omassert.h"
29 #include "str.h"
31 
32 using namespace std;
33 
34 PostList *
36 {
37  Assert(db);
38  if (!valuelist) {
39  valuelist = db->open_value_list(slot);
40  valuelist->next();
41  if (estimate_op) estimate_op->report_first(valuelist->get_docid());
42  } else {
43  valuelist->next();
44  }
45  while (!valuelist->at_end()) {
46  const string & v = valuelist->get_value();
47  if (v >= begin) {
48  ++accepted;
49  return NULL;
50  }
51  ++rejected;
52  valuelist->next();
53  }
54  db = NULL;
55  return NULL;
56 }
57 
58 PostList *
60 {
61  Assert(db);
62  if (!valuelist) valuelist = db->open_value_list(slot);
63  valuelist->skip_to(did);
64  while (!valuelist->at_end()) {
65  const string & v = valuelist->get_value();
66  if (v >= begin) {
67  ++accepted;
68  return NULL;
69  }
70  ++rejected;
71  valuelist->next();
72  }
73  db = NULL;
74  return NULL;
75 }
76 
77 PostList *
78 ValueGePostList::check(Xapian::docid did, double, bool &valid)
79 {
80  Assert(db);
81  AssertRelParanoid(did, <=, db->get_lastdocid());
82  if (!valuelist) valuelist = db->open_value_list(slot);
83  valid = valuelist->check(did);
84  if (!valid) {
85  return NULL;
86  }
87  const string & v = valuelist->get_value();
88  valid = (v >= begin);
89  if (valid)
90  ++accepted;
91  else
92  ++rejected;
93  return NULL;
94 }
95 
96 string
98 {
99  string desc = "ValueGePostList(";
100  desc += str(slot);
101  desc += ", ";
102  description_append(desc, begin);
103  desc += ")";
104  return desc;
105 }
PostList * skip_to(Xapian::docid, double w_min)
Skip forward to the specified docid.
PostList * check(Xapian::docid did, double w_min, bool &valid)
Check if the specified docid occurs in this postlist.
std::string get_description() const
Return a string description of this object.
Abstract base class for postlists.
Definition: postlist.h:40
PostList * next()
Advance the current position to the next document in the postlist.
Definition: postlist.h:168
Append a string to an object description, escaping invalid UTF-8.
Calculated bounds on and estimate of number of matches.
string str(int value)
Convert int to std::string.
Definition: str.cc:91
unsigned XAPIAN_DOCID_BASE_TYPE docid
A unique identifier for a document.
Definition: types.h:51
Various assertion macros.
#define AssertRelParanoid(A, REL, B)
Definition: omassert.h:130
#define Assert(COND)
Definition: omassert.h:122
Convert types to std::string.
void description_append(std::string &desc, std::string_view s)
Definition: unittest.cc:105
Return document ids matching a >= test on a specified doc value.