xapian-core  1.4.25
net_postlist.h
Go to the documentation of this file.
1 
4 /* Copyright (C) 2007,2009 Lemur Consulting Ltd
5  * Copyright (C) 2007,2008,2009,2011 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 #ifndef XAPIAN_INCLUDED_NET_POSTLIST_H
24 #define XAPIAN_INCLUDED_NET_POSTLIST_H
25 
26 #include <string>
27 
28 #include "api/leafpostlist.h"
29 #include "omassert.h"
30 #include "remote-database.h"
31 
32 using namespace std;
33 
36 class NetworkPostList : public LeafPostList {
37  friend class RemoteDatabase;
38 
40 
41  string postings;
42  bool started;
43  const char * pos;
44  const char * pos_end;
45 
48 
50 
52  void append_posting(const string & serialised) {
53  Assert(pos == NULL);
54  Assert(!started);
55  postings.append(serialised);
56  }
57 
58  public:
61  const string & term_)
62  : LeafPostList(term_),
63  db(db_), started(false), pos(NULL), pos_end(NULL),
64  lastdocid(0), lastwdf(0), termfreq(0)
65  {
66  termfreq = db->read_post_list(term, *this);
67  }
68 
70  Xapian::doccount get_termfreq() const;
71 
73  Xapian::docid get_docid() const;
74 
77 
80 
82  Xapian::termcount get_wdf() const;
83 
87 
90  PostList * next(double);
91 
94  PostList * skip_to(Xapian::docid did, double weight);
95 
97  bool at_end() const;
98 
100 
102  string get_description() const;
103 };
104 
105 #endif /* XAPIAN_INCLUDED_NET_POSTLIST_H */
#define Assert(COND)
Definition: omassert.h:122
Abstract base class for postlists.
Definition: postlist.h:37
Xapian::termcount get_doclength(Xapian::docid did) const
Get the length of a given document.
double weight
The weight of a document or term.
Definition: types.h:122
Xapian::Internal::intrusive_ptr< const RemoteDatabase > db
Definition: net_postlist.h:39
NetworkPostList(Xapian::Internal::intrusive_ptr< const RemoteDatabase > db_, const string &term_)
Constructor.
Definition: net_postlist.h:60
RemoteDatabase is the baseclass for remote database implementations.
STL namespace.
Xapian::termcount get_wdf_upper_bound(const string &term) const
Get an upper bound on the wdf of term term.
Abstract base class for leaf postlists.
Definition: leafpostlist.h:38
#define false
Definition: header.h:9
Abstract base class for leaf postlists.
unsigned XAPIAN_TERMCOUNT_BASE_TYPE termcount
A counts of terms.
Definition: types.h:72
const char * pos_end
Definition: net_postlist.h:44
RemoteDatabase is the baseclass for remote database implementations.
unsigned XAPIAN_DOCID_BASE_TYPE doccount
A count of documents.
Definition: types.h:38
Xapian::termcount get_unique_terms(Xapian::docid did) const
Get the number of unique term in document.
PositionList * open_position_list(Xapian::docid did, const string &tname) const
Open a position list for the given term in the given document.
Xapian::doccount read_post_list(const string &term, NetworkPostList &pl) const
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
Xapian::docid lastdocid
Definition: net_postlist.h:46
Xapian::termcount lastwdf
Definition: net_postlist.h:47
A postlist in a remote database.
Definition: net_postlist.h:36
const char * pos
Definition: net_postlist.h:43
void append_posting(const string &serialised)
Append a posting to the end of the postlist.
Definition: net_postlist.h:52
Xapian::doccount termfreq
Definition: net_postlist.h:49