Skip to content

make the stream decoder completeness scan resumable - #2

Open
joe-clickhouse wants to merge 2 commits into
mainfrom
joe/stream-decode-fix
Open

make the stream decoder completeness scan resumable#2
joe-clickhouse wants to merge 2 commits into
mainfrom
joe/stream-decode-fix

Conversation

@joe-clickhouse

@joe-clickhouse joe-clickhouse commented Aug 11, 2026

Copy link
Copy Markdown
Collaborator

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

StreamDecoder now keeps a ScanProgress checkpoint recording the parsed header, each fully scanned top level column, and per row progress inside String and Nullable(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 and finish() behavior are unchanged.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 a ScanProgress checkpoint that survives only UnexpectedEof.
  • Teach StreamDecoder to retain ScanProgress between 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 String blocks; document the change in CHANGELOG.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.

Comment thread src/native/stream_decoder.rs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants