You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@iceberg.apache.org by GitBox <gi...@apache.org> on 2021/12/01 21:36:10 UTC

[GitHub] [iceberg] findepi commented on a change in pull request #3638: Ensure MetricsConfig is immutable

findepi commented on a change in pull request #3638:
URL: https://github.com/apache/iceberg/pull/3638#discussion_r760588686



##########
File path: core/src/main/java/org/apache/iceberg/MetricsConfig.java
##########
@@ -35,21 +38,22 @@
 import static org.apache.iceberg.TableProperties.DEFAULT_WRITE_METRICS_MODE_DEFAULT;
 import static org.apache.iceberg.TableProperties.METRICS_MODE_COLUMN_CONF_PREFIX;
 
-public class MetricsConfig implements Serializable {
+@Immutable
+public final class MetricsConfig implements Serializable {
 
   private static final Logger LOG = LoggerFactory.getLogger(MetricsConfig.class);
   private static final Joiner DOT = Joiner.on('.');
 
-  private Map<String, MetricsMode> columnModes = Maps.newHashMap();
-  private MetricsMode defaultMode;
+  private final Map<String, MetricsMode> columnModes;
+  private final MetricsMode defaultMode;
 
-  private MetricsConfig() {
+  private MetricsConfig(Map<String, MetricsMode> columnModes, MetricsMode defaultMode) {
+    this.columnModes = ImmutableMap.copyOf(columnModes);

Review comment:
       `ImmutableMap.copyOf` is O(1) when value provided is an immutablemap already




-- 
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: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org