-
Notifications
You must be signed in to change notification settings - Fork 70
feat: add manifest list reader #143
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
Xuanwo
merged 11 commits into
apache:main
from
dongxiao1198:support_manifest_list_reader
Jul 17, 2025
Merged
Changes from 6 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
5201ade
feat: add manifest list reader
d283d38
fix manifest_list build issue
f74159f
fix arrow memory leak
705c4ea
rename to internal
b80c0d2
refactor MakeReader
a9f4525
remove useless unique_ptr
9712fd3
refactor some impl
d77b8f2
resolve conflict
fc65a8b
Merge branch 'main' into support_manifest_list_reader
dongxiao1198 34d0a06
fix conflict
835b26a
use ManifestReader::MakeReader instead of CreateManifestReader
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| /* | ||
| * 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. | ||
| */ | ||
|
|
||
| #include "iceberg/arrow_c_data_guard_internal.h" | ||
|
|
||
| namespace iceberg::internal { | ||
|
|
||
| ArrowArrayGuard::~ArrowArrayGuard() { | ||
| if (array_ != nullptr) { | ||
| ArrowArrayRelease(array_); | ||
| } | ||
| } | ||
|
|
||
| ArrowSchemaGuard::~ArrowSchemaGuard() { | ||
| if (schema_ != nullptr) { | ||
| ArrowSchemaRelease(schema_); | ||
| } | ||
| } | ||
|
|
||
| ArrowArrayViewGuard::~ArrowArrayViewGuard() { | ||
| if (view_ != nullptr) { | ||
| ArrowArrayViewReset(view_); | ||
| } | ||
| } | ||
|
|
||
| ArrowArrayBufferGuard::~ArrowArrayBufferGuard() { | ||
| if (buffer_ != nullptr) { | ||
| ArrowBufferReset(buffer_); | ||
| } | ||
| } | ||
|
|
||
| } // namespace iceberg::internal |
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,64 @@ | ||
| /* | ||
| * 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 <nanoarrow/nanoarrow.h> | ||
|
|
||
| #include "iceberg/arrow_c_data.h" | ||
|
|
||
| namespace iceberg::internal { | ||
|
|
||
| class ArrowArrayGuard { | ||
| public: | ||
| explicit ArrowArrayGuard(ArrowArray* array) : array_(array) {} | ||
| ~ArrowArrayGuard(); | ||
|
|
||
| private: | ||
| ArrowArray* array_; | ||
| }; | ||
|
|
||
| class ArrowSchemaGuard { | ||
| public: | ||
| explicit ArrowSchemaGuard(ArrowSchema* schema) : schema_(schema) {} | ||
| ~ArrowSchemaGuard(); | ||
|
|
||
| private: | ||
| ArrowSchema* schema_; | ||
| }; | ||
|
|
||
| class ArrowArrayViewGuard { | ||
| public: | ||
| explicit ArrowArrayViewGuard(ArrowArrayView* view) : view_(view) {} | ||
| ~ArrowArrayViewGuard(); | ||
|
|
||
| private: | ||
| ArrowArrayView* view_; | ||
| }; | ||
|
|
||
| class ArrowArrayBufferGuard { | ||
| public: | ||
| explicit ArrowArrayBufferGuard(ArrowBuffer* buffer) : buffer_(buffer) {} | ||
| ~ArrowArrayBufferGuard(); | ||
|
|
||
| private: | ||
| ArrowBuffer* buffer_; | ||
| }; | ||
|
|
||
| } // namespace iceberg::internal |
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,58 @@ | ||
| /* | ||
| * 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. | ||
| */ | ||
|
|
||
| #include "iceberg/manifest_reader.h" | ||
|
|
||
| #include "iceberg/manifest_entry.h" | ||
| #include "iceberg/manifest_list.h" | ||
| #include "iceberg/manifest_reader_internal.h" | ||
| #include "iceberg/schema.h" | ||
| #include "iceberg/util/macros.h" | ||
|
|
||
| namespace iceberg { | ||
|
|
||
| Result<std::shared_ptr<ManifestReader>> ManifestReader::MakeReader( | ||
| const std::string& manifest_location, std::shared_ptr<FileIO> file_io, | ||
| std::shared_ptr<Schema> partition_schema) { | ||
| auto manifest_entry_schema = ManifestEntry::TypeFromPartitionType(partition_schema); | ||
| auto fields_span = manifest_entry_schema->fields(); | ||
| std::vector<SchemaField> fields(fields_span.begin(), fields_span.end()); | ||
| auto schema = std::make_shared<Schema>(fields); | ||
| ICEBERG_ASSIGN_OR_RAISE( | ||
| auto reader, | ||
| ReaderFactoryRegistry::Open( | ||
| FileFormatType::kAvro, | ||
| {.path = manifest_location, .io = std::move(file_io), .projection = schema})); | ||
| return std::make_shared<ManifestReaderImpl>(std::move(reader), std::move(schema)); | ||
| } | ||
|
|
||
| Result<std::shared_ptr<ManifestListReader>> ManifestListReader::MakeReader( | ||
| const std::string& manifest_list_location, std::shared_ptr<FileIO> file_io) { | ||
| std::vector<SchemaField> fields(ManifestFile::Type().fields().begin(), | ||
| ManifestFile::Type().fields().end()); | ||
| auto schema = std::make_shared<Schema>(fields); | ||
| ICEBERG_ASSIGN_OR_RAISE( | ||
| auto reader, | ||
| ReaderFactoryRegistry::Open(FileFormatType::kAvro, {.path = manifest_list_location, | ||
| .io = std::move(file_io), | ||
| .projection = schema})); | ||
| return std::make_shared<ManifestListReaderImpl>(std::move(reader), std::move(schema)); | ||
| } | ||
|
|
||
| } // namespace iceberg |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we want to evaluate Nanoarrow eventually? As it has these helpers