Search in sources :

Example 6 with RepeatedVarCharVector

use of org.apache.drill.exec.vector.RepeatedVarCharVector in project drill by apache.

the class TestBatchValidator method testRepeatedBadArrayOffset.

@Test
public void testRepeatedBadArrayOffset() {
    TupleMetadata schema = new SchemaBuilder().add("a", MinorType.VARCHAR, DataMode.REPEATED).buildSchema();
    SingleRowSet batch = fixture.rowSetBuilder(schema).addRow((Object) strArray()).addRow((Object) strArray("fred", "barney", "wilma")).addRow((Object) strArray("dino")).build();
    VectorAccessible va = batch.vectorAccessible();
    ValueVector v = va.iterator().next().getValueVector();
    RepeatedVarCharVector vc = (RepeatedVarCharVector) v;
    UInt4Vector ov = vc.getOffsetVector();
    ov.getMutator().set(3, 1);
    checkForError(batch, BAD_OFFSETS);
    batch.clear();
}
Also used : ValueVector(org.apache.drill.exec.vector.ValueVector) SingleRowSet(org.apache.drill.exec.physical.rowSet.RowSet.SingleRowSet) VectorAccessible(org.apache.drill.exec.record.VectorAccessible) RepeatedVarCharVector(org.apache.drill.exec.vector.RepeatedVarCharVector) TupleMetadata(org.apache.drill.exec.record.metadata.TupleMetadata) SchemaBuilder(org.apache.drill.exec.record.metadata.SchemaBuilder) UInt4Vector(org.apache.drill.exec.vector.UInt4Vector) SubOperatorTest(org.apache.drill.test.SubOperatorTest) Test(org.junit.Test)

Example 7 with RepeatedVarCharVector

use of org.apache.drill.exec.vector.RepeatedVarCharVector in project drill by apache.

the class TestBatchValidator method testRepeatedBadValueOffset.

@Test
public void testRepeatedBadValueOffset() {
    TupleMetadata schema = new SchemaBuilder().add("a", MinorType.VARCHAR, DataMode.REPEATED).buildSchema();
    SingleRowSet batch = fixture.rowSetBuilder(schema).addRow((Object) strArray()).addRow((Object) strArray("fred", "barney", "wilma")).addRow((Object) strArray("dino")).build();
    VectorAccessible va = batch.vectorAccessible();
    ValueVector v = va.iterator().next().getValueVector();
    RepeatedVarCharVector rvc = (RepeatedVarCharVector) v;
    VarCharVector vc = rvc.getDataVector();
    UInt4Vector ov = vc.getOffsetVector();
    ov.getMutator().set(4, 100_000);
    checkForError(batch, "Invalid offset");
    batch.clear();
}
Also used : ValueVector(org.apache.drill.exec.vector.ValueVector) SingleRowSet(org.apache.drill.exec.physical.rowSet.RowSet.SingleRowSet) VectorAccessible(org.apache.drill.exec.record.VectorAccessible) RepeatedVarCharVector(org.apache.drill.exec.vector.RepeatedVarCharVector) TupleMetadata(org.apache.drill.exec.record.metadata.TupleMetadata) SchemaBuilder(org.apache.drill.exec.record.metadata.SchemaBuilder) RepeatedVarCharVector(org.apache.drill.exec.vector.RepeatedVarCharVector) VarCharVector(org.apache.drill.exec.vector.VarCharVector) UInt4Vector(org.apache.drill.exec.vector.UInt4Vector) SubOperatorTest(org.apache.drill.test.SubOperatorTest) Test(org.junit.Test)

Example 8 with RepeatedVarCharVector

use of org.apache.drill.exec.vector.RepeatedVarCharVector in project drill by axbaretto.

the class TestFillEmpties method testRepeatedVarChar.

@Test
public void testRepeatedVarChar() {
    @SuppressWarnings("resource") RepeatedVarCharVector vector = new RepeatedVarCharVector(SchemaBuilder.columnSchema("a", MinorType.VARCHAR, DataMode.REPEATED), fixture.allocator());
    vector.allocateNew();
    // Create "foo", null, "bar", but omit the null.
    RepeatedVarCharVector.Mutator mutator = vector.getMutator();
    mutator.startNewValue(0);
    byte[] value = makeValue("a");
    mutator.addSafe(0, value, 0, value.length);
    value = makeValue("b");
    mutator.addSafe(0, value, 0, value.length);
    // Work around: test fails without this. But, only the new column writers
    // call this method.
    mutator.fillEmpties(0, 2);
    mutator.startNewValue(2);
    value = makeValue("c");
    mutator.addSafe(2, value, 0, value.length);
    value = makeValue("d");
    mutator.addSafe(2, value, 0, value.length);
    visualize(vector, 3);
    verifyOffsets(vector.getOffsetVector(), new int[] { 0, 2, 2, 4 });
    verifyOffsets(vector.getDataVector().getOffsetVector(), new int[] { 0, 1, 2, 3, 4 });
    vector.close();
}
Also used : RepeatedVarCharVector(org.apache.drill.exec.vector.RepeatedVarCharVector) SubOperatorTest(org.apache.drill.test.SubOperatorTest) Test(org.junit.Test) VectorTest(org.apache.drill.categories.VectorTest)

Example 9 with RepeatedVarCharVector

use of org.apache.drill.exec.vector.RepeatedVarCharVector in project drill by apache.

