rdblue commented on a change in pull request #655: Add PartitionsTable for 
partition metadata
URL: https://github.com/apache/incubator-iceberg/pull/655#discussion_r347172282
 
 

 ##########
 File path: 
spark/src/main/java/org/apache/iceberg/spark/source/StructInternalRow.java
 ##########
 @@ -219,58 +219,54 @@ private MapData mapToMapData(Types.MapType mapType, 
Map<?, ?> map) {
   private ArrayData collectionToArrayData(Type elementType, Collection<?> 
values) {
     switch (elementType.typeId()) {
       case BOOLEAN:
-        return fillArray(values, array -> (BiConsumer<Integer, Boolean>) 
array::setBoolean);
       case INTEGER:
       case DATE:
       case TIME:
-        return fillArray(values, array -> (BiConsumer<Integer, Integer>) 
array::setInt);
       case LONG:
       case TIMESTAMP:
-        return fillArray(values, array -> (BiConsumer<Integer, Long>) 
array::setLong);
       case FLOAT:
-        return fillArray(values, array -> (BiConsumer<Integer, Float>) 
array::setFloat);
       case DOUBLE:
-        return fillArray(values, array -> (BiConsumer<Integer, Double>) 
array::setDouble);
+        return fillArray(values, array -> (pos, value) -> array[pos] = value);
       case STRING:
         return fillArray(values, array ->
-            (BiConsumer<Integer, CharSequence>) (pos, seq) -> 
array.update(pos, UTF8String.fromString(seq.toString())));
+            (BiConsumer<Integer, CharSequence>) (pos, seq) -> array[pos] = 
UTF8String.fromString(seq.toString()));
       case FIXED:
       case BINARY:
         return fillArray(values, array ->
-            (BiConsumer<Integer, ByteBuffer>) (pos, buf) -> array.update(pos, 
ByteBuffers.toByteArray(buf)));
+            (BiConsumer<Integer, ByteBuffer>) (pos, buf) -> array[pos] = 
ByteBuffers.toByteArray(buf));
       case DECIMAL:
         return fillArray(values, array ->
-            (BiConsumer<Integer, BigDecimal>) (pos, dec) -> array.update(pos, 
Decimal.apply(dec)));
+            (BiConsumer<Integer, BigDecimal>) (pos, dec) -> array[pos] = 
Decimal.apply(dec));
       case STRUCT:
         return fillArray(values, array -> (BiConsumer<Integer, StructLike>) 
(pos, tuple) ->
-            array.update(pos, new 
StructInternalRow(elementType.asStructType(), tuple)));
+            array[pos] = new StructInternalRow(elementType.asStructType(), 
tuple));
       case LIST:
         return fillArray(values, array -> (BiConsumer<Integer, Collection<?>>) 
(pos, list) ->
-            array.update(pos, collectionToArrayData(elementType.asListType(), 
list)));
+            array[pos] = collectionToArrayData(elementType.asListType(), 
list));
       case MAP:
         return fillArray(values, array -> (BiConsumer<Integer, Map<?, ?>>) 
(pos, map) ->
-            array.update(pos, mapToMapData(elementType.asMapType(), map)));
+            array[pos] = mapToMapData(elementType.asMapType(), map));
       default:
         throw new UnsupportedOperationException("Unsupported array element 
type: " + elementType);
     }
   }
 
   @SuppressWarnings("unchecked")
-  private <T> GenericArrayData fillArray(Collection<?> values, 
Function<ArrayData, BiConsumer<Integer, T>> makeSetter) {
-    GenericArrayData array = new GenericArrayData(new Object[values.size()]);
+  private <T> GenericArrayData fillArray(Collection<?> values, 
Function<Object[], BiConsumer<Integer, T>> makeSetter) {
+    Object[] array = new Object[values.size()];
 
 Review comment:
   This avoids calling setter methods that would just set the position in an 
object array, but would cause unboxing and reboxing.

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


With regards,
Apache Git Services

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

Reply via email to