43 return mask ?
sizeof(T) * 8 - do_clz(mask) : 0;
46 static const unsigned char hob_tab[256] = {
47 0, 1, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4,
48 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
49 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
50 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
51 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
52 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
53 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
54 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
55 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
56 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
57 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
58 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
59 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
60 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
61 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
62 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8
67 if (mask >= 0x100000000ul) {
72 if (mask >= 0x10000u) {
80 return result + hob_tab[mask];
87 template<
typename T,
typename U>
88 static constexpr
inline 91 return (shift >=
sizeof(T) * 8 ? 0 : x << shift);
128 if (value >= mid_start + spare) {
129 value = (value - (mid_start + spare)) |
131 }
else if (value >= mid_start) {
136 if (bits + n_bits >
sizeof(acc) * 8) {
140 Assert(bits <=
sizeof(acc) * 8);
141 acc |= (value << n_bits);
147 acc |= (value << n_bits);
149 while (n_bits >= 8) {
157 BitWriter::encode_interpolative(
const vector<Xapian::termpos>& pos,
int j,
int k)
169 encode(pos[mid] - lowest, outof);
170 encode_interpolative(pos, j, mid);
179 Assert(force == di_current.is_initialized());
185 p = read_bits(bits - 1);
187 if (read_bits(1)) p += mid_start + spare;
197 BitReader::read_bits(
int count)
200 if (count >
int(
sizeof(acc) * 8 - 7)) {
206 Assert(count <=
int(
sizeof(acc) * 8));
207 const size_t half_the_bits =
sizeof(acc) * 4;
208 result = read_bits(half_the_bits);
209 return result | (read_bits(count - half_the_bits) << half_the_bits);
211 while (n_bits < count) {
213 unsigned char byte = buf[idx++];
224 BitReader::decode_interpolative(
int j,
int k,
227 Assert(!di_current.is_initialized());
229 di_current.set_j(j, pos_j);
230 di_current.set_k(k, pos_k);
234 BitReader::decode_interpolative_next()
236 Assert(di_current.is_initialized());
237 while (!di_stack.empty() || di_current.is_next()) {
238 if (!di_current.is_next()) {
240 di_current = di_stack.back();
242 int mid = (di_current.j + di_current.k) / 2;
243 di_current.set_j(mid, pos_ret);
246 di_stack.push_back(di_current);
247 int mid = (di_current.j + di_current.k) / 2;
249 (di_current.pos_j + mid - di_current.j);
250 di_current.set_k(mid, pos_mid);
252 #ifdef XAPIAN_ASSERTIONS 255 return di_current.pos_k;
The Xapian namespace contains public interfaces for the Xapian library.
static constexpr T safe_shl(T x, U shift)
Shift left that's safe for shifts wider than the type.
static int decode(const T(&table)[N], const char *s)
Decode a string to an integer.
static int highest_order_bit(T mask)
bool encode(double lat, double lon, std::string &result)
Encode a coordinate and append it to a string.
Classes to encode/decode a bitstream.
Pack types into strings and unpack them again.
unsigned XAPIAN_TERMPOS_BASE_TYPE termpos
A term position within a document or query.
Various assertion macros.