-
Notifications
You must be signed in to change notification settings - Fork 70
feat: Introduce ArrowArrayReader factory on FileScanTask #200
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one | ||
| * or more contributor license agreements. See the NOTICE file | ||
| * distributed with this work for additional information | ||
| * regarding copyright ownership. The ASF licenses this file | ||
| * to you 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 <optional> | ||
|
|
||
| #include "iceberg/arrow_c_data.h" | ||
| #include "iceberg/iceberg_export.h" | ||
| #include "iceberg/result.h" | ||
|
|
||
| namespace iceberg { | ||
|
|
||
| /// \brief A reader interface that returns ArrowArray in a streaming fashion. | ||
| class ICEBERG_EXPORT ArrowArrayReader { | ||
|
Comment on lines
+30
to
+31
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. Why ArrowArray instead of RecordBatches?
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. @zeroshade Could you help review #214 which returns |
||
| public: | ||
| /// \brief Read next batch of data. | ||
| /// | ||
| /// \return std::nullopt if the reader has no more data, otherwise `ArrowArray`. | ||
| virtual Result<std::optional<ArrowArray>> Next() = 0; | ||
|
|
||
| /// \brief Get schema of data returned by `Next`. | ||
| virtual Result<ArrowSchema> Schema() const = 0; | ||
|
|
||
| /// \brief Close this reader and release all resources. | ||
| virtual Status Close() = 0; | ||
|
|
||
| virtual ~ArrowArrayReader() = default; | ||
| }; | ||
|
|
||
| } // namespace iceberg | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,9 +19,7 @@ | |
|
|
||
| #include "iceberg/table_scan.h" | ||
|
|
||
| #include <algorithm> | ||
| #include <ranges> | ||
|
|
||
| #include "iceberg/file_reader.h" | ||
| #include "iceberg/manifest_entry.h" | ||
| #include "iceberg/manifest_list.h" | ||
| #include "iceberg/manifest_reader.h" | ||
|
|
@@ -45,6 +43,21 @@ int32_t FileScanTask::files_count() const { return 1; } | |
|
|
||
| int64_t FileScanTask::estimated_row_count() const { return data_file_->record_count; } | ||
|
|
||
| Result<std::unique_ptr<ArrowArrayReader>> FileScanTask::ToArrowArrayReader( | ||
|
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. Shouldn't a
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. We have two libraries, one is |
||
| const std::shared_ptr<Schema>& projected_schema, | ||
| const std::shared_ptr<Expression>& filter, const std::shared_ptr<FileIO>& io) const { | ||
| const ReaderOptions options{.path = data_file_->file_path, | ||
| .length = data_file_->file_size_in_bytes, | ||
| .io = io, | ||
| .projection = projected_schema, | ||
| .filter = filter}; | ||
|
|
||
| ICEBERG_ASSIGN_OR_RAISE(auto reader, | ||
| ReaderFactoryRegistry::Open(data_file_->file_format, options)); | ||
|
|
||
| return reader; | ||
| } | ||
|
|
||
| TableScanBuilder::TableScanBuilder(std::shared_ptr<TableMetadata> table_metadata, | ||
| std::shared_ptr<FileIO> file_io) | ||
| : file_io_(std::move(file_io)) { | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.