xapian-core  1.4.26
net_termlist.cc
Go to the documentation of this file.
1 /* net_termlist.cc
2  *
3  * Copyright 1999,2000,2001 BrightStation PLC
4  * Copyright 2002,2003,2006,2007,2008,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 #include <config.h>
23 
24 #include "net_termlist.h"
25 
26 #include "omassert.h"
27 
28 #include <xapian/error.h>
29 
31 
33  Xapian::doccount database_size_,
35  Xapian::docid did_)
36  : items(),
37  current_position(items.begin()),
38  started(false),
39  document_length(document_length_),
40  database_size(database_size_),
41  this_db(this_db_),
42  did(did_)
43 {
44 }
45 
48 {
49  return items.size();
50 }
51 
52 void
54 {
55  Assert(started);
56  Assert(!at_end());
57 
58  stats.accumulate(shard_index,
59  current_position->wdf,
61  current_position->termfreq,
63 }
64 
65 string
67 {
68  Assert(started);
69  Assert(!at_end());
70  return current_position->tname;
71 }
72 
75 {
76  Assert(started);
77  Assert(!at_end());
78  return current_position->wdf;
79 }
80 
83 {
84  Assert(started);
85  Assert(!at_end());
86  return current_position->termfreq;
87 }
88 
89 TermList *
91 {
92  if (started) {
93  Assert(!at_end());
95  } else {
96  started = true;
97  }
98  return NULL;
99 }
100 
101 TermList *
102 NetworkTermList::skip_to(const string & term)
103 {
104  while (current_position != items.end() && current_position->tname < term) {
106  }
107  started = true;
108  return NULL;
109 }
110 
111 bool
113 {
114  Assert(started);
115  return (current_position == items.end());
116 }
117 
120 {
121  throw Xapian::UnimplementedError("NetworkTermList::positionlist_count() not implemented");
122 }
123 
126 {
128 }
Xapian::doccount get_termfreq() const
Return the term frequency for the term at the current position.
Definition: net_termlist.cc:82
#define Assert(COND)
Definition: omassert.h:122
Termlist in a remote db.
bool at_end() const
Return true if the current position is past the last term in this list.
vector< NetworkTermListItem >::const_iterator current_position
The current position in the list.
Definition: net_termlist.h:71
void accumulate_stats(Xapian::Internal::ExpandStats &stats) const
Collate weighting information for the current term.
Definition: net_termlist.cc:53
Abstract base class for termlists.
Definition: termlist.h:39
Xapian::termcount get_approx_size() const
Get the number of terms in the termlist.
Definition: net_termlist.cc:47
#define false
Definition: header.h:9
Xapian::Internal::intrusive_ptr< const RemoteDatabase > this_db
Keep a reference to our database.
Definition: net_termlist.h:92
Hierarchy of classes which Xapian can throw as exceptions.
unsigned XAPIAN_TERMCOUNT_BASE_TYPE termcount
A counts of terms.
Definition: types.h:72
bool started
Whether we have yet started iterating through the list.
Definition: net_termlist.h:75
void accumulate(size_t shard_index, Xapian::termcount wdf, Xapian::termcount doclen, Xapian::doccount subtf, Xapian::doccount subdbsize)
Definition: expandweight.h:76
Xapian::termcount document_length
The length of the document for which this is the termlist.
Definition: net_termlist.h:81
Xapian::docid did
The id of the document this termlist came from (or 0 if not applicable).
Definition: net_termlist.h:95
Class for iterating over term positions.
Xapian::termcount positionlist_count() const
Return the length of the position list for the current position.
Xapian::termcount get_wdf() const
Return the wdf for the term at the current position.
Definition: net_termlist.cc:74
unsigned XAPIAN_DOCID_BASE_TYPE doccount
A count of documents.
Definition: types.h:38
size_t shard_index
Which shard of a multidatabase this is from.
Definition: termlist.h:114
PositionList * open_position_list(Xapian::docid did, const string &tname) const
Open a position list for the given term in the given document.
Collates statistics while calculating term weight in an ESet.
Definition: expandweight.h:37
TermList * next()
Advance the current position to the next term in the termlist.
Definition: net_termlist.cc:90
Xapian::PositionIterator positionlist_begin() const
Return a PositionIterator for the current position.
Various assertion macros.
unsigned XAPIAN_DOCID_BASE_TYPE docid
A unique identifier for a document.
Definition: types.h:52
A smart pointer that uses intrusive reference counting.
Definition: intrusive_ptr.h:81
vector< NetworkTermListItem > items
The list of items comprising the termlist.
Definition: net_termlist.h:67
NetworkTermList(Xapian::termcount document_length_, Xapian::doccount database_size_, Xapian::Internal::intrusive_ptr< const RemoteDatabase > this_db_, Xapian::docid did_)
Standard constructor is private: NetworkTermLists are created by RemoteDatabase object only...
Definition: net_termlist.cc:32
Xapian::doccount database_size
The number of documents in the database in which this document resides.
Definition: net_termlist.h:89
TermList * skip_to(const std::string &term)
Skip forward to the specified term.
UnimplementedError indicates an attempt to use an unimplemented feature.
Definition: error.h:325
string get_termname() const
Return the termname at the current position.
Definition: net_termlist.cc:66