xapian-core  2.0.0
contiguousalldocspostlist.cc
Go to the documentation of this file.
1 
4 /* Copyright (C) 2007,2008,2009,2011,2017 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, see
18  * <https://www.gnu.org/licenses/>.
19  */
20 
21 #include <config.h>
22 
23 #include <string>
24 
26 
27 #include "omassert.h"
28 #include "str.h"
29 
30 using namespace std;
31 
34 {
35  Assert(did != 0);
36  return did;
37 }
38 
41 {
42  Assert(did != 0);
43  return 1;
44 }
45 
48 {
49  // Throws the same exception.
51 }
52 
55 {
56  throw Xapian::InvalidOperationError("Position lists not meaningful for ContiguousAllDocsPostList");
57 }
58 
59 PostList *
61 {
62  // Docids are contiguous from 1 so termfreq gives the highest docid.
63  if (did == termfreq) {
64  did = 0;
65  } else {
66  ++did;
67  }
68  return NULL;
69 }
70 
71 PostList *
73 {
74  if (target > did) {
75  // Docids are contiguous from 1 so termfreq gives the highest docid.
76  if (target > termfreq) {
77  did = 0;
78  } else {
79  did = target;
80  }
81  }
82  return NULL;
83 }
84 
85 bool
87 {
88  return did == 0;
89 }
90 
93 {
94  return 1;
95 }
96 
97 string
99 {
100  string msg("ContiguousAllDocsPostList(1..");
101  msg += str(termfreq);
102  msg += ')';
103  return msg;
104 }
std::string get_description() const
Return a string description of this object.
Xapian::termcount get_wdf() const
Always return 1 (wdf isn't totally meaningful for us).
PositionList * open_position_list() const
Throws InvalidOperationError.
PostList * skip_to(Xapian::docid target, double w_min)
Skip ahead to next document with docid >= target.
PositionList * read_position_list()
Throws InvalidOperationError.
bool at_end() const
Return true if and only if we're off the end of the list.
Xapian::termcount get_wdf_upper_bound() const
Always return 1 (wdf isn't totally meaningful for us).
Xapian::docid get_docid() const
Return the current docid.
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
InvalidOperationError indicates the API was used in an invalid way.
Definition: error.h:271
Abstract base class for iterating term positions in a document.
Definition: positionlist.h:32
Iterate all document ids when they form a contiguous range.
string str(int value)
Convert int to std::string.
Definition: str.cc:91
unsigned XAPIAN_TERMCOUNT_BASE_TYPE termcount
A counts of terms.
Definition: types.h:64
unsigned XAPIAN_DOCID_BASE_TYPE docid
A unique identifier for a document.
Definition: types.h:51
Various assertion macros.
#define Assert(COND)
Definition: omassert.h:122
Convert types to std::string.