From e822ea758dc18ade9d3386acfd1d38e7b05ba3dd Mon Sep 17 00:00:00 2001 From: Minji Kim Date: Mon, 7 Mar 2016 15:23:33 -0800 Subject: [PATCH] ARROW-46: ListVector should initialize bits in allocateNew --- .../arrow/vector/complex/ListVector.java | 1 + .../apache/arrow/vector/TestValueVector.java | 20 +++++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/java/vector/src/main/java/org/apache/arrow/vector/complex/ListVector.java b/java/vector/src/main/java/org/apache/arrow/vector/complex/ListVector.java index 13610c4f03f61..3e60c76802380 100644 --- a/java/vector/src/main/java/org/apache/arrow/vector/complex/ListVector.java +++ b/java/vector/src/main/java/org/apache/arrow/vector/complex/ListVector.java @@ -72,6 +72,7 @@ public UnionListWriter getWriter() { @Override public void allocateNew() throws OutOfMemoryException { super.allocateNewSafe(); + bits.allocateNewSafe(); } public void transferTo(ListVector target) { diff --git a/java/vector/src/test/java/org/apache/arrow/vector/TestValueVector.java b/java/vector/src/test/java/org/apache/arrow/vector/TestValueVector.java index 4488d750284c7..ac3eebe98eab7 100644 --- a/java/vector/src/test/java/org/apache/arrow/vector/TestValueVector.java +++ b/java/vector/src/test/java/org/apache/arrow/vector/TestValueVector.java @@ -24,10 +24,13 @@ import java.nio.charset.Charset; import org.apache.arrow.memory.RootAllocator; +import org.apache.arrow.vector.complex.ListVector; import org.apache.arrow.vector.complex.MapVector; import org.apache.arrow.vector.complex.RepeatedListVector; import org.apache.arrow.vector.complex.RepeatedMapVector; import org.apache.arrow.vector.types.MaterializedField; +import org.apache.arrow.vector.types.Types; +import org.apache.arrow.vector.types.Types.MinorType; import org.apache.arrow.vector.util.BasicTypeHelper; import org.apache.arrow.vector.util.OversizedAllocationException; import org.apache.arrow.vector.holders.BitHolder; @@ -518,4 +521,21 @@ public void testVVInitialCapacity() throws Exception { } } + @Test + public void testListVectorShouldNotThrowOversizedAllocationException() throws Exception { + final MaterializedField field = MaterializedField.create(EMPTY_SCHEMA_PATH, + Types.optional(MinorType.LIST)); + ListVector vector = new ListVector(field, allocator, null); + ListVector vectorFrom = new ListVector(field, allocator, null); + vectorFrom.allocateNew(); + + for (int i = 0; i < 10000; i++) { + vector.allocateNew(); + vector.copyFromSafe(0, 0, vectorFrom); + vector.clear(); + } + + vectorFrom.clear(); + vector.clear(); + } }