the class TestFillEmpties method testRepeatedVarChar.

@Test
public void testRepeatedVarChar() {
    RepeatedVarCharVector vector = new RepeatedVarCharVector(SchemaBuilder.columnSchema("a", MinorType.VARCHAR, DataMode.REPEATED), fixture.allocator());
    vector.allocateNew();
    // Create "foo", null, "bar", but omit the null.
    RepeatedVarCharVector.Mutator mutator = vector.getMutator();
    mutator.startNewValue(0);
    byte[] value = makeValue("a");
    mutator.addSafe(0, value, 0, value.length);
    value = makeValue("b");
    mutator.addSafe(0, value, 0, value.length);
    // Work around: test fails without this. But, only the new column writers
    // call this method.
    mutator.fillEmpties(0, 2);
    mutator.startNewValue(2);
    value = makeValue("c");
    mutator.addSafe(2, value, 0, value.length);
    value = makeValue("d");
    mutator.addSafe(2, value, 0, value.length);
    visualize(vector, 3);
    verifyOffsets(vector.getOffsetVector(), new int[] { 0, 2, 2, 4 });
    verifyOffsets(vector.getDataVector().getOffsetVector(), new int[] { 0, 1, 2, 3, 4 });
    vector.close();
}
Also used : RepeatedVarCharVector(org.apache.drill.exec.vector.RepeatedVarCharVector) SubOperatorTest(org.apache.drill.test.SubOperatorTest) Test(org.junit.Test) VectorTest(org.apache.drill.categories.VectorTest)

Example 10 with RepeatedVarCharVector

use of org.apache.drill.exec.vector.RepeatedVarCharVector in project drill by apache.

the class TestRepeatedListAccessors method testSchema3DVector.

@Test
public void testSchema3DVector() {
    final TupleMetadata schema = new SchemaBuilder().add("id", MinorType.INT).addRepeatedList("list2").addDimension().addArray(MinorType.VARCHAR).resumeList().resumeSchema().buildSchema();
    final DirectRowSet rowSet = DirectRowSet.fromSchema(fixture.allocator(), schema);
    final VectorContainer container = rowSet.container();
    assertEquals(2, container.getNumberOfColumns());
    assertTrue(container.getValueVector(1).getValueVector() instanceof RepeatedListVector);
    final RepeatedListVector list = (RepeatedListVector) container.getValueVector(1).getValueVector();
    assertEquals(1, list.getField().getChildren().size());
    assertTrue(list.getDataVector() instanceof RepeatedListVector);
    final RepeatedListVector child1 = (RepeatedListVector) list.getDataVector();
    assertEquals(1, child1.getField().getChildren().size());
    assertSame(list.getField().getChildren().iterator().next(), child1.getField());
    final ValueVector child2 = child1.getDataVector();
    assertTrue(child2 instanceof RepeatedVarCharVector);
    assertSame(child1.getField().getChildren().iterator().next(), child2.getField());
    rowSet.clear();
}
Also used : ValueVector(org.apache.drill.exec.vector.ValueVector) BaseRepeatedValueVector(org.apache.drill.exec.vector.complex.BaseRepeatedValueVector) RepeatedVarCharVector(org.apache.drill.exec.vector.RepeatedVarCharVector) RepeatedListVector(org.apache.drill.exec.vector.complex.RepeatedListVector) TupleMetadata(org.apache.drill.exec.record.metadata.TupleMetadata) SchemaBuilder(org.apache.drill.exec.record.metadata.SchemaBuilder) BatchSchemaBuilder(org.apache.drill.exec.record.BatchSchemaBuilder) VectorContainer(org.apache.drill.exec.record.VectorContainer) SubOperatorTest(org.apache.drill.test.SubOperatorTest) Test(org.junit.Test)

Aggregations

RepeatedVarCharVector (org.apache.drill.exec.vector.RepeatedVarCharVector)10 Test (org.junit.Test)9 ValueVector (org.apache.drill.exec.vector.ValueVector)8 SubOperatorTest (org.apache.drill.test.SubOperatorTest)7 SchemaBuilder (org.apache.drill.exec.record.metadata.SchemaBuilder)5 TupleMetadata (org.apache.drill.exec.record.metadata.TupleMetadata)5 UInt4Vector (org.apache.drill.exec.vector.UInt4Vector)5 VectorAccessible (org.apache.drill.exec.record.VectorAccessible)4 SingleRowSet (org.apache.drill.exec.physical.rowSet.RowSet.SingleRowSet)3 VectorContainer (org.apache.drill.exec.record.VectorContainer)3 VarCharVector (org.apache.drill.exec.vector.VarCharVector)3 BaseRepeatedValueVector (org.apache.drill.exec.vector.complex.BaseRepeatedValueVector)3 VectorTest (org.apache.drill.categories.VectorTest)2 BatchSchema (org.apache.drill.exec.record.BatchSchema)2 BatchSchemaBuilder (org.apache.drill.exec.record.BatchSchemaBuilder)2 BaseDataValueVector (org.apache.drill.exec.vector.BaseDataValueVector)2 RepeatedListVector (org.apache.drill.exec.vector.complex.RepeatedListVector)2 SingleRowSet (org.apache.drill.test.rowSet.RowSet.SingleRowSet)2 SchemaBuilder (org.apache.drill.test.rowSet.schema.SchemaBuilder)2 NullableVarCharVector (org.apache.drill.exec.vector.NullableVarCharVector)1