Repository navigation
[pull] master from ClickHouse:master - #6
Merged
Merged
Conversation
Implement cursor-based on-demand decoding of posting lists for skip
index text index, avoiding eager materialization into Roaring Bitmaps.
V2 format appends an Index Section after each segment's payload in
the .pst stream, containing per-packed-block `last_row_id` and
`relative_offset` arrays for O(log N) seek within segments.
New `PostingListCursor` class provides lazy seek/next/linearOr/linearAnd
operations, decoding packed blocks on demand via `BitpackingBlockCodec`.
Intersection algorithms:
- Leapfrog (sparse): 2/3/4-way specializations + N-way generics
- Brute-force (dense): bitmap counting for cache-friendly access
- Automatic selection based on `text_index_density_threshold`
New settings:
- `text_index_posting_list_apply_mode` ("materialize"/"lazy")
- `text_index_density_threshold` (default 0.5)
Backward compatible: V1 parts use existing materialize path;
lazy mode requires V2 format and opt-in via setting.
Reference: amosbird#4
- Fix density overflow: use double for span computation - Validate codec_type in prepareSegment - Add payload_offset bounds check in decodeBlock
…gate - Use `getDeserializedFormat` substreams in read path for correct file extensions - Add `allow_experimental_text_index_lazy_apply` setting to gate lazy mode
The block index section is now always written when using compressed posting lists, removing the version-gated conditional. This simplifies the codec interface by eliminating the `version` parameter from `encode` and `serialize` methods throughout the pipeline. Tests updated to remove `version` references and consolidate v1/v2 table variants into a single table.
Add multiple performance optimizations to `linearAnd` and supporting code: - Dense segment/embedded shortcut: skip per-row binary search when every row in the range has a posting, increment the clipped region directly. - All-zeros skip at segment and block level: when the output region is already all-zeros, no increment can contribute to a match, so skip the entire segment or block without decoding. - AVX2-accelerated `hasAllZeros` for fast zero-region detection. - AVX2-accelerated `finalizeCounters` for the brute-force intersection final pass (count == n → 1, else → 0). - Binary search in `seek` across segments instead of linear scan. - Simplify embedded posting list decoding (eliminate intermediate buffer). - Cache lazy cursors across marks within the same part in `MergeTreeReaderTextIndex` to avoid redundant cursor construction. New profile events: `TextIndexLazyAndSegmentsSkippedZero`, `TextIndexLazyAndBlocksSkippedZero`, `TextIndexLazyAndSegmentsSkippedDense`.
…ursor - Register `allow_experimental_text_index_lazy_apply` in `enableAllExperimentalSettings` (fixes Style check) - Fix `readability-qualified-auto` clang-tidy warnings: use explicit `const auto *` / `auto *` for raw pointer results from `std::lower_bound` - Suppress `cert-msc32-c` / `cert-msc51-cpp` on deterministic test RNG seed - Split multi-variable declarations to satisfy `readability-isolate-declaration` - Validate `num_blocks` upper bound against segment doc count in V2 format - Add span bounds check before constructing `std::span` in V1 `prepareSegment` - Introduce `clampRowEnd` helper to prevent `uint32_t` narrowing overflow in `linearOr` / `linearAnd` when `row_offset + num_rows` exceeds 32-bit range
- Adapt gtest_posting_list_cursor to current branch API (BitpackingBlockCodec, MergeTreeReaderStream, updated function signatures) - Add SQL tests for lazy apply mode, segment advance, block skip, correctness equivalence, and posting list format validation
`PostingListCursor` can only decode bitpacking-compressed posting lists. When an index is created without `posting_list_codec = 'bitpacking'` (the default is 'none'), non-embedded tokens are stored as Roaring Bitmaps or raw VarUInts — formats the cursor cannot parse. Previously, setting `text_index_posting_list_apply_mode = 'lazy'` on such an index silently produced wrong results (zero matches for any token with cardinality > 6) because the cursor creation fell through both the `IsCompressed` and `embedded_postings` branches in `fillColumn`. Now the reader throws `SUPPORT_IS_DISABLED` at construction time with a clear message telling the user to either add `posting_list_codec = 'bitpacking'` to the index definition or switch back to materialize mode. Also update the lazy-mode tests to use `posting_list_codec = 'bitpacking'` and remove `04051_text_index_lazy_profile_events` (depends on `system.query_log` which is not always available).
…erministic output
…decoder selection at read time
…ta size reference
…cursor outlives granule scope
… remove dead code
Add lazy posting list evaluation mode for text index
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
See Commits and Changes for more details.
Created by
pull[bot] (v2.0.0-alpha.4)
Can you help keep this open source service alive? 💖 Please sponsor : )