Return lazily-encoded QueryOutput from the execute functions#8
Draft
kalabukdima wants to merge 1 commit into
Draft
Return lazily-encoded QueryOutput from the execute functions#8kalabukdima wants to merge 1 commit into
QueryOutput from the execute functions#8kalabukdima wants to merge 1 commit into
Conversation
- Replace the writer-sink interface with Option<QueryOutput>: block range metadata is available up front, blocks encode one per write_next_block call, and framing (JSON lines, arrays) belongs to the caller - Return Option<ArrowOutput> with the same block range metadata from the Arrow variants - Cap the block header scan at the phase-1 budget cutoff so the range-end boundary block can't wrongly survive the response trim - Cover budget trimming, boundary blocks, empty results and JSON/Arrow parity with synthetic-chunk tests Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.
Problem
Worker needs to know the last block that has been written. It also needs JSONL output instead of a JSON array. Modifying the interface to expose that information.
What changed
execute_plan/execute_chunknow returnResult<Option<QueryOutput>>.QueryOutputexposesnum_blocks/first_block/last_blockimmediately — block selection completes before any encoding — and encodes one block perwrite_next_blockcall. A streaming consumer holds at most one encoded block; buffering callers useinto_json_lines().Nonemeans the queried range doesn't intersect the chunk. The handle is fully owned: no lifetime parameter, and it stays valid after the chunk reader drops. The Arrow variants returnOption<ArrowOutput>with the same block-range metadata.Budget-trim bug fixed. The phase-1 scan optimization capped the item scan at the budget cutoff but left the block-header scan uncapped, so the range-end boundary block entered the output with unaccounted weight — inflating both the response and last_block. The header scan is now capped to the same cutoff, matching the non-optimized path.
Worker serializes responses as JSON Lines (matching the legacy engine's wire format — it previously sent a JSON array) and reports the engine's post-trim last_block, falling back to the range end only when the output is empty.
Breaking
Callers of
execute_plan/execute_chunk/execute_plan_arrowmust drop the writer argument and handleOption. No engine API emits a JSON array anymore.Draft status
I still need to verify whether the ref cloning change doesn't affect the performance.