Stop apparent error from remote server when read-only client disconnects
[xapian.git] / xapian-core / backends / contiguousalldocspostlist.cc
blob04213a5d12024c5cb1ed6166b197e0a8db2d2b2f
1 /** @file contiguousalldocspostlist.cc
2 * @brief Iterate all document ids when they form a contiguous range.
3 */
4 /* Copyright (C) 2007,2008,2009 Olly Betts
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.
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.
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
21 #include <config.h>
23 #include <string>
25 #include "contiguousalldocspostlist.h"
27 #include "omassert.h"
28 #include "str.h"
30 using namespace std;
32 Xapian::doccount
33 ContiguousAllDocsPostList::get_termfreq() const
35 return doccount;
38 Xapian::docid
39 ContiguousAllDocsPostList::get_docid() const
41 Assert(did != 0);
42 Assert(!at_end());
43 return did;
46 Xapian::termcount
47 ContiguousAllDocsPostList::get_doclength() const
49 Assert(did != 0);
50 Assert(!at_end());
51 return db->get_doclength(did);
54 Xapian::termcount
55 ContiguousAllDocsPostList::get_wdf() const
57 Assert(did != 0);
58 Assert(!at_end());
59 return 1;
62 PositionList *
63 ContiguousAllDocsPostList::read_position_list()
65 // Throws the same exception.
66 return ContiguousAllDocsPostList::open_position_list();
69 PositionList *
70 ContiguousAllDocsPostList::open_position_list() const
72 throw Xapian::InvalidOperationError("Position lists not meaningful for ContiguousAllDocsPostList");
75 PostList *
76 ContiguousAllDocsPostList::next(Xapian::weight)
78 Assert(!at_end());
79 if (did == doccount) {
80 db = NULL;
81 } else {
82 ++did;
84 return NULL;
87 PostList *
88 ContiguousAllDocsPostList::skip_to(Xapian::docid target, Xapian::weight)
90 Assert(!at_end());
91 if (target > did) {
92 if (target > doccount) {
93 db = NULL;
94 } else {
95 did = target;
98 return NULL;
101 bool
102 ContiguousAllDocsPostList::at_end() const
104 return db.get() == NULL;
107 string
108 ContiguousAllDocsPostList::get_description() const
110 string msg("ContiguousAllDocsPostList(1..");
111 msg += str(doccount);
112 msg += ')';
113 return msg;