Skip to content

[VL] Make ValueStreamDataSource::next() iterative instead of recursive - #12563

Draft
malinjawi wants to merge 1 commit into
apache:mainfrom
malinjawi:fix/valuestream-empty-batch
Draft

[VL] Make ValueStreamDataSource::next() iterative instead of recursive#12563
malinjawi wants to merge 1 commit into
apache:mainfrom
malinjawi:fix/valuestream-empty-batch

Conversation

@malinjawi

@malinjawi malinjawi commented Jul 19, 2026

Copy link
Copy Markdown
Contributor

What changes are proposed in this pull request?

ValueStreamDataSource::next() retried by calling itself. Each exhausted iterator, end-of-stream batch, or batch fully eliminated by a dynamic filter consumed a stack frame, so a long run of eliminated batches — the common case once a selective dynamic filter is pushed into a value stream (#11657) — grew the native stack in proportion to the number of skipped batches.

The retry logic is now a loop. This is a pure recursion-to-iteration change; every branch keeps its previous semantics:

  • an exhausted stream and a null batch both release the current iterator before retrying,
  • a fully-filtered batch retries on the same iterator,
  • an empty pending-iterator queue still returns an engaged null RowVectorPtr, so TableScan reads it as "current split finished" rather than connector-blocked.

How was this patch tested?

New manyConsecutiveFullyFilteredBatches case in ValueStreamDynamicFilterTest pushes a dynamic filter that eliminates 4096 consecutive batches within a single split, then asserts the surviving batch after them still comes through. It rides the existing velox_operators_test target.

Was this patch authored or co-authored using generative AI tooling?

Generated-by: Claude Code (reviewed and tested before submission)

@github-actions github-actions Bot added the VELOX label Jul 19, 2026
@malinjawi
malinjawi force-pushed the fix/valuestream-empty-batch branch from b1878ec to 30fda50 Compare July 19, 2026 11:06
@malinjawi
malinjawi force-pushed the fix/valuestream-empty-batch branch from 43aebfe to 1799eda Compare August 10, 2026 11:00
@malinjawi
malinjawi marked this pull request as ready for review August 10, 2026 11:01
@malinjawi
malinjawi marked this pull request as draft August 11, 2026 08:18
ValueStreamDataSource::next() retried by calling itself. Each exhausted
iterator, end-of-stream batch, or batch fully eliminated by a dynamic
filter consumed a stack frame, so a long run of eliminated batches --
the common case once a selective dynamic filter is pushed into a value
stream -- grew the native stack in proportion to the number of skipped
batches.

The retry logic is now a loop. Every branch keeps its previous
semantics: an exhausted stream and a null batch both release the current
iterator before retrying, a fully-filtered batch retries on the same
iterator, and an empty pending-iterator queue still returns an engaged
null RowVectorPtr so TableScan reads it as "current split finished"
rather than connector-blocked.

Adds a regression test that pushes a dynamic filter eliminating 4096
consecutive batches through a single split.
@malinjawi
malinjawi force-pushed the fix/valuestream-empty-batch branch from 1799eda to 9a474f1 Compare August 11, 2026 08:25
@malinjawi malinjawi changed the title [VL] Fix ValueStream empty-batch and finished-split handling [VL] Make ValueStreamDataSource::next() iterative instead of recursive Aug 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant