Branch data Line data Source code
1 : : /** @file contiguousalldocspostlist.cc
2 : : * @brief Iterate all document ids when they form a contiguous range.
3 : : */
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, 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 : :
25 : : #include "contiguousalldocspostlist.h"
26 : :
27 : : #include "omassert.h"
28 : : #include "str.h"
29 : :
30 : : using namespace std;
31 : :
32 : : Xapian::doccount
33 : 638 : ContiguousAllDocsPostList::get_termfreq() const
34 : : {
35 : 638 : return doccount;
36 : : }
37 : :
38 : : Xapian::docid
39 : 35943 : ContiguousAllDocsPostList::get_docid() const
40 : : {
41 : : Assert(did != 0);
42 : 35943 : return did;
43 : : }
44 : :
45 : : Xapian::termcount
46 : 23623 : ContiguousAllDocsPostList::get_wdf() const
47 : : {
48 : : Assert(did != 0);
49 : 23623 : return 1;
50 : : }
51 : :
52 : : PositionList *
53 : 0 : ContiguousAllDocsPostList::read_position_list()
54 : : {
55 : : // Throws the same exception.
56 : 0 : return ContiguousAllDocsPostList::open_position_list();
57 : : }
58 : :
59 : : PositionList *
60 : 0 : ContiguousAllDocsPostList::open_position_list() const
61 : : {
62 [ # # ][ # # ]: 0 : throw Xapian::InvalidOperationError("Position lists not meaningful for ContiguousAllDocsPostList");
[ # # ]
63 : : }
64 : :
65 : : PostList *
66 : 33567 : ContiguousAllDocsPostList::next(double)
67 : : {
68 [ + + ]: 33567 : if (did == doccount) {
69 : 278 : did = 0;
70 : : } else {
71 : 33289 : ++did;
72 : : }
73 : 33567 : return NULL;
74 : : }
75 : :
76 : : PostList *
77 : 32 : ContiguousAllDocsPostList::skip_to(Xapian::docid target, double)
78 : : {
79 [ + - ]: 32 : if (target > did) {
80 [ - + ]: 32 : if (target > doccount) {
81 : 0 : did = 0;
82 : : } else {
83 : 32 : did = target;
84 : : }
85 : : }
86 : 32 : return NULL;
87 : : }
88 : :
89 : : bool
90 : 33622 : ContiguousAllDocsPostList::at_end() const
91 : : {
92 : 33622 : return did == 0;
93 : : }
94 : :
95 : : string
96 : 0 : ContiguousAllDocsPostList::get_description() const
97 : : {
98 [ # # ]: 0 : string msg("ContiguousAllDocsPostList(1..");
99 [ # # ][ # # ]: 0 : msg += str(doccount);
100 [ # # ]: 0 : msg += ')';
101 : 0 : return msg;
102 : : }
|