Repository navigation
Packed skip indices: consolidate access and hide internals - #108853
Merged
Algunenano merged 5 commits intoJul 6, 2026
Merged
Conversation
…he part The skp_idx.packed read overlay lived in the concrete `DataPartStorageOnDiskFull` and every size/existence consumer open-coded a "checksums entry, else ask the storage" two-step, so the packed layout leaked into the read step, the cost model and the index reader. Move the overlay into `DataPartStorageOnDiskBase`: `existsFile`, `getFileSize`, `prepareRead` and `readFileIfExists` are now `final` and resolve a `skp_idx_...` archive member first, then delegate to the new `existsFileImpl` / `getFileSizeImpl` / `prepareReadImpl` / `readFileIfExistsImpl` native hooks that each storage implements. No storage can bypass the overlay, and one that keeps no standalone `skp_idx.packed` (e.g. packed part storage) simply has no reader, so the `*Impl` path serves the substreams. A cheap `skp_idx_` prefix gate runs before the archive is loaded or probed, so unrelated files (`checksums.txt`, `count.txt`, column and metadata files) never touch the archive. Give the part two resolving helpers so callers stop deciding where a stream lives: `getFileSizeOrZeroResolved` (checksums size, else the storage) and `getStreamNameOrHashResolved` (checksums name, else the storage). The read-step cost model, `calculateSecondaryIndicesSizesOnDisk`, `hasSecondaryIndex` and the index reader now go through them instead of open-coding the fallback. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Follow-up to the read-side consolidation. Removes the remaining duplicated packed-skip-index logic on the write and mutate paths: - Replace the two identical "is this index inside the source archive?" lambdas in MutateTask with one part method `isSkipIndexInPackedArchive`, which enumerates the index's substreams and probes the storage. The part is the right owner (it already knows about index substreams) and reuses the storage's file-name probe, so no index vocabulary leaks into the storage. - Fold the identical read/write/copy/finalize body of `copyPackedSkipIndicesFilesInto` and `filterPackedSkipIndicesArchiveTo` into a shared `copyArchiveEntryTo`; each keeps its own iteration source and predicate, so the rewritten archive's entry order is unchanged. - `initSkipIndices` uses the existing `getSkipIndicesPackedWriter()` accessor instead of re-inlining the borrowed-or-owned ternary. - Bundle `MergeTreeWriterStream`'s four trailing packed-archive arguments into a single `SizeAdaptivePacking` value (default = no packing), so column and text-index streams keep their plain construction. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
The size-adaptive spool buffer is an implementation detail of how a skip-index
stream writes its bytes (bundled into skp_idx.packed when small, spilled to a
standalone file when large). It had its own header/cpp, so the type was visible
to anything that included it.
Move the class into an anonymous namespace in MergeTreeWriterStream.cpp, its
only consumer, and delete the standalone files. Reword the comments elsewhere
that named the class to describe the behaviour ("size-adaptive packing")
instead. Also drop the dead "optional, pass nullptr" path on the shared spill
flag: both the data and marks files always pass it, so it becomes a reference.
No behaviour change.
Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Contributor
|
Workflow [PR], commit [c9a9cf9] Summary: ✅
AI ReviewSummaryThis PR consolidates packed skip-index read/write/mutation access behind Missing context / blind spots
Final Verdict✅ No new findings. |
initSkipIndices runs from the MergeTreeDataPartWriterOnDisk constructor, so calling the virtual getSkipIndicesPackedWriter there bypasses dispatch (clang-analyzer-optin.cplusplus.VirtualCall). Read the members directly instead; the accessor stays for the external polymorphic callers. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Contributor
LLVM Coverage Report
Changed lines: Changed C/C++ lines covered: 185/203 (91.13%) · Uncovered code |
zeekay
pushed a commit
to hanzoai/datastore
that referenced
this pull request
Sep 11, 2026
…x-substream-store Packed skip indices: consolidate access and hide internals
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Follow-up refactor to the packed skip indices feature, addressing review feedback that packed-format knowledge had leaked across many MergeTree classes. Pure consolidation, no behaviour change.
Three steps:
skp_idx.packed. The archive overlay is resolved once inDataPartStorageOnDiskBase, gated by the cheapskp_idx_prefix, and is inert on storages without a standalone archive.MergeTreeWriterStream's four packed-archive constructor arguments into oneSizeAdaptivePackingvalue.SizeAdaptiveSpoolBuffer(the size-adaptive write buffer that decides bundle-vs-spill per substream) toMergeTreeWriterStream.cpp, deleting its standalone header/cpp so the type is no longer includable elsewhere.Related: #105321
Changelog category (leave one):
Version info
26.7.1.550(included in26.7and later)