Search in sources :

Example 1 with OffsetVectorState

use of org.apache.drill.exec.physical.resultSet.impl.SingleVectorState.OffsetVectorState in project drill by apache.

the class ColumnBuilder method buildSingleDict.

private ColumnState buildSingleDict(ContainerState parent, ColumnMetadata columnSchema) {
    final ProjectionFilter projFilter = parent.projection();
    final ProjResult projResult = projFilter.projection(columnSchema);
    // Create the dict's offset vector.
    final DictVector dictVector;
    final UInt4Vector offsetVector;
    if (projResult.isProjected) {
        // Creating the dict vector will create its contained vectors if we
        // give it a materialized field with children. So, instead pass a clone
        // without children so we can add them.
        final ColumnMetadata dictColMetadata = columnSchema.cloneEmpty();
        // vectors can be cached.
        assert columnSchema.tupleSchema().isEmpty();
        dictVector = new DictVector(dictColMetadata.schema(), parent.loader().allocator(), null);
        offsetVector = dictVector.getOffsetVector();
    } else {
        dictVector = null;
        offsetVector = null;
    }
    // Create the writer using the offset vector
    final AbstractObjectWriter writer = ObjectDictWriter.buildDict(columnSchema, dictVector, new ArrayList<>());
    // Wrap the offset vector in a vector state
    final VectorState offsetVectorState;
    if (!projResult.isProjected) {
        offsetVectorState = new NullVectorState();
    } else {
        offsetVectorState = new OffsetVectorState((((AbstractArrayWriter) writer.dict()).offsetWriter()), offsetVector, writer.dict().entry().events());
    }
    final VectorState mapVectorState = new TupleState.SingleDictVectorState(dictVector, offsetVectorState);
    // Assemble it all into the column state.
    final SingleDictState dictArrayState = new SingleDictState(parent.loader(), parent.vectorCache().childCache(columnSchema.name()), projResult.mapFilter);
    return new TupleState.DictColumnState(dictArrayState, writer, mapVectorState, parent.isVersioned());
}
Also used : DictVector(org.apache.drill.exec.vector.complex.DictVector) RepeatedDictVector(org.apache.drill.exec.vector.complex.RepeatedDictVector) ColumnMetadata(org.apache.drill.exec.record.metadata.ColumnMetadata) PrimitiveColumnMetadata(org.apache.drill.exec.record.metadata.PrimitiveColumnMetadata) OffsetVectorState(org.apache.drill.exec.physical.resultSet.impl.SingleVectorState.OffsetVectorState) ProjResult(org.apache.drill.exec.physical.resultSet.impl.ProjectionFilter.ProjResult) UInt4Vector(org.apache.drill.exec.vector.UInt4Vector) SingleDictState(org.apache.drill.exec.physical.resultSet.impl.TupleState.SingleDictState) AbstractObjectWriter(org.apache.drill.exec.vector.accessor.writer.AbstractObjectWriter) MapVectorState(org.apache.drill.exec.physical.resultSet.impl.TupleState.MapVectorState) RepeatedListVectorState(org.apache.drill.exec.physical.resultSet.impl.RepeatedListState.RepeatedListVectorState) UnionVectorState(org.apache.drill.exec.physical.resultSet.impl.UnionState.UnionVectorState) OffsetVectorState(org.apache.drill.exec.physical.resultSet.impl.SingleVectorState.OffsetVectorState) ListVectorState(org.apache.drill.exec.physical.resultSet.impl.ListState.ListVectorState) SimpleVectorState(org.apache.drill.exec.physical.resultSet.impl.SingleVectorState.SimpleVectorState)

Example 2 with OffsetVectorState

use of org.apache.drill.exec.physical.resultSet.impl.SingleVectorState.OffsetVectorState in project drill by apache.

the class ColumnBuilder method buildMapArray.

