00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef XAPIAN_HGUARD_BRASS_POSITIONLIST_H
00022 #define XAPIAN_HGUARD_BRASS_POSITIONLIST_H
00023
00024 #include <xapian/types.h>
00025
00026 #include "brass_lazytable.h"
00027 #include "pack.h"
00028 #include "positionlist.h"
00029
00030 #include <string>
00031 #include <vector>
00032
00033 using namespace std;
00034
00035 class BrassPositionListTable : public BrassLazyTable {
00036 public:
00037 static string make_key(Xapian::docid did, const string & term) {
00038 string key;
00039 pack_uint_preserving_sort(key, did);
00040 key += term;
00041 return key;
00042 }
00043
00052 BrassPositionListTable(const string & dbdir, bool readonly)
00053 : BrassLazyTable("position", dbdir + "/position.", readonly,
00054 DONT_COMPRESS) { }
00055
00061 void set_positionlist(Xapian::docid did, const string & tname,
00062 Xapian::PositionIterator pos,
00063 const Xapian::PositionIterator &pos_end,
00064 bool check_for_update);
00065
00067 void delete_positionlist(Xapian::docid did, const string & tname) {
00068 del(make_key(did, tname));
00069 }
00070
00072 Xapian::termcount positionlist_count(Xapian::docid did,
00073 const string & term) const;
00074 };
00075
00077 class BrassPositionList : public PositionList {
00079 vector<Xapian::termpos> positions;
00080
00082 vector<Xapian::termpos>::const_iterator current_pos;
00083
00085 bool have_started;
00086
00088 void next_internal();
00089
00091 BrassPositionList(const BrassPositionList &);
00092
00094 void operator=(const BrassPositionList &);
00095
00096 public:
00098 BrassPositionList() : have_started(false) {}
00099
00101 BrassPositionList(const BrassTable * table, Xapian::docid did,
00102 const string & tname) {
00103 (void)read_data(table, did, tname);
00104 }
00105
00110 bool read_data(const BrassTable * table, Xapian::docid did,
00111 const string & tname);
00112
00114 Xapian::termcount get_size() const;
00115
00121 Xapian::termpos get_position() const;
00122
00124 void next();
00125
00127 void skip_to(Xapian::termpos termpos);
00128
00130 bool at_end() const;
00131 };
00132
00133 #endif