use of org.apache.drill.exec.vector.NullableIntVector in project drill by apache.
the class TestToNullable method testNullable.
@Test
public void testNullable() {
MaterializedField nullableIntSchema = SchemaBuilder.columnSchema("a", MinorType.INT, DataMode.OPTIONAL);
@SuppressWarnings("resource") NullableIntVector sourceVector = new NullableIntVector(nullableIntSchema, fixture.allocator());
NullableIntVector.Mutator sourceMutator = sourceVector.getMutator();
sourceVector.allocateNew(100);
for (int i = 0; i < 100; i++) {
sourceMutator.set(i, i * 10);
}
sourceMutator.setValueCount(100);
NullableIntVector destVector = new NullableIntVector(nullableIntSchema, fixture.allocator());
sourceVector.toNullable(destVector);
assertEquals(0, sourceVector.getAccessor().getValueCount());
NullableIntVector.Accessor destAccessor = destVector.getAccessor();
assertEquals(100, destAccessor.getValueCount());
for (int i = 0; i < 100; i++) {
assertFalse(destAccessor.isNull(i));
assertEquals(i * 10, destAccessor.get(i));
}
destVector.clear();
// Don't clear the intVector, it should be empty.
// If it is not, the test will fail with a memory leak error.
}
Aggregations