Search in sources :

Example 1 with UInt4Vector

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);
    }
}
Also used : ValueVector(org.apache.drill.exec.vector.ValueVector) BaseValueVector(org.apache.drill.exec.vector.BaseValueVector) BitVector(org.apache.drill.exec.vector.BitVector) NullableVarCharVector(org.apache.drill.exec.vector.NullableVarCharVector) RepeatedListVector(org.apache.drill.exec.vector.complex.RepeatedListVector) RepeatedMapVector(org.apache.drill.exec.vector.complex.RepeatedMapVector) NullableVarCharVector(org.apache.drill.exec.vector.NullableVarCharVector) VarCharVector(org.apache.drill.exec.vector.VarCharVector) MaterializedField(org.apache.drill.exec.record.MaterializedField) NullableUInt4Vector(org.apache.drill.exec.vector.NullableUInt4Vector) UInt4Vector(org.apache.drill.exec.vector.UInt4Vector) RepeatedMapVector(org.apache.drill.exec.vector.complex.RepeatedMapVector) MapVector(org.apache.drill.exec.vector.complex.MapVector)

Example 2 with UInt4Vector

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();
    }
}
Also used : MaterializedField(org.apache.drill.exec.record.MaterializedField) NullableUInt4Vector(org.apache.drill.exec.vector.NullableUInt4Vector) UInt4Vector(org.apache.drill.exec.vector.UInt4Vector) ExecTest(org.apache.drill.exec.ExecTest) Test(org.junit.Test)

Example 3 with UInt4Vector

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);
}
Also used : UInt4Vector(org.apache.drill.exec.vector.UInt4Vector) Before(org.junit.Before)

Example 4 with UInt4Vector

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();
}
Also used : SingleRowSet(org.apache.drill.test.rowSet.RowSet.SingleRowSet) VectorAccessible(org.apache.drill.exec.record.VectorAccessible) RepeatedVarCharVector(org.apache.drill.exec.vector.RepeatedVarCharVector) RepeatedVarCharVector(org.apache.drill.exec.vector.RepeatedVarCharVector) VarCharVector(org.apache.drill.exec.vector.VarCharVector) UInt4Vector(org.apache.drill.exec.vector.UInt4Vector) ValueVector(org.apache.drill.exec.vector.ValueVector) BatchSchema(org.apache.drill.exec.record.BatchSchema) SchemaBuilder(org.apache.drill.test.rowSet.SchemaBuilder) BatchValidator(org.apache.drill.exec.physical.impl.validate.BatchValidator) Test(org.junit.Test)

Example 5 with UInt4Vector

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);
}
Also used : ValueVector(org.apache.drill.exec.vector.ValueVector) VectorAccessible(org.apache.drill.exec.record.VectorAccessible) RepeatedVarCharVector(org.apache.drill.exec.vector.RepeatedVarCharVector) VarCharVector(org.apache.drill.exec.vector.VarCharVector) UInt4Vector(org.apache.drill.exec.vector.UInt4Vector)

Aggregations

UInt4Vector (org.apache.drill.exec.vector.UInt4Vector)9 ValueVector (org.apache.drill.exec.vector.ValueVector)5 Test (org.junit.Test)5 VectorAccessible (org.apache.drill.exec.record.VectorAccessible)4 RepeatedVarCharVector (org.apache.drill.exec.vector.RepeatedVarCharVector)4 VarCharVector (org.apache.drill.exec.vector.VarCharVector)4 BatchValidator (org.apache.drill.exec.physical.impl.validate.BatchValidator)3 BatchSchema (org.apache.drill.exec.record.BatchSchema)3 MaterializedField (org.apache.drill.exec.record.MaterializedField)3 NullableUInt4Vector (org.apache.drill.exec.vector.NullableUInt4Vector)3 SingleRowSet (org.apache.drill.test.rowSet.RowSet.SingleRowSet)3 SchemaBuilder (org.apache.drill.test.rowSet.SchemaBuilder)3 ExecTest (org.apache.drill.exec.ExecTest)2 IOException (java.io.IOException)1 BaseValueVector (org.apache.drill.exec.vector.BaseValueVector)1 BitVector (org.apache.drill.exec.vector.BitVector)1 NullableVarCharVector (org.apache.drill.exec.vector.NullableVarCharVector)1 MapVector (org.apache.drill.exec.vector.complex.MapVector)1 RepeatedListVector (org.apache.drill.exec.vector.complex.RepeatedListVector)1 RepeatedMapVector (org.apache.drill.exec.vector.complex.RepeatedMapVector)1