Branch data Line data Source code
1 : : /** @file net_postlist.h
2 : : * @brief Postlists for remote databases
3 : : */
4 : : /* Copyright (C) 2007,2009 Lemur Consulting Ltd
5 : : * Copyright (C) 2007,2008,2009 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 "leafpostlist.h"
29 : : #include "omassert.h"
30 : : #include "remote-database.h"
31 : :
32 : : using namespace std;
33 : :
34 : : /** A postlist in a remote database.
35 : : */
36 [ + - ][ # # ]: 780 : class NetworkPostList : public LeafPostList {
37 : : friend class RemoteDatabase;
38 : :
39 : : Xapian::Internal::RefCntPtr<const RemoteDatabase> db;
40 : :
41 : : string postings;
42 : : bool started;
43 : : const char * pos;
44 : : const char * pos_end;
45 : :
46 : : Xapian::docid lastdocid;
47 : : Xapian::termcount lastwdf;
48 : : Xapian::Internal::RefCntPtr<PositionList> lastposlist;
49 : :
50 : : Xapian::doccount termfreq;
51 : :
52 : : /// Append a posting to the end of the postlist.
53 : 19692 : void append_posting(const string & serialised) {
54 : : Assert(pos == NULL);
55 : : Assert(!started);
56 : 19692 : postings.append(serialised);
57 : 19692 : }
58 : :
59 : : public:
60 : : /// Constructor.
61 : 792 : NetworkPostList(Xapian::Internal::RefCntPtr<const RemoteDatabase> db_,
62 : : const string & term_)
63 : : : LeafPostList(term_),
64 : : db(db_), started(false), pos(NULL), pos_end(NULL),
65 : 792 : lastdocid(0), lastwdf(0), termfreq(0)
66 : : {
67 : 792 : termfreq = db->read_post_list(term, *this);
68 : 828 : }
69 : :
70 : : /// Get number of documents indexed by this term.
71 : : Xapian::doccount get_termfreq() const;
72 : :
73 : : /// Get the current document ID.
74 : : Xapian::docid get_docid() const;
75 : :
76 : : /// Get the length of the current document.
77 : : Xapian::termcount get_doclength() const;
78 : :
79 : : /// Get the Within Document Frequency of the term in the current document.
80 : : Xapian::termcount get_wdf() const;
81 : :
82 : : /// Read the position list for the term in the current document and
83 : : /// return a pointer to it (owned by the PostList).
84 : : PositionList * read_position_list();
85 : :
86 : : /// Read the position list for the term in the current document and
87 : : /// return a pointer to it (not owned by the PostList).
88 : : PositionList * open_position_list() const;
89 : :
90 : : /// Move to the next document in the postlist (the weight parameter is
91 : : /// ignored).
92 : : PostList * next(Xapian::weight);
93 : :
94 : : /// Skip forward to the next document with document ID >= the supplied
95 : : /// document ID (the weight parameter is ignored).
96 : : PostList * skip_to(Xapian::docid did, Xapian::weight weight);
97 : :
98 : : /// Return true if and only if we've moved off the end of the list.
99 : : bool at_end() const;
100 : :
101 : : /// Get a description of the postlist.
102 : : string get_description() const;
103 : : };
104 : :
105 : : #endif /* XAPIAN_INCLUDED_NET_POSTLIST_H */
|