@Test(expected = OversizedAllocationException.class) public void testVariableVectorReallocation() { final MaterializedField field = MaterializedField.create(EMPTY_SCHEMA_PATH, UInt4Holder.TYPE); final VarCharVector vector = new VarCharVector(field, allocator); // edge case 1: value count = MAX_VALUE_ALLOCATION final int expectedAllocationInBytes = BaseValueVector.MAX_ALLOCATION_SIZE; final int expectedOffsetSize = 10; try { vector.allocateNew(expectedAllocationInBytes, 10); assertEquals(expectedOffsetSize, vector.getValueCapacity()); assertEquals(expectedAllocationInBytes, vector.getBuffer().capacity()); vector.reAlloc(); assertEquals(expectedOffsetSize * 2, vector.getValueCapacity()); assertEquals(expectedAllocationInBytes * 2, vector.getBuffer().capacity()); } finally { vector.close(); } // common: value count < MAX_VALUE_ALLOCATION try { vector.allocateNew(BaseValueVector.MAX_ALLOCATION_SIZE / 2, 0); vector.reAlloc(); // value allocation reaches to MAX_VALUE_ALLOCATION vector.reAlloc(); // this tests if it overflows } finally { vector.close(); } }