use of org.apache.drill.exec.vector.accessor.writer.AbstractObjectWriter in project drill by axbaretto.
the class BaseWriterBuilder method buildContainerChildren.
protected List<AbstractObjectWriter> buildContainerChildren(VectorContainer container, MetadataProvider mdProvider) {
List<AbstractObjectWriter> writers = new ArrayList<>();
for (int i = 0; i < container.getNumberOfColumns(); i++) {
@SuppressWarnings("resource") ValueVector vector = container.getValueVector(i).getValueVector();
VectorDescrip descrip = new VectorDescrip(mdProvider, i, vector.getField());
writers.add(buildVectorWriter(vector, descrip));
}
return writers;
}
use of org.apache.drill.exec.vector.accessor.writer.AbstractObjectWriter in project drill by axbaretto.
the class DummyWriterTest method testDummyMap.
/**
* Test a dummy map or map array. A (non-enforced) rule is that such maps
* contain only dummy writers. The writers act like "real" writers.
*/
@Test
public void testDummyMap() {
TupleMetadata schema = new SchemaBuilder().addMap("m1").add("a", MinorType.INT).addArray("b", MinorType.VARCHAR).resumeSchema().addMapArray("m2").add("c", MinorType.INT).resumeSchema().buildSchema();
List<AbstractObjectWriter> writers = new ArrayList<>();
{
schema.metadata("m1").setProjected(false);
TupleMetadata mapSchema = schema.metadata("m1").mapSchema();
List<AbstractObjectWriter> members = new ArrayList<>();
members.add(ColumnWriterFactory.buildColumnWriter(mapSchema.metadata("a"), null));
members.add(ColumnWriterFactory.buildColumnWriter(mapSchema.metadata("b"), null));
writers.add(ColumnWriterFactory.buildMapWriter(schema.metadata("m1"), null, members));
}
{
schema.metadata("m2").setProjected(false);
TupleMetadata mapSchema = schema.metadata("m2").mapSchema();
List<AbstractObjectWriter> members = new ArrayList<>();
members.add(ColumnWriterFactory.buildColumnWriter(mapSchema.metadata("c"), null));
writers.add(ColumnWriterFactory.buildMapWriter(schema.metadata("m2"), null, members));
}
AbstractTupleWriter rootWriter = new RootWriterFixture(schema, writers);
// Events are ignored.
rootWriter.startWrite();
rootWriter.startRow();
// Dummy columns seem real.
rootWriter.tuple("m1").scalar("a").setInt(20);
rootWriter.tuple(0).array("b").scalar().setString("foo");
// Dummy array map seems real.
rootWriter.array("m2").tuple().scalar("c").setInt(30);
rootWriter.array("m2").save();
rootWriter.array(1).tuple().scalar(0).setInt(40);
rootWriter.array(1).save();
// More ignored events.
rootWriter.restartRow();
rootWriter.saveRow();
rootWriter.endWrite();
}
use of org.apache.drill.exec.vector.accessor.writer.AbstractObjectWriter in project drill by apache.
the class BaseWriterBuilder method buildContainerChildren.
protected List<AbstractObjectWriter> buildContainerChildren(VectorContainer container, MetadataProvider mdProvider) {
final List<AbstractObjectWriter> writers = new ArrayList<>();
for (int i = 0; i < container.getNumberOfColumns(); i++) {
final ValueVector vector = container.getValueVector(i).getValueVector();
final VectorDescrip descrip = new VectorDescrip(mdProvider, i, vector.getField());
writers.add(buildVectorWriter(vector, descrip));
}
return writers;
}
use of org.apache.drill.exec.vector.accessor.writer.AbstractObjectWriter in project drill by apache.
the class BaseWriterBuilder method buildMap.
private List<AbstractObjectWriter> buildMap(AbstractMapVector vector, VectorDescrip descrip) {
final List<AbstractObjectWriter> writers = new ArrayList<>();
final MetadataProvider provider = descrip.parent.childProvider(descrip.metadata);
int i = 0;
for (final ValueVector child : vector) {
final VectorDescrip childDescrip = new VectorDescrip(provider, i, child.getField());
writers.add(buildVectorWriter(child, childDescrip));
i++;
}
return writers;
}
use of org.apache.drill.exec.vector.accessor.writer.AbstractObjectWriter in project drill by apache.
the class BaseWriterBuilder method buildDict.
private AbstractObjectWriter buildDict(ValueVector vector, VectorDescrip descrip) {
if (vector.getField().getType().getMode() == DataMode.REPEATED) {
ValueVector dataVector = ((RepeatedDictVector) vector).getDataVector();
List<AbstractObjectWriter> writers = buildMap((AbstractMapVector) dataVector, descrip);
return ObjectDictWriter.buildDictArray(descrip.metadata, (RepeatedDictVector) vector, writers);
} else {
List<AbstractObjectWriter> writers = buildMap((AbstractMapVector) vector, descrip);
return ObjectDictWriter.buildDict(descrip.metadata, (DictVector) vector, writers);
}
}
Aggregations