use of org.apache.drill.exec.physical.impl.scan.v3.lifecycle.OutputBatchBuilder.BatchSource in project drill by apache.
the class TestOutputBatchBuilder method testNestedMaps.
@Test
public void testNestedMaps() {
final TupleMetadata schema1 = new SchemaBuilder().add("a", MinorType.VARCHAR).addMap("m1").add("p", MinorType.VARCHAR).addMap("m2").add("x", MinorType.VARCHAR).resumeMap().resumeSchema().buildSchema();
final VectorContainer input1 = fixture.rowSetBuilder(schema1).addRow("barney", mapValue("betty", mapValue("pebbles"))).addRow("fred", mapValue("wilma", mapValue("bambam"))).build().container();
final TupleMetadata schema2 = new SchemaBuilder().addMap("m1").add("q", MinorType.INT).addMap("m2").add("y", MinorType.INT).resumeMap().resumeSchema().buildSchema();
final VectorContainer input2 = fixture.rowSetBuilder(schema2).addSingleCol(mapValue(1, mapValue(10))).addSingleCol(mapValue(2, mapValue(20))).build().container();
final TupleMetadata outputSchema = new SchemaBuilder().add("a", MinorType.VARCHAR).addMap("m1").add("p", MinorType.VARCHAR).add("q", MinorType.INT).addMap("m2").add("x", MinorType.VARCHAR).add("y", MinorType.INT).resumeMap().resumeSchema().buildSchema();
final RowSet expected = fixture.rowSetBuilder(outputSchema).addRow("barney", mapValue("betty", 1, mapValue("pebbles", 10))).addRow("fred", mapValue("wilma", 2, mapValue("bambam", 20))).build();
OutputBatchBuilder builder = new OutputBatchBuilder(outputSchema, Arrays.asList(new BatchSource(schema1, input1), new BatchSource(schema2, input2)), fixture.allocator());
builder.load(input1.getRecordCount());
VectorContainer output = builder.outputContainer();
RowSetUtilities.verify(expected, fixture.wrap(output));
}
use of org.apache.drill.exec.physical.impl.scan.v3.lifecycle.OutputBatchBuilder.BatchSource in project drill by apache.
the class ReaderLifecycle method createOutputBuilder.
private void createOutputBuilder() {
List<BatchSource> sources = new ArrayList<>();
sources.add(new BatchSource(tableLoader.outputSchema(), tableLoader.outputContainer()));
if (implicitColumnsLoader != null) {
sources.add(new BatchSource(implicitColumnsLoader.schema(), implicitColumnsLoader.outputContainer()));
}
if (missingColumnsHandler != null) {
sources.add(new BatchSource(missingColumnsHandler.schema(), missingColumnsHandler.outputContainer()));
}
outputBuilder = new OutputBatchBuilder(schemaTracker().outputSchema(), sources, scanLifecycle.allocator());
}
Aggregations