mirror of
https://github.com/quickwit-oss/tantivy.git
synced 2026-11-28 05:24:11 +00:00
- Decode the dictionary once per block open into one DictEntry
{ start: u16, len: u16 } per token, instead of an offsets Vec checked
by validate_safety. DictEntry is repr(C, align(4)), with the layout of
a u32, checked by compile-time asserts. The reader enforces
MAX_CODE_BITS = 12, so token starts fit on 16 bits, and only the last
token's read padding is checked. The token lengths are decoded 16 at a
time with NEON (aarch64) or SSE2 (x86_64), which store the interleaved
(start, len) u16 lanes directly as DictEntry values, with a scalar loop
for the rest and for other targets.
- Decode values in a single pass: 4 codes per u64 load, one range check
per 4 codes, and a 16-byte over-copy per token, in chunks of 256 codes
so that reserve stays bounded. This drops onpair's decoded_len pre-pass
and the codes_buffer round trip. The code load (load_codes) and the
token copy (copy_token) are inline functions taking slices, with their
safety contracts checked by debug_assert.
- Remove the now unused codes_buffer parameter of append_value, and the
PlainValueReader field.
- Keep a single OwnedBytes in OnPair16Block instead of splitting it.
- Test write_codes against load_codes, the reader's code load, for
code_bits in 1..=12, instead of against BitUnpacker.
Co-authored-by: Paul Masurel <paul.masurel@datadoghq.com>