make the stream decoder completeness scan resumable - #2
Open
joe-clickhouse wants to merge 2 commits into
Open
Conversation
There was a problem hiding this comment.
Pull request overview
This PR optimizes StreamDecoder's allocation-free block completeness scan to be resumable across incremental feed() calls, avoiding repeated re-walks of partial blocks (notably for String and Nullable(String)).
Changes:
- Add resumable completeness-scan entrypoints (
block_end_resume*) backed by aScanProgresscheckpoint that survives onlyUnexpectedEof. - Teach
StreamDecoderto retainScanProgressbetween feeds so scanning resumes within the current partial block. - Expand streaming tests to cover chunking-parity across multiple type shapes and add a linearity guard for large
Stringblocks; document the change inCHANGELOG.md.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/native/stream_decoder.rs | Store and reuse scan checkpoints across feeds; add chunking-parity and linearity tests for resumable scanning. |
| src/native/decode/mod.rs | Implement resumable completeness scanning with ScanProgress and targeted per-row checkpointing for String and Nullable(String). |
| CHANGELOG.md | Add an Unreleased note describing the resumable scan optimization and its behavioral non-impact. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
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.
Summary
The streaming decoder runs an allocation free completeness scan before decoding each block. The scan restarted from the beginning of the partial block on every feed, and for String columns it walks a varint per row. Consequently a block arriving over many transport chunks was
O(block bytes * chunks).StreamDecodernow keeps aScanProgresscheckpoint recording the parsed header, each fully scanned top level column, and per row progress insideStringandNullable(String)bodies. The next scan resumes where the last one stopped, so each buffered byte is scanned once. Offsets are relative to the block start and survive buffer compaction. The checkpoint clears on every outcome except incomplete data, so stream acceptance, error surfacing andfinish()behavior are unchanged.