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



##########
File path: core/src/main/java/org/apache/iceberg/avro/ValueWriters.java
##########
@@ -135,145 +150,145 @@ private NullWriter() {
 
     @Override
     public void write(Void ignored, Encoder encoder) throws IOException {
-      encoder.writeNull();
+      throw new IllegalStateException("[BUG] NullWriter shouldn't be used for 
writing nulls for Avro");
     }
-  }
 
-  private static class BooleanWriter implements ValueWriter<Boolean> {
-    private static final BooleanWriter INSTANCE = new BooleanWriter();
+    @Override
+    public Stream<FieldMetrics> metrics() {
+      throw new IllegalStateException("[BUG] NullWriter shouldn't be used for 
writing nulls for Avro");
+    }
+  }
 
-    private BooleanWriter() {
+  private static class BooleanWriter extends ComparableWriter<Boolean> {
+    private BooleanWriter(int id) {
+      super(id);
     }
 
     @Override
-    public void write(Boolean bool, Encoder encoder) throws IOException {
+    protected void writeVal(Boolean bool, Encoder encoder) throws IOException {
       encoder.writeBoolean(bool);
     }
   }
 
-  private static class ByteToIntegerWriter implements ValueWriter<Byte> {
-    private static final ByteToIntegerWriter INSTANCE = new 
ByteToIntegerWriter();
-
-    private ByteToIntegerWriter() {
+  private static class ByteToIntegerWriter extends 
MetricsAwareTransformWriter<Byte, Integer> {
+    private ByteToIntegerWriter(int id) {
+      super(id, Integer::compareTo, Byte::intValue);

Review comment:
       This change is will lead to unnecessary boxing of the converted value 
because it needs to pass an Object to `writeVal`. I'd rather duplicate a little 
bit more code than have the object creation in a tight loop. Can you update the 
byte and short writers to avoid this?




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