rdblue commented on a change in pull request #1963:
URL: https://github.com/apache/iceberg/pull/1963#discussion_r579896146



##########
File path: core/src/main/java/org/apache/iceberg/avro/ValueWriters.java
##########
@@ -492,4 +561,153 @@ protected Object get(IndexedRecord struct, int pos) {
       return struct.get(pos);
     }
   }
+
+  private abstract static class FloatingPointWriter<T extends Comparable<T>>
+      extends ComparableWriter<T> {
+    private long nanValueCount;
+
+    FloatingPointWriter(int id) {
+      super(id);
+    }
+
+    @Override
+    public void write(T datum, Encoder encoder) throws IOException {
+      valueCount++;
+
+      if (datum == null) {
+        nullValueCount++;
+      } else if (NaNUtil.isNaN(datum)) {
+        nanValueCount++;
+      } else {
+        if (max == null || datum.compareTo(max) > 0) {
+          this.max = datum;
+        }
+        if (min == null || datum.compareTo(min) < 0) {
+          this.min = datum;
+        }
+      }
+
+      writeVal(datum, encoder);
+    }
+
+    @Override
+    public Stream<FieldMetrics> metrics() {
+      return Stream.of(new FieldMetrics<>(id, valueCount, nullValueCount, 
nanValueCount, min, max));
+    }
+  }
+
+  public abstract static class MetricsAwareStringWriter<T extends 
Comparable<T>> extends ComparableWriter<T> {

Review comment:
       Is this only used for Spark's UTF8String?




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



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

Reply via email to