Repository navigation
feat(scan): Support split and parallel scans - Part-1: validated FileScanTask byte ranges #976
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
wgtmac
merged 8 commits into
apache:main
from
kamcheungting-db:feat/file-scan-task-ranges
Oct 15, 2026
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
4515d70
feat(scan): support validated FileScanTask ranges
kamcheungting-db 3bae712
fix(scan): use designated initializer for task range
kamcheungting-db 7fcb4fd
docs(scan): explain FileScanTask range logic
kamcheungting-db 10e9600
fix comments
kamcheungting-db c097e1e
fix(scan): report invalid standalone ranges as JSON errors
kamcheungting-db 37912d4
style(test): use designated initializers in RejectsInvalidRanges
kamcheungting-db 503e3ab
fix
kamcheungting-db 066fe3d
fix(scan): revalidate FileScanTask range in standalone serializer
kamcheungting-db File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -22,6 +22,7 @@ | |
| /// \file iceberg/table_scan.h | ||
| /// \brief Define table scan APIs and scan task types. | ||
|
|
||
| #include <cstdint> | ||
| #include <functional> | ||
| #include <memory> | ||
| #include <optional> | ||
|
|
@@ -71,10 +72,32 @@ class ICEBERG_EXPORT FileScanTask : public ScanTask { | |
| /// \param data_file The data file to read. | ||
| /// \param delete_files Delete files that apply to this data file. | ||
| /// \param filter Optional residual filter to apply after reading. | ||
| /// \note The data file, delete files, and residual filter must not be mutated while | ||
| /// a planning or reading stream uses this task. | ||
| explicit FileScanTask(std::shared_ptr<DataFile> data_file, | ||
| std::vector<std::shared_ptr<DataFile>> delete_files = {}, | ||
| std::shared_ptr<Expression> filter = nullptr); | ||
|
|
||
| /// \brief Make a task for a validated half-open byte range [start, start + length). | ||
| /// | ||
| /// A range covering the entire file is represented as a whole-file task. An empty | ||
| /// range is valid only for an empty whole file. The data file, delete files, and | ||
| /// residual filter are shared with the resulting task and must not be mutated | ||
| /// while a planning or reading stream uses it. | ||
| static Result<std::shared_ptr<FileScanTask>> MakeSplit( | ||
| std::shared_ptr<DataFile> data_file, int64_t start, int64_t length, | ||
| std::vector<std::shared_ptr<DataFile>> delete_files = {}, | ||
| std::shared_ptr<Expression> filter = nullptr); | ||
|
|
||
| /// \brief The inclusive byte offset where this task starts, or zero for a whole file. | ||
| int64_t start() const { return range_ ? range_->start : 0; } | ||
|
|
||
| /// \brief The byte length of this task, or the current size of a whole file. | ||
| int64_t length() const; | ||
|
|
||
| /// \brief Whether this task reads a proper subset of its data file. | ||
| bool is_split() const { return range_.has_value(); } | ||
|
|
||
| /// \brief The data file that should be read by this scan task. | ||
| const std::shared_ptr<DataFile>& data_file() const { return data_file_; } | ||
|
|
||
|
|
@@ -92,9 +115,22 @@ class ICEBERG_EXPORT FileScanTask : public ScanTask { | |
| int64_t estimated_row_count() const override; | ||
|
|
||
| private: | ||
| // Only set for a partial file; whole-file tasks leave range_ empty. | ||
| struct Range { | ||
| int64_t start; | ||
| int64_t length; | ||
| // Size when the range was validated. Always positive, so safe to divide by. | ||
| int64_t file_size; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. IMHO, this |
||
| }; | ||
|
|
||
| FileScanTask(std::shared_ptr<DataFile> data_file, | ||
| std::vector<std::shared_ptr<DataFile>> delete_files, | ||
| std::shared_ptr<Expression> filter, Range range); | ||
|
|
||
| std::shared_ptr<DataFile> data_file_; | ||
| std::vector<std::shared_ptr<DataFile>> delete_files_; | ||
| std::shared_ptr<Expression> residual_filter_; | ||
| std::optional<Range> range_; | ||
| }; | ||
|
|
||
| /// \brief Stream of file scan tasks. | ||
|
|
||
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
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.