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