Branch data Line data Source code
1 : : /* net_termlist.h
2 : : *
3 : : * Copyright 1999,2000,2001 BrightStation PLC
4 : : * Copyright 2003,2006,2007,2009,2010 Olly Betts
5 : : *
6 : : * This program is free software; you can redistribute it and/or
7 : : * modify it under the terms of the GNU General Public License as
8 : : * published by the Free Software Foundation; either version 2 of the
9 : : * License, or (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
19 : : * USA
20 : : */
21 : :
22 : : #ifndef OM_HGUARD_NET_TERMLIST_H
23 : : #define OM_HGUARD_NET_TERMLIST_H
24 : :
25 : : #include <string>
26 : :
27 : : #include <xapian/types.h>
28 : : #include <xapian/error.h>
29 : : #include "termlist.h"
30 : : #include "expandweight.h"
31 : : #include "remote-database.h"
32 : :
33 : : using namespace std;
34 : :
35 : : /** An item in a NetworkTermList.
36 : : */
37 : 60612 : class NetworkTermListItem {
38 : : public:
39 : : /** The "name" of this term.
40 : : */
41 : : string tname;
42 : :
43 : : /** The term frequency.
44 : : * This is the number of documents (in the network database)
45 : : * indexed by the term.
46 : : */
47 : : Xapian::doccount termfreq;
48 : :
49 : : /** The within-document-frequency of the term.
50 : : *
51 : : * This information may not be available, in which case the field
52 : : * should have a value of 0.
53 : : */
54 : : Xapian::termcount wdf;
55 : : };
56 : :
57 : : /** A term list for a database on the other side of a network connection.
58 : : * The termlist is serialised across the network, and rebuilt into this
59 : : * object on the client side.
60 : : */
61 [ + - ][ # # ]: 2652 : class NetworkTermList : public TermList {
62 : : friend class RemoteDatabase;
63 : : private:
64 : : /** The list of items comprising the termlist.
65 : : */
66 : : vector<NetworkTermListItem> items;
67 : :
68 : : /** The current position in the list.
69 : : */
70 : : vector<NetworkTermListItem>::const_iterator current_position;
71 : :
72 : : /** Whether we have yet started iterating through the list.
73 : : */
74 : : bool started;
75 : :
76 : : /** The length of the document for which this is the termlist.
77 : : *
78 : : * Note that this is not a normalised document length.
79 : : */
80 : : Xapian::termcount document_length;
81 : :
82 : : /** The number of documents in the database in which this
83 : : * document resides.
84 : : *
85 : : * Note that this may not be the number of documents in the combined
86 : : * database when multiple databases are being searched.
87 : : */
88 : : Xapian::doccount database_size;
89 : :
90 : : /// Keep a reference to our database
91 : : Xapian::Internal::RefCntPtr<const RemoteDatabase> this_db;
92 : :
93 : : /// The id of the document this termlist came from (or 0 if not applicable).
94 : : Xapian::docid did;
95 : :
96 : : /** Standard constructor is private: NetworkTermLists are created
97 : : * by RemoteDatabase object only, which is a friend.
98 : : *
99 : : * @param document_length_ The (non-normalised) length of the document
100 : : * @param database_size_ The number of documents in the database
101 : : * @param this_db_ The database
102 : : * @param did_ The document id
103 : : */
104 : : NetworkTermList(Xapian::termcount document_length_,
105 : : Xapian::doccount database_size_,
106 : : Xapian::Internal::RefCntPtr<const RemoteDatabase> this_db_,
107 : : Xapian::docid did_);
108 : : public:
109 : :
110 : : /** Get the number of terms in the termlist.
111 : : */
112 : : Xapian::termcount get_approx_size() const;
113 : :
114 : : // Collate weighting information for the current term.
115 : : void accumulate_stats(Xapian::Internal::ExpandStats &stats) const;
116 : : string get_termname() const;
117 : : Xapian::termcount get_wdf() const;
118 : : Xapian::doccount get_termfreq() const;
119 : : TermList * next();
120 : : TermList * skip_to(const std::string &term);
121 : : bool at_end() const;
122 : :
123 : : Xapian::termcount positionlist_count() const;
124 : : Xapian::PositionIterator positionlist_begin() const;
125 : : };
126 : :
127 : : #endif /* OM_HGUARD_NET_TERMLIST_H */
|