pvary commented on code in PR #13562:
URL: https://github.com/apache/iceberg/pull/13562#discussion_r2236810550


##########
arrow/src/main/java/org/apache/iceberg/arrow/vectorized/VectorizedArrowReader.java:
##########
@@ -508,6 +433,179 @@ public static VectorizedReader<?> 
replaceWithMetadataReader(
     return reader;
   }
 
+  private final class VectorizedArrowReaderLogicalTypeAnnotationVisitor
+      implements LogicalTypeAnnotation.LogicalTypeAnnotationVisitor<Object> {
+    private final Field arrowField;
+    private final PrimitiveType primitive;
+
+    VectorizedArrowReaderLogicalTypeAnnotationVisitor(Field arrowField, 
PrimitiveType primitive) {
+      this.arrowField = arrowField;
+      this.primitive = primitive;
+    }
+
+    @Override
+    public Optional<Object> visit(
+        LogicalTypeAnnotation.StringLogicalTypeAnnotation stringLogicalType) {
+      return visitEnumJsonBsonString();
+    }
+
+    @Override
+    public Optional<Object> 
visit(LogicalTypeAnnotation.EnumLogicalTypeAnnotation enumLogicalType) {
+      return visitEnumJsonBsonString();
+    }
+
+    @Override
+    public Optional<Object> 
visit(LogicalTypeAnnotation.UUIDLogicalTypeAnnotation uuidLogicalType) {
+      // Fallback to allocation based on primitive type name
+      VectorizedArrowReader.this.allocateVectorBasedOnTypeName(
+          VectorizedArrowReader.this.columnDescriptor.getPrimitiveType(), 
arrowField);
+      return Optional.empty();
+    }
+
+    @Override
+    public Optional<Object> visit(
+        LogicalTypeAnnotation.DecimalLogicalTypeAnnotation decimalLogicalType) 
{
+      VectorizedArrowReader.this.vec =
+          arrowField.createVector(VectorizedArrowReader.this.rootAlloc);
+      switch (primitive.getPrimitiveTypeName()) {
+        case BINARY:
+        case FIXED_LEN_BYTE_ARRAY:
+          ((FixedSizeBinaryVector) VectorizedArrowReader.this.vec)
+              .allocateNew(VectorizedArrowReader.this.batchSize);
+          VectorizedArrowReader.this.readType = ReadType.FIXED_LENGTH_DECIMAL;
+          VectorizedArrowReader.this.typeWidth = primitive.getTypeLength();
+          break;
+        case INT64:
+          ((BigIntVector) VectorizedArrowReader.this.vec)
+              .allocateNew(VectorizedArrowReader.this.batchSize);
+          VectorizedArrowReader.this.readType = ReadType.LONG_BACKED_DECIMAL;
+          VectorizedArrowReader.this.typeWidth = (int) BigIntVector.TYPE_WIDTH;
+          break;
+        case INT32:
+          ((IntVector) VectorizedArrowReader.this.vec)
+              .allocateNew(VectorizedArrowReader.this.batchSize);
+          VectorizedArrowReader.this.readType = ReadType.INT_BACKED_DECIMAL;
+          VectorizedArrowReader.this.typeWidth = (int) IntVector.TYPE_WIDTH;
+          break;
+        default:
+          throw new UnsupportedOperationException(
+              "Unsupported base type for decimal: " + 
primitive.getPrimitiveTypeName());
+      }

Review Comment:
   nit: newlines please after the end of blocks. See: 
https://iceberg.apache.org/contribute/#block-spacing



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