xapian-core  1.4.25
valuegepostlist.cc
Go to the documentation of this file.
1 
4 /* Copyright 2007,2008,2011,2013 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, write to the Free Software
20  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21  */
22 
23 #include <config.h>
24 
25 #include "valuegepostlist.h"
26 
27 #include "omassert.h"
28 #include "str.h"
30 
31 using namespace std;
32 
33 PostList *
35 {
36  Assert(db);
37  if (!valuelist) valuelist = db->open_value_list(slot);
38  valuelist->next();
39  while (!valuelist->at_end()) {
40  const string & v = valuelist->get_value();
41  if (v >= begin) return NULL;
42  valuelist->next();
43  }
44  db = NULL;
45  return NULL;
46 }
47 
48 PostList *
50 {
51  Assert(db);
52  if (!valuelist) valuelist = db->open_value_list(slot);
53  valuelist->skip_to(did);
54  while (!valuelist->at_end()) {
55  const string & v = valuelist->get_value();
56  if (v >= begin) return NULL;
57  valuelist->next();
58  }
59  db = NULL;
60  return NULL;
61 }
62 
63 PostList *
64 ValueGePostList::check(Xapian::docid did, double, bool &valid)
65 {
66  Assert(db);
67  AssertRelParanoid(did, <=, db->get_lastdocid());
68  if (!valuelist) valuelist = db->open_value_list(slot);
69  valid = valuelist->check(did);
70  if (!valid) {
71  return NULL;
72  }
73  const string & v = valuelist->get_value();
74  valid = (v >= begin);
75  return NULL;
76 }
77 
78 string
80 {
81  string desc = "ValueGePostList(";
82  desc += str(slot);
83  desc += ", ";
84  description_append(desc, begin);
85  desc += ")";
86  return desc;
87 }
PostList * check(Xapian::docid did, double w_min, bool &valid)
Check if the specified docid occurs in this postlist.
#define Assert(COND)
Definition: omassert.h:122
Abstract base class for postlists.
Definition: postlist.h:37
STL namespace.
Convert types to std::string.
#define AssertRelParanoid(A, REL, B)
Definition: omassert.h:130
void description_append(std::string &desc, const std::string &s)
Definition: unittest.cc:102
Internal * next()
Advance the current position to the next document in the postlist.
Definition: postlist.h:194
Return document ids matching a >= test on a specified doc value.
string str(int value)
Convert int to std::string.
Definition: str.cc:90
Append a string to an object description, escaping invalid UTF-8.
PostList * skip_to(Xapian::docid, double w_min)
Skip forward to the specified docid.
std::string get_description() const
Return a string description of this object.
Various assertion macros.
unsigned XAPIAN_DOCID_BASE_TYPE docid
A unique identifier for a document.
Definition: types.h:52