Skip to content

Commit 60cf20f

Browse files
author
Yicong Huang
committed
test: simplify tests
1 parent af5d019 commit 60cf20f

2 files changed

Lines changed: 26 additions & 61 deletions

File tree

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

Lines changed: 13 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1101,34 +1101,22 @@ public void testCopyValueSafeForExtensionType() throws Exception {
11011101
}
11021102

11031103
@Test
1104-
public void testNestedEmptyLargeListOffsetBuffer() {
1105-
// Test that nested LargeListVector properly allocates offset buffer
1106-
// even when nested writers are never invoked. According to Arrow spec,
1107-
// offset buffer must have N+1 entries. Even when N=0, it should contain [0].
1108-
try (LargeListVector outerList = LargeListVector.empty("outer", allocator)) {
1109-
// Setup LargeList<LargeList<Int>>
1110-
outerList.addOrGetVector(FieldType.nullable(MinorType.LARGELIST.getType()));
1111-
LargeListVector innerList = (LargeListVector) outerList.getDataVector();
1112-
innerList.addOrGetVector(FieldType.nullable(MinorType.INT.getType()));
1113-
1114-
// Allocate both outer and inner - simulates case where inner is never written to
1115-
outerList.allocateNew();
1116-
innerList.allocateNew();
1117-
outerList.setValueCount(0);
1118-
innerList.setValueCount(0);
1119-
1120-
// Get field buffers - this is what IPC serialization uses
1121-
List<ArrowBuf> innerBuffers = innerList.getFieldBuffers();
1122-
1123-
// Verify inner list offset buffer has at least OFFSET_WIDTH (8) bytes
1104+
public void testEmptyLargeListOffsetBuffer() {
1105+
// Test that LargeListVector has correct readableBytes after allocation.
1106+
// According to Arrow spec, offset buffer must have N+1 entries.
1107+
// Even when N=0, it should contain [0].
1108+
try (LargeListVector list = LargeListVector.empty("list", allocator)) {
1109+
list.addOrGetVector(FieldType.nullable(MinorType.INT.getType()));
1110+
list.allocateNew();
1111+
list.setValueCount(0);
1112+
1113+
List<ArrowBuf> buffers = list.getFieldBuffers();
11241114
assertTrue(
1125-
innerBuffers.get(1).readableBytes() >= LargeListVector.OFFSET_WIDTH,
1126-
"Inner LargeList offset buffer should have at least "
1115+
buffers.get(1).readableBytes() >= LargeListVector.OFFSET_WIDTH,
1116+
"Offset buffer should have at least "
11271117
+ LargeListVector.OFFSET_WIDTH
11281118
+ " bytes for offset[0]");
1129-
1130-
// Verify offset[0] = 0
1131-
assertEquals(0L, innerList.getOffsetBuffer().getLong(0));
1119+
assertEquals(0L, list.getOffsetBuffer().getLong(0));
11321120
}
11331121
}
11341122

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

Lines changed: 13 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1380,45 +1380,22 @@ public void testCopyValueSafeForExtensionType() throws Exception {
13801380
}
13811381

13821382
@Test
1383-
public void testNestedEmptyListOffsetBuffer() {
1384-
// Test that 3-level nested ListVector properly allocates offset buffers
1385-
// even when nested writers are never invoked. According to Arrow spec,
1386-
// offset buffer must have N+1 entries. Even when N=0, it should contain [0].
1387-
try (ListVector level0 = ListVector.empty("level0", allocator)) {
1388-
// Setup List<List<List<Int>>> - 3 levels
1389-
level0.addOrGetVector(FieldType.nullable(MinorType.LIST.getType()));
1390-
ListVector level1 = (ListVector) level0.getDataVector();
1391-
level1.addOrGetVector(FieldType.nullable(MinorType.LIST.getType()));
1392-
ListVector level2 = (ListVector) level1.getDataVector();
1393-
level2.addOrGetVector(FieldType.nullable(MinorType.INT.getType()));
1394-
1395-
// Allocate all levels - simulates case where nested levels are never written to
1396-
level0.allocateNew();
1397-
level1.allocateNew();
1398-
level2.allocateNew();
1399-
level0.setValueCount(0);
1400-
level1.setValueCount(0);
1401-
level2.setValueCount(0);
1402-
1403-
// Verify all levels have properly allocated offset buffers
1404-
List<ArrowBuf> level1Buffers = level1.getFieldBuffers();
1405-
List<ArrowBuf> level2Buffers = level2.getFieldBuffers();
1406-
1407-
assertTrue(
1408-
level1Buffers.get(1).readableBytes() >= BaseRepeatedValueVector.OFFSET_WIDTH,
1409-
"Level1 offset buffer should have at least "
1410-
+ BaseRepeatedValueVector.OFFSET_WIDTH
1411-
+ " bytes for offset[0]");
1412-
1383+
public void testEmptyListOffsetBuffer() {
1384+
// Test that ListVector has correct readableBytes after allocation.
1385+
// According to Arrow spec, offset buffer must have N+1 entries.
1386+
// Even when N=0, it should contain [0].
1387+
try (ListVector list = ListVector.empty("list", allocator)) {
1388+
list.addOrGetVector(FieldType.nullable(MinorType.INT.getType()));
1389+
list.allocateNew();
1390+
list.setValueCount(0);
1391+
1392+
List<ArrowBuf> buffers = list.getFieldBuffers();
14131393
assertTrue(
1414-
level2Buffers.get(1).readableBytes() >= BaseRepeatedValueVector.OFFSET_WIDTH,
1415-
"Level2 offset buffer should have at least "
1394+
buffers.get(1).readableBytes() >= BaseRepeatedValueVector.OFFSET_WIDTH,
1395+
"Offset buffer should have at least "
14161396
+ BaseRepeatedValueVector.OFFSET_WIDTH
14171397
+ " bytes for offset[0]");
1418-
1419-
// Verify offset[0] = 0 for all levels
1420-
assertEquals(0, level1.getOffsetBuffer().getInt(0));
1421-
assertEquals(0, level2.getOffsetBuffer().getInt(0));
1398+
assertEquals(0, list.getOffsetBuffer().getInt(0));
14221399
}
14231400
}
14241401

0 commit comments

Comments
 (0)