use of org.apache.drill.exec.physical.resultSet.impl.RepeatedListState.RepeatedListVectorState in project drill by apache.
the class ColumnBuilder method buildRepeatedList.
private ColumnState buildRepeatedList(ContainerState parent, ColumnMetadata columnSchema) {
assert columnSchema.type() == MinorType.LIST;
assert columnSchema.mode() == DataMode.REPEATED;
// the element type after creating the repeated writer itself.
assert columnSchema.childSchema() == null;
// Build the repeated vector.
final RepeatedListVector vector = new RepeatedListVector(columnSchema.emptySchema(), parent.loader().allocator(), null);
// No inner type yet. The result set loader builds the subtype
// incrementally because it might be complex (a map or another
// repeated list.) To start, use a dummy to avoid need for if-statements
// everywhere.
final ColumnMetadata dummyElementSchema = new PrimitiveColumnMetadata(MaterializedField.create(columnSchema.name(), Types.repeated(MinorType.NULL)));
final AbstractObjectWriter dummyElement = ColumnWriterFactory.buildDummyColumnWriter(dummyElementSchema);
// Create the list writer: an array of arrays.
final AbstractObjectWriter arrayWriter = RepeatedListWriter.buildRepeatedList(columnSchema, vector, dummyElement);
// Create the list vector state that tracks the list vector lifecycle.
final RepeatedListVectorState vectorState = new RepeatedListVectorState(arrayWriter, vector);
// Build the container that tracks the array contents
final RepeatedListState listState = new RepeatedListState(parent.loader(), parent.vectorCache().childCache(columnSchema.name()));
// Bind the list state as the list event listener.
((RepeatedListWriter) arrayWriter.array()).bindListener(listState);
// propagate events down to the (one and only) child state.
return new RepeatedListColumnState(parent.loader(), arrayWriter, vectorState, listState);
}
Aggregations