xapian-core  1.4.26
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 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, write to the Free Software
19  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
20  * USA
21  */
22 
23 #include <config.h>
24 
25 #include "net_postlist.h"
26 #include "net/length.h"
27 #include "omassert.h"
29 
30 using namespace std;
31 
34 {
35  return termfreq;
36 }
37 
40 {
41  return lastdocid;
42 }
43 
46 {
47  return db->get_doclength(lastdocid);
48 }
49 
52 {
53  return db->get_unique_terms(lastdocid);
54 }
55 
58 {
59  return lastwdf;
60 }
61 
64 {
65  return db->open_position_list(lastdocid, term);
66 }
67 
68 PostList *
70 {
71  if (!started) {
72  started = true;
73  pos = postings.data();
74  pos_end = pos + postings.size();
75  lastdocid = 0;
76  }
77 
78  if (pos == pos_end) {
79  pos = NULL;
80  } else {
81  Xapian::docid inc;
82  decode_length(&pos, pos_end, inc);
83  lastdocid += inc + 1;
84 
85  decode_length(&pos, pos_end, lastwdf);
86  }
87 
88  return NULL;
89 }
90 
91 PostList *
92 NetworkPostList::skip_to(Xapian::docid did, double min_weight)
93 {
94  if (!started)
95  next(min_weight);
96  while (pos && lastdocid < did)
97  next(min_weight);
98  return NULL;
99 }
100 
101 bool
103 {
104  return (pos == NULL && started);
105 }
106 
109 {
110  // This is only called when setting weights on PostList objects before
111  // a match, which shouldn't happen to NetworkPostList objects (as remote
112  // matching happens like a local match on the server).
113  Assert(false);
114  return 0;
115 }
116 
117 string
119 {
120  string desc = "NetworkPostList(";
121  description_append(desc, term);
122  desc += ')';
123  return desc;
124 }
#define Assert(COND)
Definition: omassert.h:122
Xapian::docid get_docid() const
Get the current document ID.
Definition: net_postlist.cc:39
Abstract base class for postlists.
Definition: postlist.h:37
length encoded as a string
STL namespace.
Xapian::termcount get_unique_terms() const
Get the number of unique terms in the current document.
Definition: net_postlist.cc:51
unsigned XAPIAN_TERMCOUNT_BASE_TYPE termcount
A counts of terms.
Definition: types.h:72
Xapian::termcount get_wdf() const
Get the Within Document Frequency of the term in the current document.
Definition: net_postlist.cc:57
void description_append(std::string &desc, const std::string &s)
Definition: unittest.cc:102
string get_description() const
Get a description of the postlist.
Internal * next()
Advance the current position to the next document in the postlist.
Definition: postlist.h:194
Xapian::termcount get_wdf_upper_bound() const
Postlists for remote databases.
Xapian::termcount get_doclength() const
Get the length of the current document.
Definition: net_postlist.cc:45
bool at_end() const
Return true if and only if we&#39;ve moved off the end of the list.
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:92
Append a string to an object description, escaping invalid UTF-8.
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:63
unsigned XAPIAN_DOCID_BASE_TYPE doccount
A count of documents.
Definition: types.h:38
Xapian::doccount get_termfreq() const
Get number of documents indexed by this term.
Definition: net_postlist.cc:33
Various assertion macros.
unsigned XAPIAN_DOCID_BASE_TYPE docid
A unique identifier for a document.
Definition: types.h:52
Abstract base class for iterating term positions in a document.
Definition: positionlist.h:31
void decode_length(const char **p, const char *end, unsigned &out)
Decode a length encoded by encode_length.
Definition: length.cc:94