Repository navigation
Minor refactoring of posting lists deserialization - #114317
Conversation
`PostingsSerialization::deserialize` decoded posting lists marked `IsCompressed` with the configured codec, but handled the uncompressed roaring format inline, so `PostingListCodecNone::decode` was an unused no-op. Implement it, and route everything except raw postings through the codec. The codec is now selected by the posting list header instead of the codec configured for the part, so the resolution is extracted into `resolveCodec`. An uncompressed posting list is always a serialized roaring bitmap, and picking the codec by the header keeps that independent of the lazy `Bitpacking` resolution done for pre-`WithCodec` parts. Adapted from ClickHouse#113856 Co-Authored-By: Claude Opus 5 <[email protected]>
|
Workflow [PR], commit [f7a8c30] Summary: ❌
AI ReviewSummaryThis PR refactors text-index posting-list deserialization to route uncompressed blocks through Findings❌ Blockers
Final Verdict❌ Block LLVM Coverage Report
Changed lines: Changed C/C++ lines covered: 47/53 (88.68%) · Uncovered code |
`PostingListCodecNone::decode` allocated a fresh `PaddedPODArray` for every posting list block that is not entirely in the read buffer, and `SegmentedPostingListCodec::decode` allocated its `compressed_data` member anew on every call, because `PostingListCodecBitpacking::decode` constructs the codec per call. Pass the reusable `deserialization_buffer` of `PostingsSerialization` to `IPostingListCodec::decode` instead. The buffer cannot be kept in the codec: the codec for uncompressed posting lists is a shared static instance and `decode` is `const`. Also decode a bitpacked segment in place when its payload is entirely in the read buffer, as `PostingListCodecNone::decode` already did for roaring bitmaps. Both go through `readContiguousBytes` now. Decoding in place is safe: `simdcomp` uses unaligned loads only, and the memory of `ReadBuffer` has the same `PADDING_FOR_SIMD` right padding as `PaddedPODArray`. Follows up on ClickHouse#114317 (comment) Co-Authored-By: Claude Opus 5 <[email protected]>
`PostingListCodecNone::decode` allocated a fresh `PaddedPODArray` for every posting list block that is not entirely in the read buffer, and `SegmentedPostingListCodec::decode` allocated its `compressed_data` member anew on every call, because `PostingListCodecBitpacking::decode` constructs the codec per call. Pass the reusable `deserialization_buffer` of `PostingsSerialization` to `IPostingListCodec::decode` instead. The buffer cannot be kept in the codec: the codec for uncompressed posting lists is a shared static instance and `decode` is `const`. Also decode a bitpacked segment in place when its payload is entirely in the read buffer, as `PostingListCodecNone::decode` already did for roaring bitmaps. Both go through `readContiguousBytes` now. Decoding in place is safe: `simdcomp` uses unaligned loads only, and the memory of `ReadBuffer` has the same `PADDING_FOR_SIMD` right padding as `PaddedPODArray`. Follows up on ClickHouse#114317 (comment) Co-Authored-By: Claude Opus 5 <[email protected]>
510c895 to
2562ec7
Compare
`RawPostings` and `IsCompressed` are mutually exclusive: the writer always clears `IsCompressed` on every path that sets `RawPostings`. The refactoring of `deserialize` checks `RawPostings` first, so a corrupted header with both bits set would be parsed as `cardinality` raw `VarUInt` row ids instead of failing, returning bogus matches and leaving the stream misaligned for the following posting lists. Reject such headers with `CORRUPTED_DATA`. Co-Authored-By: Claude Opus 5 <[email protected]>
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
Only the stripped binary is compared: the official master build keeps debug symbols while PR builds strip them, so the other binaries differ by construction. Compile time of recompiled translation units28 translation units recompiled, 326 s compile time in total, 28 of them have a recent master baseline. |
dd5389b
…optimizations The conflicts were between the local iteration of `Deserialize uncompressed posting lists via PostingListCodecNone` and the version of the same change merged into master in ClickHouse#114317, which additionally got two follow-ups there: a reusable scratch buffer for `IPostingListCodec::decode`, and rejection of a posting list header that marks the data as both raw and compressed. Resolved in favour of master, with the row ids decode path of this branch re-applied on top of it: - Both overloads of `IPostingListCodec::decode` take the reusable `deserialization_buffer` of `PostingsSerialization`. - `SegmentedPostingListCodec::readSegment` returns the segment header together with the payload span produced by `readContiguousBytes`, shared by both `decode` overloads. Neither of them copies the payload into `compressed_data` anymore, which stays an encode-only member. - The check for the contradictory `RawPostings` and `IsCompressed` flags is extracted into `checkPostingListFlags` and applied to both overloads of `PostingsSerialization::deserialize`: the row ids overload dispatches on `RawPostings` first as well, so it has the same exposure to a corrupted header. Co-Authored-By: Claude Opus 5 <[email protected]>
Resolved conflicts with `Minor refactoring of posting lists deserialization` (ClickHouse#114317) in the text index posting list codecs: - `IPostingListCodec::decode` keeps the new `PaddedPODArray<char> & buffer` scratch parameter from master, threaded through `SegmentedPostingListCodec`, `PostingListCodecBitpacking` and `PostingListCodecNone`, while keeping `createEncoder` from this branch. `IPostingListCodec::encode` and `encodePostingsInBlocks` stay removed - encoding goes through `IPostingListEncoder`. - `PostingsSerialization::deserialize` uses `resolveCodec` from master, so an uncompressed posting list is always decoded by `PostingListCodecNone` instead of the configured codec, and contradictory `RawPostings` / `IsCompressed` header flags are rejected. - `PostingListCodecNone::decode` now reuses the shared `readContiguousBytes` helper and the caller-owned scratch buffer instead of a local `std::vector`. - Kept both `TextIndexSerialization::serializeRawPostings` (this branch) and `TextIndexSerialization::checkTokenSize` (master). Co-Authored-By: Claude Opus 5 <[email protected]>
Changelog category (leave one):
Slightly better code which is needed for future development.
Version info
26.8.1.1190(included in26.8and later)