use of org.apache.drill.exec.vector.accessor.TupleAccessor.TupleSchema in project drill by apache.
the class DirectRowSet method buildWriter.
/**
* Build writer objects for each column based on the column type.
*
* @param rowIndex the index which points to each row
* @return an array of writers
*/
protected RowSetWriter buildWriter(ExtendableRowIndex rowIndex) {
ValueVector[] valueVectors = vectors();
AbstractColumnWriter[] writers = new AbstractColumnWriter[valueVectors.length];
for (int i = 0; i < writers.length; i++) {
writers[i] = ColumnAccessorFactory.newWriter(valueVectors[i].getField().getType());
writers[i].bind(rowIndex, valueVectors[i]);
}
TupleSchema accessSchema = schema().hierarchicalAccess();
return new RowSetWriterImpl(this, accessSchema, rowIndex, writers);
}
use of org.apache.drill.exec.vector.accessor.TupleAccessor.TupleSchema in project drill by apache.
the class RowSetPrinter method printSchema.
private void printSchema(PrintStream out, SelectionVectorMode selectionMode) {
out.print("#");
switch(selectionMode) {
case FOUR_BYTE:
out.print(" (batch #, row #)");
break;
case TWO_BYTE:
out.print(" (row #)");
break;
default:
break;
}
out.print(": ");
TupleSchema schema = rowSet.schema().hierarchicalAccess();
for (int i = 0; i < schema.count(); i++) {
if (i > 0) {
out.print(", ");
}
out.print(schema.column(i).getLastName());
}
out.println();
}
use of org.apache.drill.exec.vector.accessor.TupleAccessor.TupleSchema in project drill by apache.
the class RowSetTest method testSchema.
/**
* Test a simple physical schema with no maps.
*/
@Test
public void testSchema() {
BatchSchema batchSchema = new SchemaBuilder().add("c", MinorType.INT).add("a", MinorType.INT, DataMode.REPEATED).addNullable("b", MinorType.VARCHAR).build();
assertEquals("c", batchSchema.getColumn(0).getName());
assertEquals("a", batchSchema.getColumn(1).getName());
assertEquals("b", batchSchema.getColumn(2).getName());
RowSetSchema schema = new RowSetSchema(batchSchema);
TupleSchema access = schema.hierarchicalAccess();
assertEquals(3, access.count());
crossCheck(access, 0, "c", MinorType.INT);
assertEquals(DataMode.REQUIRED, access.column(0).getDataMode());
assertEquals(DataMode.REQUIRED, access.column(0).getType().getMode());
assertTrue(!access.column(0).isNullable());
crossCheck(access, 1, "a", MinorType.INT);
assertEquals(DataMode.REPEATED, access.column(1).getDataMode());
assertEquals(DataMode.REPEATED, access.column(1).getType().getMode());
assertTrue(!access.column(1).isNullable());
crossCheck(access, 2, "b", MinorType.VARCHAR);
assertEquals(MinorType.VARCHAR, access.column(2).getType().getMinorType());
assertEquals(DataMode.OPTIONAL, access.column(2).getDataMode());
assertEquals(DataMode.OPTIONAL, access.column(2).getType().getMode());
assertTrue(access.column(2).isNullable());
// No maps: physical schema is the same as access schema.
PhysicalSchema physical = schema.physical();
assertEquals(3, physical.count());
assertEquals("c", physical.column(0).field().getName());
assertEquals("a", physical.column(1).field().getName());
assertEquals("b", physical.column(2).field().getName());
}
Aggregations