openinx commented on a change in pull request #2887:
URL: https://github.com/apache/iceberg/pull/2887#discussion_r679769740



##########
File path: core/src/main/java/org/apache/iceberg/TableMetadata.java
##########
@@ -679,10 +700,23 @@ private TableMetadata setCurrentSnapshotTo(Snapshot 
snapshot) {
 
   public TableMetadata replaceProperties(Map<String, String> newProperties) {
     ValidationException.check(newProperties != null, "Cannot set properties to 
null");
-    return new TableMetadata(null, formatVersion, uuid, location,
+    Map<String, String> validProperties = newProperties;
+    int newFormatVersion = formatVersion;
+    if (newProperties.containsKey(PROPERTY_FORMAT_VERSION)) {
+      validProperties = Maps.newHashMap(newProperties);
+      newFormatVersion = 
Integer.parseInt(validProperties.remove(PROPERTY_FORMAT_VERSION));
+    }

Review comment:
       I see lots of this code block in this PR, I'd like to have a small 
abstracted static method:
   
   ```java
     private static int parseFormatVersion(Map<String, String> properties, int 
defaultFormatVersion) {
       return properties.containsKey(PROPERTY_FORMAT_VERSION) ?
           Integer.parseInt(properties.remove(PROPERTY_FORMAT_VERSION)) : 
defaultFormatVersion;
     }
   ```
   
   Then we could simplify this block as: 
   
   ```java
       Map<String, String> validProperties = Maps.newHashMap(newProperties);
       int newFormatVersion = parseFormatVersion(validProperties, 
formatVersion);
   ```




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