Skip to content

[pull] master from ClickHouse:master - #6

Merged
pull[bot] merged 94 commits into
sowelswl:masterfrom
ClickHouse:master
May 24, 2026
Merged

pull[bot] merged 94 commits into
sowelswl:masterfrom
ClickHouse:master

Conversation

@pull

@pull pull Bot commented May 24, 2026 •

Copy link
Copy Markdown

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 : )

fastio and others added 30 commits March 19, 2026 21:06
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).
@pull pull Bot locked and limited conversation to collaborators May 24, 2026
@pull pull Bot added the ⤵️ pull label May 24, 2026
@pull
pull Bot merged commit 83c2b12 into sowelswl:master May 24, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants