vibhatha commented on code in PR #44627:
URL: https://github.com/apache/arrow/pull/44627#discussion_r1826888160
##########
java/vector/src/test/java/org/apache/arrow/vector/TestSplitAndTransfer.java:
##########
@@ -198,6 +202,47 @@ public void testWithEmptyVector() {
toDUV.clear();
}
+ @Test
+ public void testListVectorWithEmptyMapVector() {
+ // List<element: Map(false)<entries: Struct<key: Utf8 not null, value:
Utf8> not null>>
+ int valueCount = 1;
+ List<Field> children = new ArrayList<>();
+ children.add(new Field("key", FieldType.notNullable(new ArrowType.Utf8()),
null));
+ children.add(new Field("value", FieldType.nullable(new ArrowType.Utf8()),
null));
+ Field structField = new Field(
+ "entries",
+ FieldType.notNullable(ArrowType.Struct.INSTANCE),
+ children);
+
+ Field mapField = new Field(
+ "element",
+ FieldType.notNullable(new ArrowType.Map(false)),
+ asList(structField));
+
+ Field listField = new Field(
+ "list",
+ FieldType.nullable(new ArrowType.List()),
+ asList(mapField));
+
+ ListVector fromListVector = (ListVector) listField.createVector(allocator);
+ fromListVector.allocateNew();
+ fromListVector.setValueCount(valueCount);
+
+ // child vector is empty
+ MapVector dataVector = (MapVector) fromListVector.getDataVector();
+ dataVector.allocateNew();
+ // unset capacity to mimic observed failure mode
+ dataVector.getOffsetBuffer().capacity(0);
+
+ TransferPair transferPair =
fromListVector.getTransferPair(fromListVector.getAllocator());
+ transferPair.splitAndTransfer(0, valueCount);
+ ListVector toListVector = (ListVector) transferPair.getTo();
+
+ assertEquals(valueCount, toListVector.getValueCount());
+ fromListVector.clear();
Review Comment:
nit: use try-with-resources
--
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]