use of org.apache.drill.exec.vector.UInt4Vector in project drill by apache.
the class TestValueVector method testVectors.
/**
* Convenience method that allows running tests on various {@link ValueVector vector} instances.
*
* @param test test function to execute
*/
private void testVectors(VectorVerifier test) throws Exception {
final MaterializedField[] fields = { MaterializedField.create(EMPTY_SCHEMA_PATH, UInt4Holder.TYPE), MaterializedField.create(EMPTY_SCHEMA_PATH, BitHolder.TYPE), MaterializedField.create(EMPTY_SCHEMA_PATH, VarCharHolder.TYPE), MaterializedField.create(EMPTY_SCHEMA_PATH, NullableVarCharHolder.TYPE), MaterializedField.create(EMPTY_SCHEMA_PATH, RepeatedListVector.TYPE), MaterializedField.create(EMPTY_SCHEMA_PATH, MapVector.TYPE), MaterializedField.create(EMPTY_SCHEMA_PATH, RepeatedMapVector.TYPE) };
final ValueVector[] vectors = { new UInt4Vector(fields[0], allocator), new BitVector(fields[1], allocator), new VarCharVector(fields[2], allocator), new NullableVarCharVector(fields[3], allocator), new RepeatedListVector(fields[4], allocator, null), new MapVector(fields[5], allocator, null), new RepeatedMapVector(fields[6], allocator, null) };
try {
for (final ValueVector vector : vectors) {
test.verify(vector);
}
} finally {
AutoCloseables.close(vectors);
}
}
use of org.apache.drill.exec.vector.UInt4Vector in project drill by apache.
the class TestValueVector method testFixedVectorReallocation.
@Test(expected = OversizedAllocationException.class)
public void testFixedVectorReallocation() {
final MaterializedField field = MaterializedField.create(EMPTY_SCHEMA_PATH, UInt4Holder.TYPE);
final UInt4Vector vector = new UInt4Vector(field, allocator);
// edge case 1: buffer size = max value capacity
final int expectedValueCapacity = BaseValueVector.MAX_ALLOCATION_SIZE / 4;
try {
vector.allocateNew(expectedValueCapacity);
assertEquals(expectedValueCapacity, vector.getValueCapacity());
vector.reAlloc();
assertEquals(expectedValueCapacity * 2, vector.getValueCapacity());
} finally {
vector.close();
}
// common case: value count < max value capacity
try {
vector.allocateNew(BaseValueVector.MAX_ALLOCATION_SIZE / 8);
// value allocation reaches to MAX_VALUE_ALLOCATION
vector.reAlloc();
// this should throw an IOOB
vector.reAlloc();
} finally {
vector.close();
}
}
use of org.apache.drill.exec.vector.UInt4Vector in project drill by apache.
the class TestEmptyPopulation method initialize.
@Before
public void initialize() {
offsets = new UInt4Vector(BaseRepeatedValueVector.OFFSETS_FIELD, allocator);
offsets.allocateNewSafe();
accessor = offsets.getAccessor();
mutator = offsets.getMutator();
mutator.set(0, 0);
mutator.setValueCount(1);
Assert.assertTrue("offsets must have one value", accessor.getValueCount() == 1);
populator = new EmptyValuePopulator(offsets);
}
use of org.apache.drill.exec.vector.UInt4Vector in project drill by apache.
the class TestBatchValidator method testRepeatedBadValueOffset.
@Test
public void testRepeatedBadValueOffset() {
BatchSchema schema = new SchemaBuilder().add("a", MinorType.VARCHAR, DataMode.REPEATED).build();
SingleRowSet batch = fixture.rowSetBuilder(schema).add((Object) new String[] {}).add((Object) new String[] { "fred", "barney", "wilma" }).add((Object) new String[] { "dino" }).build();
VectorAccessible va = batch.vectorAccessible();
@SuppressWarnings("resource") ValueVector v = va.iterator().next().getValueVector();
RepeatedVarCharVector rvc = (RepeatedVarCharVector) v;
@SuppressWarnings("resource") VarCharVector vc = rvc.getDataVector();
@SuppressWarnings("resource") UInt4Vector ov = vc.getOffsetVector();
ov.getMutator().set(4, 100_000);
BatchValidator validator = new BatchValidator(batch.vectorAccessible(), true);
validator.validate();
List<String> errors = validator.errors();
assertEquals(1, errors.size());
assertTrue(errors.get(0).contains("Invalid offset"));
batch.clear();
}
use of org.apache.drill.exec.vector.UInt4Vector in project drill by apache.
the class TestBatchValidator method zapOffset.
public void zapOffset(SingleRowSet batch, int index, int bogusValue) {
// Here we are evil: stomp on an offset to simulate corruption.
// Don't do this in real code!
VectorAccessible va = batch.vectorAccessible();
@SuppressWarnings("resource") ValueVector v = va.iterator().next().getValueVector();
VarCharVector vc = (VarCharVector) v;
@SuppressWarnings("resource") UInt4Vector ov = vc.getOffsetVector();
ov.getMutator().set(index, bogusValue);
}
Aggregations