00001
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include <config.h>
00022
00023 #include <string>
00024
00025 #include "flint_database.h"
00026 #include "flint_alldocspostlist.h"
00027
00028 #include "utils.h"
00029
00030 using namespace std;
00031
00032 FlintAllDocsPostList::~FlintAllDocsPostList()
00033 {
00034 }
00035
00036 Xapian::doccount
00037 FlintAllDocsPostList::get_termfreq() const
00038 {
00039 return doccount;
00040 }
00041
00042 Xapian::docid
00043 FlintAllDocsPostList::get_docid() const
00044 {
00045 return current_did;
00046 }
00047
00048 Xapian::doclength
00049 FlintAllDocsPostList::get_doclength() const
00050 {
00051 DEBUGCALL(DB, Xapian::doclength, "FlintAllDocsPostList::get_doclength", "");
00052 Assert(current_did);
00053
00054 cursor->read_tag();
00055
00056 if (cursor->current_tag.empty()) RETURN(0);
00057
00058 const char * pos = cursor->current_tag.data();
00059 const char * end = pos + cursor->current_tag.size();
00060
00061 flint_doclen_t doclen;
00062 if (!unpack_uint(&pos, end, &doclen)) {
00063 const char *msg;
00064 if (pos == 0) {
00065 msg = "Too little data for doclen in termlist";
00066 } else {
00067 msg = "Overflowed value for doclen in termlist";
00068 }
00069 throw Xapian::DatabaseCorruptError(msg);
00070 }
00071
00072 RETURN(doclen);
00073 }
00074
00075 Xapian::termcount
00076 FlintAllDocsPostList::get_wdf() const
00077 {
00078 DEBUGCALL(DB, Xapian::termcount, "FlintAllDocsPostList::get_wdf", "");
00079 Assert(current_did);
00080 RETURN(1);
00081 }
00082
00083 PostList *
00084 FlintAllDocsPostList::read_did_from_current_key()
00085 {
00086 DEBUGCALL(DB, PostList *, "FlintAllDocsPostList::read_did_from_current_key",
00087 "");
00088 const string & key = cursor->current_key;
00089 const char * pos = key.data();
00090 const char * end = pos + key.size();
00091 if (!unpack_uint_preserving_sort(&pos, end, ¤t_did)) {
00092 const char *msg;
00093 if (pos == 0) {
00094 msg = "Too little data in termlist key";
00095 } else {
00096 msg = "Overflowed value in termlist key";
00097 }
00098 throw Xapian::DatabaseCorruptError(msg);
00099 }
00100
00101
00102 RETURN(NULL);
00103 }
00104
00105 PostList *
00106 FlintAllDocsPostList::next(Xapian::weight )
00107 {
00108 DEBUGCALL(DB, PostList *, "FlintAllDocsPostList::next", "/*w_min*/");
00109 Assert(!at_end());
00110 if (!cursor->next()) RETURN(NULL);
00111 RETURN(read_did_from_current_key());
00112 }
00113
00114 PostList *
00115 FlintAllDocsPostList::skip_to(Xapian::docid did, Xapian::weight )
00116 {
00117 DEBUGCALL(DB, PostList *, "FlintAllDocsPostList::skip_to",
00118 did << ", /*w_min*/");
00119
00120 if (did <= current_did || at_end()) RETURN(NULL);
00121
00122 if (cursor->find_entry_ge(pack_uint_preserving_sort(did))) {
00123
00124 current_did = did;
00125 RETURN(NULL);
00126 }
00127 if (cursor->after_end()) RETURN(NULL);
00128
00129 RETURN(read_did_from_current_key());
00130 }
00131
00132 bool
00133 FlintAllDocsPostList::at_end() const {
00134 DEBUGCALL(DB, bool, "FlintAllDocsPostList::at_end", "");
00135 RETURN(cursor->after_end());
00136 }
00137
00138 string
00139 FlintAllDocsPostList::get_description() const
00140 {
00141 string desc = "FlintAllDocsPostList(did=";
00142 desc += om_tostring(current_did);
00143 desc += ",doccount=";
00144 desc += om_tostring(doccount);
00145 desc += ')';
00146 return desc;
00147 }