- 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>
* Use BlockwiseLinearCodec directly for plain block offsets
- Store BlockwiseLinearReader directly in OnPair16Block and RawBlock
instead of Arc<dyn ColumnValues<u32>>, dropping the 1-byte CodecType
prefix (block kind and column format version cover future format changes).
- Skip the redundant BlockwiseLinearEstimator estimation pass on write.
- Add BlockwiseLinearReader::get_pair(slot) (sharing the block lookup for
511/512 consecutive pairs) and avoid bytes.split in BlockwiseLinearCodec::load.
- Keep a single OwnedBytes in RawBlock and update LAYOUT.md.
* Serialize plain block offsets without stats or estimation pass
---------
Co-authored-by: Paul Masurel <paul.masurel@datadoghq.com>
- Add get_pair(&self, idx: u32) -> (T, T) to ColumnValues<T> with a
default implementation and forward it through Arc<dyn ColumnValues<T>>
and MonotonicMappingColumn.
- Implement BlockwiseLinearReader::get_pair to share the block lookup
when idx and idx + 1 fall in the same 512-element block.
- Use get_pair in MultiValueIndex (V1/V2 range and V1 iter_non_null_docs)
and plain block offset lookups.
- Add unit test covering within-block and block-boundary pairs via
Arc<dyn ColumnValues<u32>>.
Co-authored-by: Paul Masurel <paul.masurel@datadoghq.com>
Load dictionary blocks asynchronously and stream coalesced postings through FileHandle to build automaton bitsets. Run term enumeration and decoding on the executor, retaining buffers only while needed.
Restore configurable SSTable read coalescing and cover read ranges, decoding, cancellation, buffer release, and errors.
Explain what tantivy-query-grammar is responsible for, how it fits
between the query string and QueryParser, and its two entry points.
The README is included as the crate docs so its example is doctested.
Also fix the crate description, keywords and categories, which were
copied from the main crate.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Make the onpair dependency optional behind a `plain_codec` feature
OnPair16 compresses the blocks of plain-encoded Str and Bytes columns.
The columnar writer does not emit plain columns yet, so the dependency is
not used in practice.
The new `plain_codec` feature (tantivy and tantivy-columnar) enables it.
It is on by default in tantivy and off by default in tantivy-columnar,
like `zstd-compression`.
Without the feature, plain blocks are always written raw, and reading an
OnPair16 block returns an `Unsupported` io error.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Gate the whole plain module behind `plain_codec`
Instead of gating OnPair16 inside the plain module, gate the module itself,
the `DynamicColumn::PlainBytes`/`PlainStr` variants and their match arms.
Without the feature, opening or writing a plain-encoded column panics.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* Distinguish "no fast field tokenizer" from the raw tokenizer
same state, and skipped the tokenizer lookup for "raw". A custom analyzer
registered under "raw" (e.g. Quickwit's raw + RemoveLongFilter(255)) was
then silently ignored.
The fast field tokenizer is now an `Option<String>`:
- `FAST` / `"fast": true`: `None`, values are recorded as is, no lookup.
- `set_fast(name)` / `{"with_tokenizer": name}`: always looked up,
including "raw".
`set_fast("raw")` now serializes as `{"with_tokenizer": "raw"}` instead
of `true`, so the distinction survives a schema round trip.
* Added method to set up a fast field with a None tokenizer
* Add ExpUnrolledLinkedList::iter_chunks
Adds an iterator over the chunks of an ExpUnrolledLinkedList, one slice
per block, in write order.
read_to_end now goes through ExpUnrolledLinkedListChunks::read_to_end,
which keeps the plain block loop instead of calling next() per chunk.
It also reserves the exact output length upfront, computed from the
block metadata.
* Export ExpUnrolledLinkedListChunks and make read_exact_into public
So callers can name the type returned by iter_chunks, and use
read_exact_into from outside the crate.
* Add the plain codec format to the columnar
Adds StrColumnCodec, the column key code of plain columns, the V3
columnar version, and the plain column storage: OnPair16 blocks of at
most 65,536 values and 1 MiB, block index, and reader.
The columnar writer does not produce plain columns yet.
* less result moar panic
* CR Comment. Making PlainColumn Inner type private
* CR comment: checked sorted index in block index.
`SnippetGenerator::set_max_num_chars` and `search_fragments` document the
limit as a number of chars (not bytes), but fragments were cut as soon as
their byte length went over it. For non-ASCII text, snippets were therefore
much shorter than requested: about half for Cyrillic or Greek, a third for
CJK.
Count the chars of the fragment instead. Since a char is at least one byte,
the chars only need counting once the byte length exceeds the limit, so ASCII
text does no extra work.
Co-authored-by: ybai08 <271969568+ybai08@users.noreply.github.com>
* Export PhraseScorer from tantivy::query
PhraseScorer already has a public constructor and the Postings trait is public, but the type was only reachable inside the crate. Exporting it lets a custom Query/Weight score a phrase over any Postings, for example a union of several terms at one position, without copying the phrase matching code.
Also documents the struct, the constructor and phrase_count.
* Document that PhraseScorer::new needs two postings
Intersection::new asserts at least two docsets, so a custom Weight whose phrase degenerates to one term must branch before building the scorer.
---------
Co-authored-by: KleiKodesh <211884665+KleiKodesh@users.noreply.github.com>
The metric reducers folded values one at a time through recurrences that
carry state across every iteration: Kahan compensated summation in
`collect_stats` (sum/avg/min/max/count/stats) and Welford's online variance
in `extended_stats`. These strict dependency chains block both CPU
pipelining and auto-vectorization.
`collect_stats` now reduces each block of values as a slice into 4
independent Kahan (sum, delta) lanes plus 4 min/max lanes, combined at the
end of the block.
`extended_stats` accumulates each block into 4 independent
`IntermediateExtendedStats` lanes and folds them into the bucket with the
existing `merge_fruits` (Chan parallel-variance combination), the same
operation used to merge segment results. The lanes carry the bucket's sigma,
since `merge_fruits` replaces an empty bucket with the incoming lane.
Blocks with fewer than two values per lane are collected value by value,
where setting up and combining lanes costs more than it saves.
Only the floating-point summation order changes, as it already does across
segment merges. All aggregation tests pass within the existing `2e-12`
tolerance, including the rounding-sensitive `test_aggregation_level1`, and a
new test covers sigma through the lane path.