-
Notifications
You must be signed in to change notification settings - Fork 103
feat: add FastAppend #516
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
Merged
feat: add FastAppend #516
Changes from 5 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
141eadc
feat: add FastAppend
zhjwpku 7cfc0e9
fix: review comments
zhjwpku 610cf80
Make DataFileSet preserve insertion order for v3 row ID assignment
zhjwpku 004a162
fix: windows build error
zhjwpku 310fae7
fix: move Set to SnapshotUpdate
zhjwpku 7118dcc
fix: more review comments
zhjwpku 04fb4a4
fix: windows build failure
zhjwpku e2e216d
attempt to fix manifest reader
wgtmac 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,75 @@ | ||
| /* | ||
| * 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/manifest_util_internal.h" | ||
|
|
||
| #include <memory> | ||
| #include <optional> | ||
|
|
||
| #include "iceberg/inheritable_metadata.h" | ||
| #include "iceberg/manifest/manifest_entry.h" | ||
| #include "iceberg/manifest/manifest_reader.h" | ||
| #include "iceberg/manifest/manifest_writer.h" | ||
| #include "iceberg/result.h" | ||
| #include "iceberg/schema.h" | ||
| #include "iceberg/snapshot.h" | ||
| #include "iceberg/util/macros.h" | ||
|
|
||
| namespace iceberg { | ||
|
|
||
| Result<ManifestFile> CopyAppendManifest( | ||
| const ManifestFile& manifest, std::shared_ptr<FileIO> file_io, | ||
| std::shared_ptr<Schema> schema, std::shared_ptr<PartitionSpec> spec, | ||
| int64_t snapshot_id, const std::string& output_path, int8_t format_version, | ||
| SnapshotSummaryBuilder* summary_builder) { | ||
| ICEBERG_ASSIGN_OR_RAISE(auto reader, | ||
| ManifestReader::Make(manifest, file_io, schema, spec)); | ||
|
wgtmac marked this conversation as resolved.
Outdated
|
||
| ICEBERG_ASSIGN_OR_RAISE(auto entries, reader->Entries()); | ||
|
|
||
| // use metadata that will add the current snapshot's ID for the rewrite | ||
| ICEBERG_ASSIGN_OR_RAISE(auto inheritable_metadata, | ||
| InheritableMetadataFactory::ForCopy(snapshot_id)); | ||
|
|
||
| // do not produce row IDs for the copy | ||
| ICEBERG_ASSIGN_OR_RAISE( | ||
| auto writer, | ||
| ManifestWriter::MakeWriter(format_version, snapshot_id, output_path, file_io, spec, | ||
| schema, ManifestContent::kData)); | ||
|
|
||
| // Write all entries as added entries with the new snapshot ID | ||
| for (auto& entry : entries) { | ||
| ICEBERG_PRECHECK(entry.status == ManifestStatus::kAdded, | ||
| "Manifest to copy must only contain added entries"); | ||
|
|
||
| ICEBERG_RETURN_UNEXPECTED(inheritable_metadata->Apply(entry)); | ||
|
|
||
| if (summary_builder != nullptr && entry.data_file != nullptr) { | ||
| ICEBERG_RETURN_UNEXPECTED(summary_builder->AddedFile(*spec, *entry.data_file)); | ||
| } | ||
|
|
||
| ICEBERG_RETURN_UNEXPECTED(writer->WriteAddedEntry(entry)); | ||
| } | ||
|
|
||
| ICEBERG_RETURN_UNEXPECTED(writer->Close()); | ||
| ICEBERG_ASSIGN_OR_RAISE(auto new_manifest, writer->ToManifestFile()); | ||
|
|
||
| return new_manifest; | ||
|
zhjwpku marked this conversation as resolved.
Outdated
|
||
| } | ||
|
|
||
| } // 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| /* | ||
| * 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 | ||
|
|
||
| /// \file iceberg/manifest/manifest_util_internal.h | ||
| /// Internal utility functions for manifest operations. | ||
|
|
||
| #include <cstdint> | ||
| #include <memory> | ||
| #include <string> | ||
|
|
||
| #include "iceberg/iceberg_export.h" | ||
| #include "iceberg/result.h" | ||
| #include "iceberg/type_fwd.h" | ||
|
|
||
| namespace iceberg { | ||
|
|
||
| /// \brief Copy an append manifest with a new snapshot ID. | ||
| /// | ||
| /// This function copies a manifest file that contains only ADDED entries, | ||
| /// rewriting it with a new snapshot ID. This is similar to Java's | ||
| /// ManifestFiles.copyAppendManifest. | ||
| /// | ||
| /// \param manifest The manifest file to copy | ||
| /// \param file_io File IO implementation to use | ||
| /// \param schema Table schema | ||
| /// \param spec Partition spec for the manifest | ||
| /// \param snapshot_id The new snapshot ID to assign to entries | ||
| /// \param output_path Path where the new manifest will be written | ||
| /// \param format_version Table format version | ||
| /// \param summary_builder Optional summary builder to update with file metrics | ||
| /// \return The copied manifest file, or an error | ||
| ICEBERG_EXPORT Result<ManifestFile> CopyAppendManifest( | ||
| const ManifestFile& manifest, std::shared_ptr<FileIO> file_io, | ||
| std::shared_ptr<Schema> schema, std::shared_ptr<PartitionSpec> spec, | ||
|
zhjwpku marked this conversation as resolved.
Outdated
|
||
| int64_t snapshot_id, const std::string& output_path, int8_t format_version, | ||
| SnapshotSummaryBuilder* summary_builder = nullptr); | ||
|
|
||
| } // 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
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
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.