xapian-core  1.4.26
contiguousalldocspostlist.cc
Go to the documentation of this file.
1 
4 /* Copyright (C) 2007,2008,2009,2011 Olly Betts
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
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.
15  *
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
19  */
20 
21 #include <config.h>
22 
23 #include <string>
24 
26 
27 #include "omassert.h"
28 #include "str.h"
29 
30 #include "xapian/error.h"
31 
32 using namespace std;
33 
36 {
37  return doccount;
38 }
39 
42 {
43  Assert(did != 0);
44  Assert(!at_end());
45  return did;
46 }
47 
50 {
51  Assert(did != 0);
52  Assert(!at_end());
53  return db->get_doclength(did);
54 }
55 
58 {
59  Assert(did != 0);
60  Assert(!at_end());
61  return db->get_unique_terms(did);
62 }
63 
66 {
67  Assert(did != 0);
68  Assert(!at_end());
69  return 1;
70 }
71 
74 {
75  // Throws the same exception.
77 }
78 
81 {
82  throw Xapian::InvalidOperationError("Position lists not meaningful for ContiguousAllDocsPostList");
83 }
84 
85 PostList *
87 {
88  Assert(!at_end());
89  if (did == doccount) {
90  db = NULL;
91  } else {
92  ++did;
93  }
94  return NULL;
95 }
96 
97 PostList *
99 {
100  Assert(!at_end());
101  if (target > did) {
102  if (target > doccount) {
103  db = NULL;
104  } else {
105  did = target;
106  }
107  }
108  return NULL;
109 }
110 
111 bool
113 {
114  return db.get() == NULL;
115 }
116 
119 {
120  return 1;
121 }
122 
123 string
125 {
126  string msg("ContiguousAllDocsPostList(1..");
127  msg += str(doccount);
128  msg += ')';
129  return msg;
130 }
#define Assert(COND)
Definition: omassert.h:122
Abstract base class for postlists.
Definition: postlist.h:37
bool at_end() const
Return true if and only if we&#39;re off the end of the list.
PositionList * read_position_list()
Throws InvalidOperationError.
InvalidOperationError indicates the API was used in an invalid way.
Definition: error.h:283
Iterate all document ids when they form a contiguous range.
Xapian::termcount get_wdf_upper_bound() const
Always return 1 (wdf isn&#39;t totally meaningful for us).
Xapian::termcount get_doclength() const
Return the length of current document.
STL namespace.
Convert types to std::string.
PostList * skip_to(Xapian::docid target, double w_min)
Skip ahead to next document with docid >= target.
Hierarchy of classes which Xapian can throw as exceptions.
unsigned XAPIAN_TERMCOUNT_BASE_TYPE termcount
A counts of terms.
Definition: types.h:72
Xapian::termcount get_unique_terms() const
Return the number of unique terms.
Internal * next()
Advance the current position to the next document in the postlist.
Definition: postlist.h:194
string str(int value)
Convert int to std::string.
Definition: str.cc:90
Xapian::doccount get_termfreq() const
Return the term frequency.
Xapian::termcount get_wdf() const
Always return 1 (wdf isn&#39;t totally meaningful for us).
unsigned XAPIAN_DOCID_BASE_TYPE doccount
A count of documents.
Definition: types.h:38
Various assertion macros.
unsigned XAPIAN_DOCID_BASE_TYPE docid
A unique identifier for a document.
Definition: types.h:52
Abstract base class for iterating term positions in a document.
Definition: positionlist.h:31
std::string get_description() const
Return a string description of this object.
Xapian::docid get_docid() const
Return the current docid.
PositionList * open_position_list() const
Throws InvalidOperationError.