Search in sources :

Example 1 with RepeatedListColumnState

use of org.apache.drill.exec.physical.resultSet.impl.RepeatedListState.RepeatedListColumnState 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);
}
Also used : ColumnMetadata(org.apache.drill.exec.record.metadata.ColumnMetadata) PrimitiveColumnMetadata(org.apache.drill.exec.record.metadata.PrimitiveColumnMetadata) PrimitiveColumnMetadata(org.apache.drill.exec.record.metadata.PrimitiveColumnMetadata) RepeatedListVector(org.apache.drill.exec.vector.complex.RepeatedListVector) RepeatedListWriter(org.apache.drill.exec.vector.accessor.writer.RepeatedListWriter) RepeatedListColumnState(org.apache.drill.exec.physical.resultSet.impl.RepeatedListState.RepeatedListColumnState) RepeatedListVectorState(org.apache.drill.exec.physical.resultSet.impl.RepeatedListState.RepeatedListVectorState) AbstractObjectWriter(org.apache.drill.exec.vector.accessor.writer.AbstractObjectWriter)

Aggregations

RepeatedListColumnState (org.apache.drill.exec.physical.resultSet.impl.RepeatedListState.RepeatedListColumnState)1 RepeatedListVectorState (org.apache.drill.exec.physical.resultSet.impl.RepeatedListState.RepeatedListVectorState)1 ColumnMetadata (org.apache.drill.exec.record.metadata.ColumnMetadata)1 PrimitiveColumnMetadata (org.apache.drill.exec.record.metadata.PrimitiveColumnMetadata)1 AbstractObjectWriter (org.apache.drill.exec.vector.accessor.writer.AbstractObjectWriter)1 RepeatedListWriter (org.apache.drill.exec.vector.accessor.writer.RepeatedListWriter)1 RepeatedListVector (org.apache.drill.exec.vector.complex.RepeatedListVector)1