-
Notifications
You must be signed in to change notification settings - Fork 20
Extract interfaces from FileBatchReader to PrefetchFileBatchReader #47
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
+221
−309
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
4c8089f
refactor: extract interfaces from FileBatchReader to PrefetchFileBatc…
lucasfang cef3183
fix
lucasfang 276cf85
fix
lucasfang 1247fd1
fix
lucasfang 57e62aa
Merge branch 'main' into orc_prefetch
lucasfang bceadf7
fix
lucasfang 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,76 @@ | ||
| /* | ||
| * Copyright 2026-present Alibaba Inc. | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| #pragma once | ||
|
|
||
| #include <memory> | ||
| #include <utility> | ||
| #include <vector> | ||
|
|
||
| #include "paimon/reader/file_batch_reader.h" | ||
|
|
||
| namespace paimon { | ||
|
|
||
| /// The prefetch file batch reader extends the basic FileBatchReader interface for prefetch read, | ||
| /// if a format implementation inherits from this class, it will automatically support the C++ | ||
| /// Paimon prefetch capability and integrate with the Paimon prefetch framework. | ||
| class PAIMON_EXPORT PrefetchFileBatchReader : public FileBatchReader { | ||
lucasfang marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| public: | ||
| /// Seeks to a specific row in the file. | ||
| /// @param row_number The row number to seek to. | ||
| /// @return The status of the operation. | ||
| virtual Status SeekToRow(uint64_t row_number) = 0; | ||
|
|
||
| /// Retrieves the row number of the next row to be read. | ||
| /// This method indicates the current read position within the file. | ||
| /// @return The row number of the next row to read. | ||
| virtual uint64_t GetNextRowToRead() const = 0; | ||
|
|
||
| /// Generates a list of row ranges to be read in batches. | ||
| /// Each range specifies the start and end row numbers for a batch, | ||
| /// allowing for efficient batch processing. | ||
| /// | ||
| /// The underlying format layer (e.g., parquet) is responsible for determining | ||
| /// the most effective way to split the data. This could be by row groups, stripes, | ||
| /// or other internal data structures. The key principle is to split the data | ||
| /// into contiguous, seekable ranges to minimize read amplification. | ||
| /// | ||
| /// For example: | ||
| /// - A parquet format could split by RowGroup directly, ensuring each range aligns | ||
| /// with a single RowGroup. | ||
| /// | ||
| /// The smallest splittable unit must be seekable to its start position, and the | ||
| /// splitting strategy should aim to avoid read amplification. | ||
| /// | ||
| /// @param need_prefetch A pointer to a boolean. The format layer sets this to indicate whether | ||
| /// prefetching is beneficial for the current scenario, to avoid performance regression in | ||
| /// certain cases. | ||
| /// @return A vector of pairs, where each pair represents a range with a start and end row | ||
| /// number. | ||
| virtual Result<std::vector<std::pair<uint64_t, uint64_t>>> GenReadRanges( | ||
| bool* need_prefetch) const = 0; | ||
|
|
||
| /// Sets the specific row ranges as a hint to be read from format file. | ||
| /// | ||
| /// If the specific file format does not support explicit range-based reads, implementations may | ||
| /// gracefully ignore this hint and provide an empty (no-op) implementation. | ||
| /// | ||
| /// @param read_ranges A vector of pairs, where each pair defines a half-open interval | ||
| /// `[start_row, end_row)`. The `start_row` is inclusive, and the `end_row` is exclusive. | ||
| virtual Status SetReadRanges(const std::vector<std::pair<uint64_t, uint64_t>>& read_ranges) = 0; | ||
| }; | ||
|
|
||
| } // namespace paimon | ||
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
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.