Skip to content

Commit 2f93de2

Browse files
committed
Add unit test
1 parent e84f8b6 commit 2f93de2

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -327,8 +327,8 @@ under the License.
327327
<io.netty.tryReflectionSetAccessible>true</io.netty.tryReflectionSetAccessible>
328328
<user.timezone>UTC</user.timezone>
329329
<!-- Note: changing the below configuration might increase the max allocation size for a vector
330-
which in turn can cause OOM. -->
331-
<arrow.vector.max_allocation_bytes>1048576</arrow.vector.max_allocation_bytes>
330+
which in turn can cause OOM. Using 1MB - 1byte to simulate the defaul limit of 2^31 - 1 bytes. -->
331+
<arrow.vector.max_allocation_bytes>1048575</arrow.vector.max_allocation_bytes>
332332
</systemPropertyVariables>
333333
<useModulePath>false</useModulePath>
334334
</configuration>

vector/src/test/java/org/apache/arrow/vector/TestVectorReAlloc.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import java.nio.charset.StandardCharsets;
2525
import org.apache.arrow.memory.BufferAllocator;
2626
import org.apache.arrow.memory.RootAllocator;
27+
import org.apache.arrow.memory.util.CommonUtil;
2728
import org.apache.arrow.vector.complex.DenseUnionVector;
2829
import org.apache.arrow.vector.complex.FixedSizeListVector;
2930
import org.apache.arrow.vector.complex.ListVector;
@@ -222,6 +223,17 @@ public void testVariableAllocateAfterReAlloc() throws Exception {
222223
}
223224
}
224225

226+
@Test
227+
public void testVariableReAllocAbove1GB() throws Exception {
228+
try (final VarCharVector vector = new VarCharVector("", allocator)) {
229+
long desiredSizeAboveLastPowerOf2 =
230+
CommonUtil.nextPowerOfTwo(BaseVariableWidthVector.MAX_ALLOCATION_SIZE) / 2 + 1;
231+
vector.reallocDataBuffer(desiredSizeAboveLastPowerOf2);
232+
233+
assertTrue(vector.getDataBuffer().capacity() >= desiredSizeAboveLastPowerOf2);
234+
}
235+
}
236+
225237
@Test
226238
public void testLargeVariableAllocateAfterReAlloc() throws Exception {
227239
try (final LargeVarCharVector vector = new LargeVarCharVector("", allocator)) {

0 commit comments

Comments
 (0)