Search in sources :

Example 1 with BaseMapColumnState

use of org.apache.drill.exec.physical.rowSet.impl.ColumnState.BaseMapColumnState in project drill by axbaretto.

the class TupleState method buildSchema.

/**
 * When creating a schema up front, provide the schema of the desired tuple,
 * then build vectors and writers to match. Allows up-front schema definition
 * in addition to on-the-fly schema creation handled elsewhere.
 *
 * @param schema desired tuple schema to be materialized
 */
public void buildSchema(TupleMetadata schema) {
    for (int i = 0; i < schema.size(); i++) {
        ColumnMetadata colSchema = schema.metadata(i);
        AbstractObjectWriter colWriter;
        if (colSchema.isMap()) {
            colWriter = addColumn(colSchema.cloneEmpty());
            BaseMapColumnState mapColState = (BaseMapColumnState) columns.get(columns.size() - 1);
            mapColState.mapState().buildSchema(colSchema.mapSchema());
        } else {
            colWriter = addColumn(colSchema);
        }
        writer().addColumnWriter(colWriter);
    }
}
Also used : AbstractColumnMetadata(org.apache.drill.exec.record.metadata.AbstractColumnMetadata) ColumnMetadata(org.apache.drill.exec.record.metadata.ColumnMetadata) BaseMapColumnState(org.apache.drill.exec.physical.rowSet.impl.ColumnState.BaseMapColumnState) AbstractObjectWriter(org.apache.drill.exec.vector.accessor.writer.AbstractObjectWriter)

Example 2 with BaseMapColumnState

use of org.apache.drill.exec.physical.rowSet.impl.ColumnState.BaseMapColumnState in project drill by axbaretto.

the class VectorContainerBuilder method updateTuple.

private void updateTuple(TupleState sourceModel, TupleProxy destProxy) {
    int prevCount = destProxy.size();
    List<ColumnState> cols = sourceModel.columns();
    int currentCount = cols.size();
    for (int i = 0; i < prevCount; i++) {
        ColumnState colState = cols.get(i);
        if (!colState.schema().isProjected()) {
            continue;
        }
        if (colState.schema().isMap()) {
            updateTuple((TupleState) ((BaseMapColumnState) colState).mapState(), destProxy.mapProxy(i));
        }
    }
    for (int i = prevCount; i < currentCount; i++) {
        ColumnState colState = cols.get(i);
        if (!colState.schema().isProjected()) {
            continue;
        }
        if (colState.addVersion > outputSchemaVersion) {
            break;
        }
        if (colState.schema().isMap()) {
            buildMap(destProxy, (BaseMapColumnState) colState);
        } else {
            destProxy.add(colState.vector());
            destProxy.schema.addColumn(colState.schema());
            assert destProxy.size() == destProxy.schema.size();
        }
    }
}
Also used : BaseMapColumnState(org.apache.drill.exec.physical.rowSet.impl.ColumnState.BaseMapColumnState) BaseMapColumnState(org.apache.drill.exec.physical.rowSet.impl.ColumnState.BaseMapColumnState)

Aggregations

BaseMapColumnState (org.apache.drill.exec.physical.rowSet.impl.ColumnState.BaseMapColumnState)2 AbstractColumnMetadata (org.apache.drill.exec.record.metadata.AbstractColumnMetadata)1 ColumnMetadata (org.apache.drill.exec.record.metadata.ColumnMetadata)1 AbstractObjectWriter (org.apache.drill.exec.vector.accessor.writer.AbstractObjectWriter)1