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 2020/08/19 08:08:38 UTC

[GitHub] [iceberg] shardulm94 commented on a change in pull request #1339: ORC: Use MetricsConfig

shardulm94 commented on a change in pull request #1339:
URL: https://github.com/apache/iceberg/pull/1339#discussion_r472815623



##########
File path: orc/src/main/java/org/apache/iceberg/orc/OrcMetrics.java
##########
@@ -203,7 +227,29 @@ private static Metrics buildOrcMetrics(final long numOfRows, final TypeDescripti
       BooleanColumnStatistics booleanStats = (BooleanColumnStatistics) columnStats;
       max = booleanStats.getTrueCount() > 0;
     }
-    return Optional.ofNullable(Conversions.toByteBuffer(column.type(), max));
+    return Optional.ofNullable(Conversions.toByteBuffer(type, truncateIfNeeded(Bound.UPPER, type, max, metricsMode)));
+  }
+
+  private static Object truncateIfNeeded(Bound bound, Type type, Object value, MetricsMode metricsMode) {
+    // ORC only stores min/max for String columns

Review comment:
       Got confused for a second, I think what the comment wants to say is that out of the two types which require truncation (string/binary) ORC only supports string bounds. Can we rephrase the comment?

##########
File path: orc/src/main/java/org/apache/iceberg/orc/OrcMetrics.java
##########
@@ -203,7 +227,29 @@ private static Metrics buildOrcMetrics(final long numOfRows, final TypeDescripti
       BooleanColumnStatistics booleanStats = (BooleanColumnStatistics) columnStats;
       max = booleanStats.getTrueCount() > 0;
     }
-    return Optional.ofNullable(Conversions.toByteBuffer(column.type(), max));
+    return Optional.ofNullable(Conversions.toByteBuffer(type, truncateIfNeeded(Bound.UPPER, type, max, metricsMode)));
+  }
+
+  private static Object truncateIfNeeded(Bound bound, Type type, Object value, MetricsMode metricsMode) {
+    // ORC only stores min/max for String columns
+    if (value == null || metricsMode == MetricsModes.Full.get() || type.typeId() != Type.TypeID.STRING) {

Review comment:
       Might be better to check if the Metrics mode != Truncate, seems easier to read that way. Also we have a Precondition later to assert the same, which may be unnecessary if we make the check here.




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

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