00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef XAPIAN_HGUARD_FLINT_POSITIONLIST_H
00022 #define XAPIAN_HGUARD_FLINT_POSITIONLIST_H
00023
00024 #include <xapian/types.h>
00025
00026 #include "flint_table.h"
00027 #include "flint_utils.h"
00028 #include "positionlist.h"
00029
00030 #include <string>
00031 #include <vector>
00032
00033 using namespace std;
00034
00035 class FlintPositionListTable : public FlintTable {
00036 static string make_key(Xapian::docid did, const string & tname) {
00037 return pack_uint_preserving_sort(did) + tname;
00038 }
00039
00040 public:
00049 FlintPositionListTable(string dbdir, bool readonly)
00050 : FlintTable(dbdir + "/position.", readonly, DONT_COMPRESS, true) { }
00051
00053 void set_positionlist(Xapian::docid did, const string & tname,
00054 Xapian::PositionIterator pos,
00055 const Xapian::PositionIterator &pos_end);
00056
00058 void delete_positionlist(Xapian::docid did, const string & tname) {
00059 del(make_key(did, tname));
00060 }
00061
00063 Xapian::termcount positionlist_count(Xapian::docid did,
00064 const string & term) const;
00065 };
00066
00068 class FlintPositionList : public PositionList {
00070 vector<Xapian::termpos> positions;
00071
00073 vector<Xapian::termpos>::const_iterator current_pos;
00074
00076 bool have_started;
00077
00079 void next_internal();
00080
00082 FlintPositionList(const FlintPositionList &);
00083
00085 void operator=(const FlintPositionList &);
00086
00087 public:
00089 FlintPositionList() : have_started(false) {}
00090
00092 FlintPositionList(const FlintTable * table, Xapian::docid did,
00093 const string & tname) {
00094 (void)read_data(table, did, tname);
00095 }
00096
00098 ~FlintPositionList() { }
00099
00104 bool read_data(const FlintTable * table, Xapian::docid did,
00105 const string & tname);
00106
00108 Xapian::termcount get_size() const;
00109
00115 Xapian::termpos get_position() const;
00116
00118 void next();
00119
00121 void skip_to(Xapian::termpos termpos);
00122
00124 bool at_end() const;
00125 };
00126
00127 #endif