root / tags / 1.0.8 / xapian-core / backends / flint / contiguousalldocspostlist.cc
| Revision 9463, 2.5 kB (checked in by olly, 15 months ago) |
|---|
| Line | |
|---|---|
| 1 | /** @file contiguousalldocspostlist.cc |
| 2 | * @brief Iterate all document ids when they form a contiguous range. |
| 3 | */ |
| 4 | /* Copyright (C) 2007 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 "utils.h" |
| 29 | |
| 30 | using namespace std; |
| 31 | |
| 32 | ContiguousAllDocsPostList::~ContiguousAllDocsPostList() { } |
| 33 | |
| 34 | Xapian::doccount |
| 35 | ContiguousAllDocsPostList::get_termfreq() const |
| 36 | { |
| 37 | return doccount; |
| 38 | } |
| 39 | |
| 40 | Xapian::docid |
| 41 | ContiguousAllDocsPostList::get_docid() const |
| 42 | { |
| 43 | Assert(did != 0); |
| 44 | Assert(!at_end()); |
| 45 | return did; |
| 46 | } |
| 47 | |
| 48 | Xapian::doclength |
| 49 | ContiguousAllDocsPostList::get_doclength() const |
| 50 | { |
| 51 | Assert(did != 0); |
| 52 | Assert(!at_end()); |
| 53 | return db->get_doclength(did); |
| 54 | } |
| 55 | |
| 56 | Xapian::termcount |
| 57 | ContiguousAllDocsPostList::get_wdf() const |
| 58 | { |
| 59 | Assert(did != 0); |
| 60 | Assert(!at_end()); |
| 61 | return 1; |
| 62 | } |
| 63 | |
| 64 | PositionList * |
| 65 | ContiguousAllDocsPostList::read_position_list() |
| 66 | { |
| 67 | // Throws the same exception. |
| 68 | return ContiguousAllDocsPostList::open_position_list(); |
| 69 | } |
| 70 | |
| 71 | PositionList * |
| 72 | ContiguousAllDocsPostList::open_position_list() const |
| 73 | { |
| 74 | throw Xapian::InvalidOperationError("Position lists not meaningful for ContiguousAllDocsPostList"); |
| 75 | } |
| 76 | |
| 77 | PostList * |
| 78 | ContiguousAllDocsPostList::next(Xapian::weight) |
| 79 | { |
| 80 | Assert(!at_end()); |
| 81 | if (did == doccount) { |
| 82 | db = NULL; |
| 83 | } else { |
| 84 | ++did; |
| 85 | } |
| 86 | return NULL; |
| 87 | } |
| 88 | |
| 89 | PostList * |
| 90 | ContiguousAllDocsPostList::skip_to(Xapian::docid target, Xapian::weight) |
| 91 | { |
| 92 | Assert(!at_end()); |
| 93 | if (target > did) { |
| 94 | if (target > doccount) { |
| 95 | db = NULL; |
| 96 | } else { |
| 97 | did = target; |
| 98 | } |
| 99 | } |
| 100 | return NULL; |
| 101 | } |
| 102 | |
| 103 | bool |
| 104 | ContiguousAllDocsPostList::at_end() const |
| 105 | { |
| 106 | return db.get() == NULL; |
| 107 | } |
| 108 | |
| 109 | string |
| 110 | ContiguousAllDocsPostList::get_description() const |
| 111 | { |
| 112 | string msg("ContiguousAllDocsPostList(1.."); |
| 113 | msg += om_tostring(doccount); |
| 114 | msg += ')'; |
| 115 | return msg; |
| 116 | } |
Note: See TracBrowser
for help on using the browser.
