[ci] Fix clang-santisers job for GHA change
[xapian.git] / xapian-core / backends / contiguousalldocspostlist.cc
blob2f4af81c5cf242a58a633915c7092661b3c29af7
1 /** @file
2 * @brief Iterate all document ids when they form a contiguous range.
3 */
4 /* Copyright (C) 2007,2008,2009,2011,2017 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::docid
33 ContiguousAllDocsPostList::get_docid() const
35 Assert(did != 0);
36 return did;
39 Xapian::termcount
40 ContiguousAllDocsPostList::get_wdf() const
42 Assert(did != 0);
43 return 1;
46 PositionList *
47 ContiguousAllDocsPostList::read_position_list()
49 // Throws the same exception.
50 return ContiguousAllDocsPostList::open_position_list();
53 PositionList *
54 ContiguousAllDocsPostList::open_position_list() const
56 throw Xapian::InvalidOperationError("Position lists not meaningful for ContiguousAllDocsPostList");
59 PostList *
60 ContiguousAllDocsPostList::next(double)
62 // Docids are contiguous from 1 so termfreq gives the highest docid.
63 if (did == termfreq) {
64 did = 0;
65 } else {
66 ++did;
68 return NULL;
71 PostList *
72 ContiguousAllDocsPostList::skip_to(Xapian::docid target, double)
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;
82 return NULL;
85 bool
86 ContiguousAllDocsPostList::at_end() const
88 return did == 0;
91 Xapian::termcount
92 ContiguousAllDocsPostList::get_wdf_upper_bound() const
94 return 1;
97 string
98 ContiguousAllDocsPostList::get_description() const
100 string msg("ContiguousAllDocsPostList(1..");
101 msg += str(termfreq);
102 msg += ')';
103 return msg;