Search in sources :

Example 1 with BatchSource

use of org.apache.drill.exec.physical.impl.scan.v3.lifecycle.OutputBatchBuilder.BatchSource in project drill by apache.

the class TestOutputBatchBuilder method testReorder.

@Test
public void testReorder() {
    TupleMetadata schema = firstSchema();
    VectorContainer input = makeFirst(schema);
    TupleMetadata outputSchema = new SchemaBuilder().add("a", MinorType.INT).add("d", MinorType.VARCHAR).buildSchema();
    OutputBatchBuilder builder = new OutputBatchBuilder(outputSchema, Collections.singletonList(new BatchSource(schema, input)), fixture.allocator());
    builder.load(input.getRecordCount());
    VectorContainer output = builder.outputContainer();
    RowSet expected = fixture.rowSetBuilder(outputSchema).addRow(10, "barney").addRow(20, "wilma").build();
    RowSetUtilities.verify(expected, fixture.wrap(output));
}
Also used : TupleMetadata(org.apache.drill.exec.record.metadata.TupleMetadata) SchemaBuilder(org.apache.drill.exec.record.metadata.SchemaBuilder) BatchSource(org.apache.drill.exec.physical.impl.scan.v3.lifecycle.OutputBatchBuilder.BatchSource) SingleRowSet(org.apache.drill.exec.physical.rowSet.RowSet.SingleRowSet) RowSet(org.apache.drill.exec.physical.rowSet.RowSet) VectorContainer(org.apache.drill.exec.record.VectorContainer) SubOperatorTest(org.apache.drill.test.SubOperatorTest) Test(org.junit.Test) EvfTest(org.apache.drill.categories.EvfTest)

Example 2 with BatchSource

use of org.apache.drill.exec.physical.impl.scan.v3.lifecycle.OutputBatchBuilder.BatchSource in project drill by apache.

the class TestOutputBatchBuilder method testMap.

@Test
public void testMap() {
    final TupleMetadata schema = new SchemaBuilder().add("a", MinorType.VARCHAR).addMap("m").add("x", MinorType.INT).add("y", MinorType.VARCHAR).resumeSchema().buildSchema();
    final VectorContainer input = fixture.rowSetBuilder(schema).addRow("barney", mapValue(1, "betty")).addRow("fred", mapValue(2, "wilma")).build().container();
    final OutputBatchBuilder builder = new OutputBatchBuilder(schema, Collections.singletonList(new BatchSource(schema, input)), fixture.allocator());
    builder.load(input.getRecordCount());
    VectorContainer output = builder.outputContainer();
    RowSetUtilities.verify(fixture.wrap(input), fixture.wrap(output));
}
Also used : TupleMetadata(org.apache.drill.exec.record.metadata.TupleMetadata) SchemaBuilder(org.apache.drill.exec.record.metadata.SchemaBuilder) BatchSource(org.apache.drill.exec.physical.impl.scan.v3.lifecycle.OutputBatchBuilder.BatchSource) VectorContainer(org.apache.drill.exec.record.VectorContainer) SubOperatorTest(org.apache.drill.test.SubOperatorTest) Test(org.junit.Test) EvfTest(org.apache.drill.categories.EvfTest)

Example 3 with BatchSource

use of org.apache.drill.exec.physical.impl.scan.v3.lifecycle.OutputBatchBuilder.BatchSource in project drill by apache.

the class TestOutputBatchBuilder method testTwoMaps.

@Test
public void testTwoMaps() {
    final TupleMetadata schema1 = new SchemaBuilder().add("a", MinorType.VARCHAR).addMap("m").add("y", MinorType.VARCHAR).resumeSchema().buildSchema();
    final VectorContainer input1 = fixture.rowSetBuilder(schema1).addRow("barney", mapValue("betty")).addRow("fred", mapValue("wilma")).build().container();
    final TupleMetadata schema2 = new SchemaBuilder().addMap("m").add("x", MinorType.INT).resumeSchema().buildSchema();
    final VectorContainer input2 = fixture.rowSetBuilder(schema2).addSingleCol(mapValue(1)).addSingleCol(mapValue(2)).build().container();
    final TupleMetadata outputSchema = new SchemaBuilder().add("a", MinorType.VARCHAR).addMap("m").add("x", MinorType.INT).add("y", MinorType.VARCHAR).resumeSchema().buildSchema();
    final RowSet expected = fixture.rowSetBuilder(outputSchema).addRow("barney", mapValue(1, "betty")).addRow("fred", mapValue(2, "wilma")).build();
    OutputBatchBuilder builder = new OutputBatchBuilder(outputSchema, Lists.newArrayList(new BatchSource(schema1, input1), new BatchSource(schema2, input2)), fixture.allocator());
    builder.load(input1.getRecordCount());
    VectorContainer output = builder.outputContainer();
    RowSetUtilities.verify(expected, fixture.wrap(output));
}
Also used : TupleMetadata(org.apache.drill.exec.record.metadata.TupleMetadata) SchemaBuilder(org.apache.drill.exec.record.metadata.SchemaBuilder) SingleRowSet(org.apache.drill.exec.physical.rowSet.RowSet.SingleRowSet) RowSet(org.apache.drill.exec.physical.rowSet.RowSet) BatchSource(org.apache.drill.exec.physical.impl.scan.v3.lifecycle.OutputBatchBuilder.BatchSource) VectorContainer(org.apache.drill.exec.record.VectorContainer) SubOperatorTest(org.apache.drill.test.SubOperatorTest) Test(org.junit.Test) EvfTest(org.apache.drill.categories.EvfTest)

