use of org.apache.drill.exec.record.metadata.RepeatedListColumnMetadata in project drill by apache.
the class RepeatedListState method addColumn.
@Override
protected void addColumn(ColumnState colState) {
// Remember the one and only child column.
assert childState == null;
childState = colState;
// Add the new child schema to the existing repeated list
// schema.
((RepeatedListColumnMetadata) parentColumn.schema()).childSchema(colState.schema());
// Add the child vector to the existing repeated list
// vector.
final RepeatedListVectorState vectorState = (RepeatedListVectorState) parentColumn.vectorState();
final RepeatedListVector listVector = vectorState.vector;
listVector.setChildVector(childState.vector());
// The repeated list's offset vector state needs to know the offset
// of the inner vector. Bind that information now that we have
// an inner writer.
vectorState.updateChildWriter(childState.writer());
}
use of org.apache.drill.exec.record.metadata.RepeatedListColumnMetadata in project drill by apache.
the class TestResultSetLoaderRepeatedList method do2DTest.
private void do2DTest(TupleMetadata schema, ResultSetLoader rsLoader) {
final RowSetLoader writer = rsLoader.writer();
// Sanity check of writer structure
assertEquals(2, writer.size());
final ObjectWriter listObj = writer.column("list2");
assertEquals(ObjectType.ARRAY, listObj.type());
final ArrayWriter listWriter = listObj.array();
assertEquals(ObjectType.ARRAY, listWriter.entryType());
final ArrayWriter innerWriter = listWriter.array();
assertEquals(ObjectType.SCALAR, innerWriter.entryType());
final ScalarWriter strWriter = innerWriter.scalar();
assertEquals(ValueType.STRING, strWriter.valueType());
// Sanity test of schema
final TupleMetadata rowSchema = writer.tupleSchema();
assertEquals(2, rowSchema.size());
final ColumnMetadata listSchema = rowSchema.metadata(1);
assertEquals(MinorType.LIST, listSchema.type());
assertEquals(DataMode.REPEATED, listSchema.mode());
assertTrue(listSchema instanceof RepeatedListColumnMetadata);
assertEquals(StructureType.MULTI_ARRAY, listSchema.structureType());
assertNotNull(listSchema.childSchema());
final ColumnMetadata elementSchema = listSchema.childSchema();
assertEquals(listSchema.name(), elementSchema.name());
assertEquals(MinorType.VARCHAR, elementSchema.type());
assertEquals(DataMode.REPEATED, elementSchema.mode());
// Write values
rsLoader.startBatch();
writer.addRow(1, objArray(strArray("a", "b"), strArray("c", "d"))).addRow(2, objArray(strArray("e"), strArray(), strArray("f", "g", "h"))).addRow(3, objArray()).addRow(4, objArray(strArray(), strArray("i"), strArray()));
// Verify the values.
// (Relies on the row set level repeated list tests having passed.)
final RowSet expected = fixture.rowSetBuilder(schema).addRow(1, objArray(strArray("a", "b"), strArray("c", "d"))).addRow(2, objArray(strArray("e"), strArray(), strArray("f", "g", "h"))).addRow(3, objArray()).addRow(4, objArray(strArray(), strArray("i"), strArray())).build();
RowSetUtilities.verify(expected, fixture.wrap(rsLoader.harvest()));
}
Aggregations