rdblue commented on a change in pull request #227: ORC column map fix
URL: https://github.com/apache/incubator-iceberg/pull/227#discussion_r300068351
 
 

 ##########
 File path: orc/src/main/java/org/apache/iceberg/orc/OrcFileAppender.java
 ##########
 @@ -95,24 +97,16 @@ public Metrics metrics() {
       // we don't currently have columnSizes or distinct counts.
       Map<Integer, Long> valueCounts = new HashMap<>();
       Map<Integer, Long> nullCounts = new HashMap<>();
-      Integer[] icebergIds = new Integer[orcSchema.getMaximumId() + 1];
-      for (TypeDescription type : columnIds.keySet()) {
-        icebergIds[type.getId()] = columnIds.get(type);
-      }
-      for (int c = 1; c < stats.length; ++c) {
-        if (icebergIds[c] != null) {
-          valueCounts.put(icebergIds[c], stats[c].getNumberOfValues());
-        }
-      }
-      for (TypeDescription child : orcSchema.getChildren()) {
-        int childId = child.getId();
-        if (icebergIds[childId] != null) {
-          nullCounts.put(icebergIds[childId], rows - 
stats[childId].getNumberOfValues());
-        }
+      Map<ColumnMap.IcebergColumn, TypeDescription> icebertToOrc = 
columnIds.inverse();
+      for (Types.NestedField field : schema.columns()) {
+        TypeDescription orcCol = icebertToOrc.get(
+            ColumnMap.newIcebergColumn(field.fieldId(), field.isRequired()));
+        valueCounts.put(field.fieldId(), 
stats[orcCol.getId()].getNumberOfValues());
+        nullCounts.put(field.fieldId(), rows - 
stats[orcCol.getId()].getNumberOfValues());
 
 Review comment:
   I would prefer setting the null count to 1 in this case. That way we get the 
same effect -- at least one row is null.

----------------------------------------------------------------
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:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to