41 bool check_for_update)
43 LOGCALL_VOID(DB,
"ChertPositionListTable::set_positionlist", did | tname | pos | pos_end | check_for_update);
47 vector<Xapian::termpos> poscopy(pos, pos_end);
54 if (poscopy.size() > 1) {
56 wr.
encode(poscopy[0], poscopy.back());
57 wr.
encode(poscopy.size() - 2, poscopy.back() - poscopy[0]);
62 if (check_for_update) {
64 if (get_exact_entry(key, old_tag) && s == old_tag)
72 const string & term)
const 77 if (!get_exact_entry(
make_key(did, term), data)) {
81 const char * pos = data.data();
82 const char * end = pos + data.size();
103 const string & tname)
105 LOGCALL(DB,
bool,
"ChertPositionList::read_data", table | did | tname);
107 have_started =
false;
118 const char * pos = data.data();
119 const char * end = pos + data.size();
127 current_pos = last = pos_last;
131 rd.init(data, pos - data.data());
134 rd.decode_interpolative(0, pos_size - 1, pos_first, pos_last);
137 current_pos = pos_first;
159 LOGCALL(DB,
bool,
"ChertPositionList::next", NO_ARGS);
160 if (
rare(!have_started)) {
162 return current_pos <= last;
164 if (current_pos == last) {
167 current_pos = rd.decode_interpolative_next();
174 LOGCALL(DB,
bool,
"ChertPositionList::skip_to", termpos);
176 if (termpos >= last) {
177 if (termpos == last) {
183 while (current_pos < termpos) {
184 if (current_pos == last) {
187 current_pos = rd.decode_interpolative_next();
static string make_key(Xapian::docid did, const string &term)
Xapian::termcount get_approx_size() const
Returns size of position list.
Class managing a Btree table in a Chert database.
#define LOGCALL_VOID(CATEGORY, FUNC, PARAMS)
bool skip_to(Xapian::termpos termpos)
Advance to the first term position which is at least termpos.
Xapian::termpos get_position() const
Returns current position.
void encode_interpolative(const std::vector< Xapian::termpos > &pos, int j, int k)
Perform interpolative encoding of pos elements between j and k.
unsigned XAPIAN_TERMCOUNT_BASE_TYPE termcount
A counts of terms.
Xapian::termcount positionlist_count(Xapian::docid did, const string &term) const
Return the number of entries in specified position list.
bool read_data(const ChertTable *table, Xapian::docid did, const string &tname)
Fill list with data, and move the position to the start.
bool get_exact_entry(const std::string &key, std::string &tag) const
Read an entry from the table, if and only if it is exactly that being asked for.
Read a stream created by BitWriter.
Class for iterating over term positions.
Classes to encode/decode a bitstream.
A position list in a chert database.
Xapian::termpos decode(Xapian::termpos outof, bool force=false)
DatabaseCorruptError indicates database corruption was detected.
void pack_uint(std::string &s, U value)
Append an encoded unsigned integer to a string.
bool next()
Advance to the next term position in the list.
Pack types into strings and unpack them again.
unsigned XAPIAN_TERMPOS_BASE_TYPE termpos
A term position within a document or query.
bool unpack_uint(const char **p, const char *end, U *result)
Decode an unsigned integer from a string.
Create a stream to which non-byte-aligned values can be written.
void set_positionlist(Xapian::docid did, const string &tname, Xapian::PositionIterator pos, const Xapian::PositionIterator &pos_end, bool check_for_update)
Set the position list for term tname in document did.
unsigned XAPIAN_DOCID_BASE_TYPE docid
A unique identifier for a document.
void encode(Xapian::termpos value, Xapian::termpos outof)
Encode value, known to be less than outof.
string make_key(Xapian::docid did)
#define LOGCALL(CATEGORY, TYPE, FUNC, PARAMS)
std::string & freeze()
Finish encoding and return the encoded data as a std::string.