39 const vector<Xapian::termpos> & vec)
const 41 LOGCALL_VOID(DB,
"GlassPositionListTable::pack", s | vec);
48 wr.
encode(vec[0], vec.back());
49 wr.
encode(vec.size() - 2, vec.back() - vec[0]);
62 const char * pos = data.data();
63 const char * end = pos + data.size();
82 const string & term)
const 87 if (!get_exact_entry(
make_key(did, term), data)) {
91 RETURN(positionlist_count(data));
99 LOGCALL(DB,
bool,
"GlassPositionList::read_data", data);
101 have_started =
false;
111 const char * pos = data.data();
112 const char * end = pos + data.size();
120 current_pos = last = pos_last;
124 rd.init(data, pos - data.data());
127 rd.decode_interpolative(0, pos_size - 1, pos_first, pos_last);
130 current_pos = pos_first;
136 const string & tname)
138 LOGCALL(DB,
bool,
"GlassPositionList::read_data", table | did | tname);
144 RETURN(read_data(cursor->current_tag));
146 RETURN(read_data(
string()));
167 LOGCALL(DB,
bool,
"GlassPositionList::next", NO_ARGS);
168 if (
rare(!have_started)) {
170 return current_pos <= last;
172 if (current_pos == last) {
175 current_pos = rd.decode_interpolative_next();
182 LOGCALL(DB,
bool,
"GlassPositionList::skip_to", termpos);
184 if (termpos >= last) {
185 if (termpos == last) {
191 while (current_pos < termpos) {
192 if (current_pos == last) {
195 current_pos = rd.decode_interpolative_next();
void pack(string &s, const std::vector< Xapian::termpos > &vec) const
Pack a position list into a string.
bool next()
Advance to the next term position in the list.
Xapian::termcount positionlist_count(const string &data) const
Return the number of entries in specified position list data.
A position list in a glass database.
Class managing a Btree table in a Glass database.
Xapian::termcount get_approx_size() const
Returns size of position list.
#define LOGCALL_VOID(CATEGORY, FUNC, PARAMS)
bool read_data(const string &data)
Fill list with data, and move the position to the start.
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.
Read a stream created by BitWriter.
bool skip_to(Xapian::termpos termpos)
Advance to the first term position which is at least termpos.
Classes to encode/decode a bitstream.
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.
Xapian::termpos get_position() const
Returns current position.
GlassCursor * cursor_get() const
Get a cursor for reading from the table.
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.
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.
static string make_key(Xapian::docid did, const string &term)
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.