shangxinli commented on code in PR #774:
URL: https://github.com/apache/iceberg-cpp/pull/774#discussion_r4297617480
##########
src/iceberg/manifest/manifest_util.cc:
##########
@@ -68,4 +96,43 @@ Result<ManifestFile> CopyAppendManifest(
return writer->ToManifestFile();
}
+Result<ManifestFile> CopyRewriteManifest(
+ const ManifestFile& manifest, const std::shared_ptr<FileIO>& file_io,
+ const std::shared_ptr<Schema>& schema, const
std::shared_ptr<PartitionSpec>& spec,
+ int64_t snapshot_id, const std::string& output_path, int8_t
format_version) {
+ ICEBERG_ASSIGN_OR_RAISE(auto source_format_version,
+ ReadManifestFormatVersion(manifest, file_io));
+ // Require explicit snapshot IDs and preserve them in the copied entries.
+ ICEBERG_ASSIGN_OR_RAISE(auto inheritable_metadata,
InheritableMetadataFactory::Empty());
+ ICEBERG_ASSIGN_OR_RAISE(
+ auto reader, ManifestReader::Make(
+ manifest.manifest_path, manifest.manifest_length,
file_io, schema,
+ spec, std::move(inheritable_metadata),
manifest.first_row_id,
+ /*is_committed=*/false));
+ ICEBERG_ASSIGN_OR_RAISE(auto entries, reader->Entries());
+
+ ICEBERG_ASSIGN_OR_RAISE(
+ auto writer,
+ ManifestWriter::MakeWriter(format_version, snapshot_id, output_path,
file_io, spec,
+ schema, manifest.content,
manifest.first_row_id));
+ for (auto& entry : entries) {
+ // A rewritten added manifest may only contain existing entries.
+ if (entry.status == ManifestStatus::kAdded) {
+ return ValidationFailed("Cannot add manifest with added files");
Review Comment:
Bumping this one - unlike the wording nit above, reusing the addManifest
message here loses which status was actually invalid.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]