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