rdblue commented on code in PR #11904:
URL: https://github.com/apache/iceberg/pull/11904#discussion_r1906132097


##########
parquet/src/main/java/org/apache/iceberg/data/parquet/BaseParquetReaders.java:
##########
@@ -114,113 +112,6 @@ public ParquetValueReader<?> struct(
     }
   }
 
-  private class LogicalTypeAnnotationParquetValueReaderVisitor
-      implements 
LogicalTypeAnnotation.LogicalTypeAnnotationVisitor<ParquetValueReader<?>> {
-
-    private final ColumnDescriptor desc;
-    private final org.apache.iceberg.types.Type.PrimitiveType expected;
-    private final PrimitiveType primitive;
-
-    LogicalTypeAnnotationParquetValueReaderVisitor(
-        ColumnDescriptor desc,
-        org.apache.iceberg.types.Type.PrimitiveType expected,
-        PrimitiveType primitive) {
-      this.desc = desc;
-      this.expected = expected;
-      this.primitive = primitive;
-    }
-
-    @Override
-    public Optional<ParquetValueReader<?>> visit(
-        LogicalTypeAnnotation.StringLogicalTypeAnnotation stringLogicalType) {
-      return Optional.of(new ParquetValueReaders.StringReader(desc));
-    }
-
-    @Override
-    public Optional<ParquetValueReader<?>> visit(
-        LogicalTypeAnnotation.EnumLogicalTypeAnnotation enumLogicalType) {
-      return Optional.of(new ParquetValueReaders.StringReader(desc));
-    }
-
-    @Override
-    public Optional<ParquetValueReader<?>> visit(DecimalLogicalTypeAnnotation 
decimalLogicalType) {
-      switch (primitive.getPrimitiveTypeName()) {
-        case BINARY:
-        case FIXED_LEN_BYTE_ARRAY:
-          return Optional.of(
-              new ParquetValueReaders.BinaryAsDecimalReader(desc, 
decimalLogicalType.getScale()));
-        case INT64:
-          return Optional.of(
-              new ParquetValueReaders.LongAsDecimalReader(desc, 
decimalLogicalType.getScale()));
-        case INT32:
-          return Optional.of(
-              new ParquetValueReaders.IntegerAsDecimalReader(desc, 
decimalLogicalType.getScale()));
-        default:
-          throw new UnsupportedOperationException(
-              "Unsupported base type for decimal: " + 
primitive.getPrimitiveTypeName());
-      }
-    }
-
-    @Override
-    public Optional<ParquetValueReader<?>> visit(
-        LogicalTypeAnnotation.DateLogicalTypeAnnotation dateLogicalType) {
-      return Optional.of(new DateReader(desc));

Review Comment:
   This and the following 2 methods are the only changes between the 
implementations of this class, so a lot of code is duplicated. In addition, 
this already introduces abstract factory methods for some readers -- including 
timestamps. I think it would be much cleaner to reuse this and call factory 
methods instead:
   
   ```java
     protected abstract PrimitiveReader<?> dateReader(ColumnDescriptor desc);
     protected abstract PrimitiveReader<?> timeReader(ColumnDescriptor desc, 
ChronoUnit unit);
     protected abstract PrimitiveReader<?> timestampReader(ColumnDescriptor 
desc, ChronoUnit unit, boolean isAdjustedToUTC);
   ```



-- 
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-unsubscr...@iceberg.apache.org

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


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

Reply via email to