Search in sources :

Example 1 with ContainerAndSv2Accessor

use of org.apache.drill.exec.physical.impl.protocol.VectorContainerAccessor.ContainerAndSv2Accessor in project drill by axbaretto.

the class TestOperatorRecordBatch method testSv2.

/**
 * Test that an SV2 is properly handled by the proper container accessor.
 */
@Test
public void testSv2() {
    BatchSchema schema = new SchemaBuilder().add("a", MinorType.INT).add("b", MinorType.VARCHAR).build();
    SingleRowSet rs = fixture.rowSetBuilder(schema).addRow(10, "fred").addRow(20, "wilma").withSv2().build();
    ContainerAndSv2Accessor accessor = new ContainerAndSv2Accessor();
    accessor.setContainer(rs.container());
    accessor.setSelectionVector(rs.getSv2());
    MockOperatorExec opExec = new MockOperatorExec(accessor);
    opExec.nextCalls = 1;
    try (OperatorRecordBatch opBatch = makeOpBatch(opExec)) {
        assertEquals(IterOutcome.OK_NEW_SCHEMA, opBatch.next());
        assertSame(rs.getSv2(), opBatch.getSelectionVector2());
    } catch (Exception e) {
        fail();
    }
    assertTrue(opExec.closeCalled);
    // Must release SV2
    rs.clear();
}
Also used : SingleRowSet(org.apache.drill.test.rowSet.RowSet.SingleRowSet) ContainerAndSv2Accessor(org.apache.drill.exec.physical.impl.protocol.VectorContainerAccessor.ContainerAndSv2Accessor) BatchSchema(org.apache.drill.exec.record.BatchSchema) SchemaBuilder(org.apache.drill.test.rowSet.schema.SchemaBuilder) UserException(org.apache.drill.common.exceptions.UserException) SubOperatorTest(org.apache.drill.test.SubOperatorTest) Test(org.junit.Test)

Aggregations

UserException (org.apache.drill.common.exceptions.UserException)1 ContainerAndSv2Accessor (org.apache.drill.exec.physical.impl.protocol.VectorContainerAccessor.ContainerAndSv2Accessor)1 BatchSchema (org.apache.drill.exec.record.BatchSchema)1 SubOperatorTest (org.apache.drill.test.SubOperatorTest)1 SingleRowSet (org.apache.drill.test.rowSet.RowSet.SingleRowSet)1 SchemaBuilder (org.apache.drill.test.rowSet.schema.SchemaBuilder)1 Test (org.junit.Test)1