pvary commented on code in PR #13562:
URL: https://github.com/apache/iceberg/pull/13562#discussion_r2236819434
##########
arrow/src/main/java/org/apache/iceberg/arrow/vectorized/VectorizedArrowReader.java:
##########
@@ -258,89 +261,11 @@ private void allocateDictEncodedVector() {
this.readType = ReadType.DICTIONARY;
}
- private void allocateVectorBasedOnOriginalType(PrimitiveType primitive,
Field arrowField) {
- switch (primitive.getOriginalType()) {
- case ENUM:
- case JSON:
- case UTF8:
- case BSON:
- this.vec = arrowField.createVector(rootAlloc);
- // TODO: Possibly use the uncompressed page size info to set the
initial capacity
- vec.setInitialCapacity(batchSize * AVERAGE_VARIABLE_WIDTH_RECORD_SIZE);
- vec.allocateNewSafe();
- this.readType = ReadType.VARCHAR;
- this.typeWidth = UNKNOWN_WIDTH;
- break;
- case INT_8:
- case INT_16:
- case INT_32:
- this.vec = arrowField.createVector(rootAlloc);
- ((IntVector) vec).allocateNew(batchSize);
- this.readType = ReadType.INT;
- this.typeWidth = (int) IntVector.TYPE_WIDTH;
- break;
- case DATE:
- this.vec = arrowField.createVector(rootAlloc);
- ((DateDayVector) vec).allocateNew(batchSize);
- this.readType = ReadType.INT;
- this.typeWidth = (int) IntVector.TYPE_WIDTH;
- break;
- case INT_64:
- this.vec = arrowField.createVector(rootAlloc);
- ((BigIntVector) vec).allocateNew(batchSize);
- this.readType = ReadType.LONG;
- this.typeWidth = (int) BigIntVector.TYPE_WIDTH;
- break;
- case TIMESTAMP_MILLIS:
- this.vec = arrowField.createVector(rootAlloc);
- ((BigIntVector) vec).allocateNew(batchSize);
- this.readType = ReadType.TIMESTAMP_MILLIS;
- this.typeWidth = (int) BigIntVector.TYPE_WIDTH;
- break;
- case TIMESTAMP_MICROS:
- this.vec = arrowField.createVector(rootAlloc);
- if (((Types.TimestampType) icebergField.type()).shouldAdjustToUTC()) {
- ((TimeStampMicroTZVector) vec).allocateNew(batchSize);
- } else {
- ((TimeStampMicroVector) vec).allocateNew(batchSize);
- }
- this.readType = ReadType.LONG;
- this.typeWidth = (int) BigIntVector.TYPE_WIDTH;
- break;
- case TIME_MICROS:
- this.vec = arrowField.createVector(rootAlloc);
- ((TimeMicroVector) vec).allocateNew(batchSize);
- this.readType = ReadType.LONG;
- this.typeWidth = (int) TimeMicroVector.TYPE_WIDTH;
- break;
- case DECIMAL:
- this.vec = arrowField.createVector(rootAlloc);
- switch (primitive.getPrimitiveTypeName()) {
- case BINARY:
- case FIXED_LEN_BYTE_ARRAY:
- ((FixedSizeBinaryVector) vec).allocateNew(batchSize);
- this.readType = ReadType.FIXED_LENGTH_DECIMAL;
- this.typeWidth = primitive.getTypeLength();
- break;
- case INT64:
- ((BigIntVector) vec).allocateNew(batchSize);
- this.readType = ReadType.LONG_BACKED_DECIMAL;
- this.typeWidth = (int) BigIntVector.TYPE_WIDTH;
- break;
- case INT32:
- ((IntVector) vec).allocateNew(batchSize);
- this.readType = ReadType.INT_BACKED_DECIMAL;
- this.typeWidth = (int) IntVector.TYPE_WIDTH;
- break;
- default:
- throw new UnsupportedOperationException(
- "Unsupported base type for decimal: " +
primitive.getPrimitiveTypeName());
- }
- break;
- default:
- throw new UnsupportedOperationException(
- "Unsupported logical type: " + primitive.getOriginalType());
- }
+ private void allocateVectorBasedOnLogicalTypeAnnotation(
+ PrimitiveType primitive, Field arrowField) {
+ primitive
+ .getLogicalTypeAnnotation()
+ .accept(new
VectorizedArrowReaderLogicalTypeAnnotationVisitor(arrowField, primitive));
}
Review Comment:
Is it worth to create a separate method for 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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]