private ColumnState buildMapArray(ContainerState parent, ColumnMetadata columnSchema) {
    final ProjectionFilter projFilter = parent.projection();
    final ProjResult projResult = projFilter.projection(columnSchema);
    // Create the map's offset vector.
    final RepeatedMapVector mapVector;
    final UInt4Vector offsetVector;
    if (projResult.isProjected) {
        // Creating the map vector will create its contained vectors if we
        // give it a materialized field with children. So, instead pass a clone
        // without children so we can add them.
        final ColumnMetadata mapColSchema = columnSchema.cloneEmpty();
        // vectors can be cached.
        assert columnSchema.tupleSchema().isEmpty();
        mapVector = new RepeatedMapVector(mapColSchema.schema(), parent.loader().allocator(), null);
        offsetVector = mapVector.getOffsetVector();
    } else {
        mapVector = null;
        offsetVector = null;
    }
    // Create the writer using the offset vector
    final AbstractObjectWriter writer = MapWriter.buildMapArray(columnSchema, mapVector, new ArrayList<>());
    // Wrap the offset vector in a vector state
    VectorState offsetVectorState;
    if (!projResult.isProjected) {
        offsetVectorState = new NullVectorState();
    } else {
        offsetVectorState = new OffsetVectorState((((AbstractArrayWriter) writer.array()).offsetWriter()), offsetVector, writer.array().entry().events());
    }
    final VectorState mapVectorState = new MapVectorState(mapVector, offsetVectorState);
    // Assemble it all into the column state.
    final MapArrayState mapState = new MapArrayState(parent.loader(), parent.vectorCache().childCache(columnSchema.name()), projResult.mapFilter);
    return new MapColumnState(mapState, writer, mapVectorState, parent.isVersioned());
}
Also used : ColumnMetadata(org.apache.drill.exec.record.metadata.ColumnMetadata) PrimitiveColumnMetadata(org.apache.drill.exec.record.metadata.PrimitiveColumnMetadata) OffsetVectorState(org.apache.drill.exec.physical.resultSet.impl.SingleVectorState.OffsetVectorState) RepeatedMapVector(org.apache.drill.exec.vector.complex.RepeatedMapVector) ProjResult(org.apache.drill.exec.physical.resultSet.impl.ProjectionFilter.ProjResult) MapColumnState(org.apache.drill.exec.physical.resultSet.impl.TupleState.MapColumnState) UInt4Vector(org.apache.drill.exec.vector.UInt4Vector) MapVectorState(org.apache.drill.exec.physical.resultSet.impl.TupleState.MapVectorState) AbstractObjectWriter(org.apache.drill.exec.vector.accessor.writer.AbstractObjectWriter) MapVectorState(org.apache.drill.exec.physical.resultSet.impl.TupleState.MapVectorState) RepeatedListVectorState(org.apache.drill.exec.physical.resultSet.impl.RepeatedListState.RepeatedListVectorState) UnionVectorState(org.apache.drill.exec.physical.resultSet.impl.UnionState.UnionVectorState) OffsetVectorState(org.apache.drill.exec.physical.resultSet.impl.SingleVectorState.OffsetVectorState) ListVectorState(org.apache.drill.exec.physical.resultSet.impl.ListState.ListVectorState) SimpleVectorState(org.apache.drill.exec.physical.resultSet.impl.SingleVectorState.SimpleVectorState) MapArrayState(org.apache.drill.exec.physical.resultSet.impl.TupleState.MapArrayState)

Example 3 with OffsetVectorState

use of org.apache.drill.exec.physical.resultSet.impl.SingleVectorState.OffsetVectorState in project drill by apache.

the class ColumnBuilder method buildDictArray.