Example 4 with BatchSource

use of org.apache.drill.exec.physical.impl.scan.v3.lifecycle.OutputBatchBuilder.BatchSource in project drill by apache.

the class TestOutputBatchBuilder method testSingleInput.

@Test
public void testSingleInput() {
    TupleMetadata schema = firstSchema();
    VectorContainer input = makeFirst(schema);
    OutputBatchBuilder builder = new OutputBatchBuilder(schema, Collections.singletonList(new BatchSource(schema, input)), fixture.allocator());
    builder.load(input.getRecordCount());
    VectorContainer output = builder.outputContainer();
    RowSetUtilities.verify(fixture.wrap(input), fixture.wrap(output));
}
Also used : TupleMetadata(org.apache.drill.exec.record.metadata.TupleMetadata) BatchSource(org.apache.drill.exec.physical.impl.scan.v3.lifecycle.OutputBatchBuilder.BatchSource) VectorContainer(org.apache.drill.exec.record.VectorContainer) SubOperatorTest(org.apache.drill.test.SubOperatorTest) Test(org.junit.Test) EvfTest(org.apache.drill.categories.EvfTest)

Example 5 with BatchSource

use of org.apache.drill.exec.physical.impl.scan.v3.lifecycle.OutputBatchBuilder.BatchSource in project drill by apache.

the class TestOutputBatchBuilder method testTwoInputs.

@Test
public void testTwoInputs() {
    TupleMetadata schema1 = firstSchema();
    VectorContainer input1 = makeFirst(schema1);
    TupleMetadata schema2 = secondSchema();
    VectorContainer input2 = makeSecond(schema2);
    TupleMetadata outputSchema = new SchemaBuilder().add("a", MinorType.INT).add("b", MinorType.INT).add("c", MinorType.VARCHAR).add("d", MinorType.VARCHAR).buildSchema();
    OutputBatchBuilder builder = new OutputBatchBuilder(outputSchema, Lists.newArrayList(new BatchSource(schema1, input1), new BatchSource(schema2, input2)), fixture.allocator());
    builder.load(input1.getRecordCount());
    VectorContainer output = builder.outputContainer();
    SingleRowSet expected = fixture.rowSetBuilder(outputSchema).addRow(10, 1, "foo.csv", "barney").addRow(20, 2, "foo.csv", "wilma").build();
    RowSetUtilities.verify(expected, fixture.wrap(output));
}
Also used : SingleRowSet(org.apache.drill.exec.physical.rowSet.RowSet.SingleRowSet) TupleMetadata(org.apache.drill.exec.record.metadata.TupleMetadata) SchemaBuilder(org.apache.drill.exec.record.metadata.SchemaBuilder) BatchSource(org.apache.drill.exec.physical.impl.scan.v3.lifecycle.OutputBatchBuilder.BatchSource) VectorContainer(org.apache.drill.exec.record.VectorContainer) SubOperatorTest(org.apache.drill.test.SubOperatorTest) Test(org.junit.Test) EvfTest(org.apache.drill.categories.EvfTest)

Aggregations

BatchSource (org.apache.drill.exec.physical.impl.scan.v3.lifecycle.OutputBatchBuilder.BatchSource)7 EvfTest (org.apache.drill.categories.EvfTest)6 VectorContainer (org.apache.drill.exec.record.VectorContainer)6 TupleMetadata (org.apache.drill.exec.record.metadata.TupleMetadata)6 SubOperatorTest (org.apache.drill.test.SubOperatorTest)6 Test (org.junit.Test)6 SchemaBuilder (org.apache.drill.exec.record.metadata.SchemaBuilder)5 SingleRowSet (org.apache.drill.exec.physical.rowSet.RowSet.SingleRowSet)4 RowSet (org.apache.drill.exec.physical.rowSet.RowSet)3 ArrayList (java.util.ArrayList)1