feat: add lazy scan planning iterators - #873
Open
manuzhang wants to merge 3 commits into
Open
Conversation
Co-authored-by: Codex <codex@openai.com>
There was a problem hiding this comment.
Pull request overview
This PR introduces a fallible, pull-based Iterator<T> abstraction and uses it to add streaming (lazy) scan planning APIs so manifest reading and file task planning can be consumed incrementally instead of fully materialized, while preserving scan metrics reporting for fully and partially consumed plans.
Changes:
- Add a generic
Iterator<T>interface (Next()+ToVector()) for fallible, lazily produced values. - Implement streaming manifest-entry reading and streaming file-scan-task planning via new
*Iterator()APIs onManifestReader,ManifestGroup, andDataTableScan(keeping existing eager APIs intact). - Update examples and add tests covering iterator lifetime/resource ownership and lazy planning behavior.
Reviewed changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| src/iceberg/util/meson.build | Installs the new iterator.h header in Meson builds. |
| src/iceberg/util/iterator.h | Adds the fallible pull-based Iterator<T> interface and a ToVector() helper. |
| src/iceberg/type_fwd.h | Forward-declares Iterator<T> for use in public APIs. |
| src/iceberg/test/table_scan_test.cc | Adds coverage for PlanFilesIterator() behavior and iterator lifetime beyond the scan object. |
| src/iceberg/test/manifest_reader_test.cc | Adds coverage that manifest entry iterators own reader resources and can outlive the reader. |
| src/iceberg/table_scan.h | Adds DataTableScan::PlanFilesIterator() public API. |
| src/iceberg/table_scan.cc | Implements lazy scan planning and metrics reporting for partially consumed iterators. |
| src/iceberg/manifest/manifest_reader.h | Adds EntriesIterator() / LiveEntriesIterator() streaming APIs (defaulting to eager adaptation). |
| src/iceberg/manifest/manifest_reader.cc | Implements streaming manifest entry iteration and refactors eager reads to build on iterators. |
| src/iceberg/manifest/manifest_reader_internal.h | Updates internal reader interface/state to support iterator-owned resources. |
| src/iceberg/manifest/manifest_group.h | Adds ManifestGroup::PlanFilesIterator() streaming planning API. |
| src/iceberg/manifest/manifest_group.cc | Implements pull-based task planning iterator over manifest batches and entries. |
| example/demo_example.cc | Demonstrates consuming scan tasks via PlanFilesIterator() using Next(). |
Co-authored-by: Codex <codex@openai.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 13 out of 13 changed files in this pull request and generated 1 comment.
Suppressed comments (1)
src/iceberg/util/iterator.h:62
- Iterator::ToVector() unconditionally moves the element into the output vector. This fails to compile for copy-only T (copy-constructible but not move-constructible). Using std::move_if_noexcept(*value) keeps move semantics for moveable types while falling back to copy when move is unavailable/undesirable.
values.push_back(std::move(value).value());
Co-authored-by: Codex <codex@openai.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.
What changed
Iterator<T>utilityWhy
The existing scan planning APIs materialize every manifest entry and file scan task before returning. Large tables can therefore require memory proportional to the full scan plan. The new iterator APIs process one manifest batch at a time and let callers consume tasks on demand while keeping the existing eager APIs compatible.
User impact
Callers can use
DataTableScan::PlanFilesIterator()to bound planning memory and stop planning early. ExistingPlanFiles()behavior remains available. Streaming planning is pull-based and does not eagerly submit manifest work to the configured planning executor.