use of org.apache.drill.exec.physical.resultSet.impl.TupleState.SingleDictState 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());
}
Aggregations