Skip to content

Commit 0530c85

Browse files
committed
test the null count byte by byte and the odd length case
1 parent 95667d3 commit 0530c85

File tree

1 file changed

+27
-1
lines changed

1 file changed

+27
-1
lines changed

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

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,12 +323,38 @@ public void testBitVector() {
323323
// Ensure unallocated space returns 0
324324
assertEquals(0, accessor.get(3));
325325

326+
// unset the previously set bits
326327
m.set(1, 0);
327328
m.set(1022, 0);
328-
329+
// this should set all the array to 0
329330
assertEquals(1024, accessor.getNullCount());
330331

332+
// set all the array to 1
331333
for (int i = 0; i < 1024; ++i) {
334+
assertEquals(1024 - i, accessor.getNullCount());
335+
m.set(i, 1);
336+
}
337+
338+
assertEquals(0, accessor.getNullCount());
339+
340+
// re-allocate the vector with a new (odd) size, smaller by more than a byte than the original vector
341+
// this allows to ensure that we use one byte less memory than the previous one
342+
vector.allocateNew(1015);
343+
344+
// ensure it has been zeroed
345+
assertEquals(1016, accessor.getNullCount());
346+
347+
m.set(0, 1);
348+
m.set(1015, 1); // ensure that the last item of the last byte is allocated
349+
350+
assertEquals(1014, accessor.getNullCount());
351+
352+
vector.zeroVector();
353+
assertEquals(1016, accessor.getNullCount());
354+
355+
// set all the array to 1
356+
for (int i = 0; i < 1016; ++i) {
357+
assertEquals(1016 - i, accessor.getNullCount());
332358
m.set(i, 1);
333359
}
334360

0 commit comments

Comments
 (0)