WZhuo commented on code in PR #386:
URL: https://github.com/apache/iceberg-cpp/pull/386#discussion_r2597540704


##########
src/iceberg/table_metadata.cc:
##########
@@ -258,13 +290,95 @@ Result<std::unique_ptr<TableMetadata>> 
TableMetadataUtil::Read(
   return TableMetadataFromJson(json);
 }
 
+Status TableMetadataUtil::Write(FileIO& io, const TableMetadata* base,
+                                TableMetadata* metadata) {
+  ICEBERG_CHECK(metadata != nullptr, "The metadata is nullptr.");
+
+  int version = -1;
+  if (base != nullptr && !base->metadata_file_location.empty()) {
+    // parse current version from location
+    version = ParseVersionFromLocation(base->metadata_file_location);
+  }
+
+  ICEBERG_ASSIGN_OR_RAISE(std::string new_file_location,
+                          NewTableMetadataFilePath(*metadata, version + 1));

Review Comment:
   The ParseVersionFromLocation method only gets the version of a specified 
file, not the next version. I think this makes the function's semantics clearer.



-- 
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]

Reply via email to