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 F_pack_uint_preserving_sort(did) + tname;
00038 }
00039
00040 public:
00049 FlintPositionListTable(const string & dbdir, bool readonly)
00050 : FlintTable("position", dbdir + "/position.", readonly, DONT_COMPRESS, true) { }
00051
00057 void set_positionlist(Xapian::docid did, const string & tname,
00058 Xapian::PositionIterator pos,
00059 const Xapian::PositionIterator &pos_end,
00060 bool check_for_update);
00061
00063 void delete_positionlist(Xapian::docid did, const string & tname) {
00064 del(make_key(did, tname));
00065 }
00066
00068 Xapian::termcount positionlist_count(Xapian::docid did,
00069 const string & term) const;
00070 };
00071
00073 class FlintPositionList : public PositionList {
00075 vector<Xapian::termpos> positions;
00076
00078 vector<Xapian::termpos>::const_iterator current_pos;
00079
00081 bool have_started;
00082
00084 void next_internal();
00085
00087 FlintPositionList(const FlintPositionList &);
00088
00090 void operator=(const FlintPositionList &);
00091
00092 public:
00094 FlintPositionList() : have_started(false) {}
00095
00097 FlintPositionList(const FlintTable * table, Xapian::docid did,
00098 const string & tname) {
00099 (void)read_data(table, did, tname);
00100 }
00101
00106 bool read_data(const FlintTable * table, Xapian::docid did,
00107 const string & tname);
00108
00110 Xapian::termcount get_size() const;
00111
00117 Xapian::termpos get_position() const;
00118
00120 void next();
00121
00123 void skip_to(Xapian::termpos termpos);
00124
00126 bool at_end() const;
00127 };
00128
00129 #endif