xapian-core  2.0.0
net_postlist.cc
Go to the documentation of this file.
1 
4 /* Copyright (C) 2007 Lemur Consulting Ltd
5  * Copyright (C) 2007,2008,2009,2011,2012,2013,2015,2019 Olly Betts
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License as
9  * published by the Free Software Foundation; either version 2 of the
10  * License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, see
19  * <https://www.gnu.org/licenses/>.
20  */
21 
22 #include <config.h>
23 
24 #include "net_postlist.h"
25 
26 #include "omassert.h"
27 #include "pack.h"
29 
30 using namespace std;
31 
34 {
35  return lastdocid;
36 }
37 
40 {
41  return lastwdf;
42 }
43 
46 {
47  return db->open_position_list(lastdocid, term);
48 }
49 
50 PostList *
52 {
53  if (!started) {
54  started = true;
55  pos = postings.data();
56  pos_end = pos + postings.size();
57  lastdocid = 0;
58  }
59 
60  if (pos == pos_end) {
61  pos = NULL;
62  } else {
63  Xapian::docid inc;
64  if (!unpack_uint(&pos, pos_end, &inc) ||
65  !unpack_uint(&pos, pos_end, &lastwdf)) {
67  }
68  lastdocid += inc + 1;
69  }
70 
71  return NULL;
72 }
73 
74 PostList *
75 NetworkPostList::skip_to(Xapian::docid did, double min_weight)
76 {
77  if (!started)
78  next(min_weight);
79  while (pos && lastdocid < did)
80  next(min_weight);
81  return NULL;
82 }
83 
84 bool
86 {
87  return (pos == NULL && started);
88 }
89 
92 {
93  // This is only called when setting weights on PostList objects before
94  // a match, which shouldn't happen to NetworkPostList objects (as remote
95  // matching happens like a local match on the server).
96  Assert(false);
97  return 0;
98 }
99 
100 string
102 {
103  string desc = "NetworkPostList(";
104  description_append(desc, term);
105  desc += ')';
106  return desc;
107 }
PostList * skip_to(Xapian::docid did, double weight)
Skip forward to the next document with document ID >= the supplied document ID (the weight parameter ...
Definition: net_postlist.cc:75
std::string get_description() const
Get a description of the postlist.
Xapian::docid get_docid() const
Get the current document ID.
Definition: net_postlist.cc:33
bool at_end() const
Return true if and only if we've moved off the end of the list.
Definition: net_postlist.cc:85
PositionList * open_position_list() const
Read the position list for the term in the current document and return a pointer to it (not owned by ...
Definition: net_postlist.cc:45
Xapian::termcount get_wdf_upper_bound() const
Definition: net_postlist.cc:91
Xapian::termcount get_wdf() const
Get the Within Document Frequency of the term in the current document.
Definition: net_postlist.cc:39
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
Abstract base class for iterating term positions in a document.
Definition: positionlist.h:32
string term
Xapian::termpos pos
Append a string to an object description, escaping invalid UTF-8.
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
Postlists for remote databases.
Various assertion macros.
#define Assert(COND)
Definition: omassert.h:122
void unpack_throw_serialisation_error(const char *p)
Throw appropriate SerialisationError.
Definition: pack.cc:29
Pack types into strings and unpack them again.
bool unpack_uint(const char **p, const char *end, U *result)
Decode an unsigned integer from a string.
Definition: pack.h:346
void description_append(std::string &desc, std::string_view s)
Definition: unittest.cc:105