00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include <config.h>
00023
00024 #include "net_termlist.h"
00025
00026 #include "omassert.h"
00027
00028 #include <xapian/error.h>
00029
00030 NetworkTermList::NetworkTermList(Xapian::termcount document_length_,
00031 Xapian::doccount database_size_,
00032 Xapian::Internal::RefCntPtr<const RemoteDatabase> this_db_,
00033 Xapian::docid did_)
00034 : items(),
00035 current_position(items.begin()),
00036 started(false),
00037 document_length(document_length_),
00038 database_size(database_size_),
00039 this_db(this_db_),
00040 did(did_)
00041 {
00042 }
00043
00044 Xapian::termcount
00045 NetworkTermList::get_approx_size() const
00046 {
00047 return items.size();
00048 }
00049
00050 void
00051 NetworkTermList::accumulate_stats(Xapian::Internal::ExpandStats & stats) const
00052 {
00053 Assert(started);
00054 Assert(!at_end());
00055
00056 stats.accumulate(current_position->wdf,
00057 document_length,
00058 current_position->termfreq,
00059 database_size);
00060 }
00061
00062 string
00063 NetworkTermList::get_termname() const
00064 {
00065 Assert(started);
00066 Assert(!at_end());
00067 return current_position->tname;
00068 }
00069
00070 Xapian::termcount
00071 NetworkTermList::get_wdf() const
00072 {
00073 Assert(started);
00074 Assert(!at_end());
00075 return current_position->wdf;
00076 }
00077
00078 Xapian::doccount
00079 NetworkTermList::get_termfreq() const
00080 {
00081 Assert(started);
00082 Assert(!at_end());
00083 return current_position->termfreq;
00084 }
00085
00086 TermList *
00087 NetworkTermList::next()
00088 {
00089 if (started) {
00090 Assert(!at_end());
00091 current_position++;
00092 } else {
00093 started = true;
00094 }
00095 return NULL;
00096 }
00097
00098 TermList *
00099 NetworkTermList::skip_to(const string & term)
00100 {
00101 while (current_position != items.end() && current_position->tname < term) {
00102 ++current_position;
00103 }
00104 started = true;
00105 return NULL;
00106 }
00107
00108 bool
00109 NetworkTermList::at_end() const
00110 {
00111 Assert(started);
00112 return (current_position == items.end());
00113 }
00114
00115 Xapian::termcount
00116 NetworkTermList::positionlist_count() const
00117 {
00118 throw Xapian::UnimplementedError("NetworkTermList::positionlist_count() not implemented");
00119 }
00120
00121 Xapian::PositionIterator
00122 NetworkTermList::positionlist_begin() const
00123 {
00124 return Xapian::PositionIterator(this_db->open_position_list(did, get_termname()));
00125 }