private ColumnState buildDictArray(ContainerState parent, ColumnMetadata columnSchema) {
    final ProjectionFilter projFilter = parent.projection();
    final ProjResult projResult = projFilter.projection(columnSchema);
    // Create the dict's offset vector.
    final RepeatedDictVector repeatedDictVector;
    final UInt4Vector offsetVector;
    if (projResult.isProjected) {
        // Creating the dict vector will create its contained vectors if we
        // give it a materialized field with children. So, instead pass a clone
        // without children so we can add them.
        final ColumnMetadata dictColMetadata = columnSchema.cloneEmpty();
        assert columnSchema.tupleSchema().isEmpty();
        repeatedDictVector = new RepeatedDictVector(dictColMetadata.schema(), parent.loader().allocator(), null);
        offsetVector = repeatedDictVector.getOffsetVector();
    } else {
        repeatedDictVector = null;
        offsetVector = null;
    }
    // Create the writer using the offset vector
    final AbstractObjectWriter writer = ObjectDictWriter.buildDictArray(columnSchema, repeatedDictVector, new ArrayList<>());
    // Wrap the offset vector in a vector state
    VectorState offsetVectorState;
    VectorState dictOffsetVectorState;
    if (!projResult.isProjected) {
        offsetVectorState = new NullVectorState();
        dictOffsetVectorState = new NullVectorState();
    } else {
        AbstractArrayWriter arrayWriter = (AbstractArrayWriter) writer.array();
        offsetVectorState = new OffsetVectorState(arrayWriter.offsetWriter(), offsetVector, writer.array().entry().events());
        dictOffsetVectorState = new OffsetVectorState(((AbstractArrayWriter) arrayWriter.array()).offsetWriter(), ((DictVector) repeatedDictVector.getDataVector()).getOffsetVector(), writer.array().entry().dict().entry().events());
    }
    final VectorState mapVectorState = new TupleState.DictArrayVectorState(repeatedDictVector, offsetVectorState, dictOffsetVectorState);
    // Assemble it all into the column state.
    final TupleState.DictArrayState dictArrayState = new TupleState.DictArrayState(parent.loader(), parent.vectorCache().childCache(columnSchema.name()), projResult.mapFilter);
    return new TupleState.DictColumnState(dictArrayState, writer, mapVectorState, parent.isVersioned());
}
Also used : DictVector(org.apache.drill.exec.vector.complex.DictVector) RepeatedDictVector(org.apache.drill.exec.vector.complex.RepeatedDictVector) ColumnMetadata(org.apache.drill.exec.record.metadata.ColumnMetadata) PrimitiveColumnMetadata(org.apache.drill.exec.record.metadata.PrimitiveColumnMetadata) OffsetVectorState(org.apache.drill.exec.physical.resultSet.impl.SingleVectorState.OffsetVectorState) ProjResult(org.apache.drill.exec.physical.resultSet.impl.ProjectionFilter.ProjResult) UInt4Vector(org.apache.drill.exec.vector.UInt4Vector) AbstractArrayWriter(org.apache.drill.exec.vector.accessor.writer.AbstractArrayWriter) RepeatedDictVector(org.apache.drill.exec.vector.complex.RepeatedDictVector) AbstractObjectWriter(org.apache.drill.exec.vector.accessor.writer.AbstractObjectWriter) MapVectorState(org.apache.drill.exec.physical.resultSet.impl.TupleState.MapVectorState) RepeatedListVectorState(org.apache.drill.exec.physical.resultSet.impl.RepeatedListState.RepeatedListVectorState) UnionVectorState(org.apache.drill.exec.physical.resultSet.impl.UnionState.UnionVectorState) OffsetVectorState(org.apache.drill.exec.physical.resultSet.impl.SingleVectorState.OffsetVectorState) ListVectorState(org.apache.drill.exec.physical.resultSet.impl.ListState.ListVectorState) SimpleVectorState(org.apache.drill.exec.physical.resultSet.impl.SingleVectorState.SimpleVectorState)

Aggregations

ListVectorState (org.apache.drill.exec.physical.resultSet.impl.ListState.ListVectorState)3 ProjResult (org.apache.drill.exec.physical.resultSet.impl.ProjectionFilter.ProjResult)3 RepeatedListVectorState (org.apache.drill.exec.physical.resultSet.impl.RepeatedListState.RepeatedListVectorState)3 OffsetVectorState (org.apache.drill.exec.physical.resultSet.impl.SingleVectorState.OffsetVectorState)3 SimpleVectorState (org.apache.drill.exec.physical.resultSet.impl.SingleVectorState.SimpleVectorState)3 MapVectorState (org.apache.drill.exec.physical.resultSet.impl.TupleState.MapVectorState)3 UnionVectorState (org.apache.drill.exec.physical.resultSet.impl.UnionState.UnionVectorState)3 ColumnMetadata (org.apache.drill.exec.record.metadata.ColumnMetadata)3 PrimitiveColumnMetadata (org.apache.drill.exec.record.metadata.PrimitiveColumnMetadata)3 UInt4Vector (org.apache.drill.exec.vector.UInt4Vector)3 AbstractObjectWriter (org.apache.drill.exec.vector.accessor.writer.AbstractObjectWriter)3 DictVector (org.apache.drill.exec.vector.complex.DictVector)2 RepeatedDictVector (org.apache.drill.exec.vector.complex.RepeatedDictVector)2 MapArrayState (org.apache.drill.exec.physical.resultSet.impl.TupleState.MapArrayState)1 MapColumnState (org.apache.drill.exec.physical.resultSet.impl.TupleState.MapColumnState)1 SingleDictState (org.apache.drill.exec.physical.resultSet.impl.TupleState.SingleDictState)1 AbstractArrayWriter (org.apache.drill.exec.vector.accessor.writer.AbstractArrayWriter)1 RepeatedMapVector (org.apache.drill.exec.vector.complex.RepeatedMapVector)1