Class TupleState
- All Implemented Interfaces:
AbstractTupleWriter.TupleWriterListener
- Direct Known Subclasses:
TupleState.MapState
,TupleState.RowState
Here, by "tuple" we mean a container of vectors, each of which holds a variety of values. So, the "tuple" here is structural, not a specific set of values, but rather the collection of vectors that hold tuple values. Drill vector containers and maps are both tuples, but they irritatingly have completely different APIs for working with their child vectors. These classes are a proxy to wrap the two APIs to provide a common view for the use the result set builder and its internals.
Output Container
Builds the harvest vector container that includes only the columns that are included in the harvest schema version. That is, it excludes columns added while writing an overflow row.Because a Drill row is actually a hierarchy, walks the internal hierarchy and builds a corresponding output hierarchy.
- The root node is the row itself (vector container),
- Internal nodes are maps (structures),
- Leaf notes are primitive vectors (which may be arrays).
As special case occurs when columns are added in the overflow row. These columns do not appear in the output container for the main part of the batch; instead they appear in the next output container that includes the overflow row.
Since the container here may contain a subset of the internal columns, an interesting case occurs for maps. The maps in the output container are not the same as those used internally. Since a map column can contain either one list of columns or another, the internal and external maps must differ. The set of child vectors (except for child maps) are shared.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
static class
static class
static class
static class
TupleState.DictVectorState<T extends ValueVector>
static class
static class
Represents a map column (either single or repeated).static class
Represents a tuple defined as a Drill map: single or repeated.static class
State for a map vector.static class
Handles the details of the top-level tuple, the data row itself.static class
static class
static class
-
Field Summary
Modifier and TypeFieldDescriptionprotected final List<ColumnState>
The set of columns added via the writers: includes both projected and unprojected columns.protected TupleMetadata
Metadata description of the output container (for the row) or map (for map or repeated map.)protected final TupleMetadata
Internal writer schema that matches the column list.Fields inherited from class org.apache.drill.exec.physical.resultSet.impl.ContainerState
loader, parentColumn, projectionSet, vectorCache
-
Constructor Summary
ModifierConstructorDescriptionprotected
TupleState
(org.apache.drill.exec.physical.resultSet.impl.LoaderInternals events, ResultVectorCache vectorCache, ProjectionFilter projectionSet) -
Method Summary
Modifier and TypeMethodDescriptionprotected void
addColumn
(ColumnState colState) addColumn
(TupleWriter tupleWriter, MaterializedField column) addColumn
(TupleWriter tupleWriter, ColumnMetadata columnSchema) abstract int
addOutputColumn
(ValueVector vector, ColumnMetadata colSchema) protected void
bindOutputSchema
(TupleMetadata outputSchema) columns()
Returns an ordered set of the columns which make up the tuple.protected Collection<ColumnState>
void
dump
(HierarchicalFormatter format) boolean
boolean
isProjected
(String colName) schema()
protected void
updateOutput
(int curSchemaVersion) abstract AbstractTupleWriter
writer()
Methods inherited from class org.apache.drill.exec.physical.resultSet.impl.ContainerState
addColumn, bindColumnState, close, harvestWithLookAhead, innerCardinality, isVersioned, loader, projection, rollover, startBatch, updateCardinality, vectorCache
-
Field Details
-
columns
The set of columns added via the writers: includes both projected and unprojected columns. (The writer is free to add columns that the query does not project; the result set loader creates a dummy column and dummy writer, then does not project the column to the output.) -
schema
Internal writer schema that matches the column list. -
outputSchema
Metadata description of the output container (for the row) or map (for map or repeated map.)Rows and maps have an output schema which may differ from the internal schema. The output schema excludes unprojected columns. It also excludes columns added in an overflow row.
The output schema is built slightly differently for maps inside a union vs. normal top-level (or nested) maps. Maps inside a union do not defer columns because of the muddy semantics (and infrequent use) of unions.
-
-
Constructor Details
-
TupleState
protected TupleState(org.apache.drill.exec.physical.resultSet.impl.LoaderInternals events, ResultVectorCache vectorCache, ProjectionFilter projectionSet)
-
-
Method Details
-
bindOutputSchema
-
columns
Returns an ordered set of the columns which make up the tuple. Column order is the same as that defined by the map's schema, to allow indexed access. New columns always appear at the end of the list to preserve indexes.- Returns:
- ordered list of column states for the columns within this tuple
-
schema
-
writer
-
isProjected
- Specified by:
isProjected
in interfaceAbstractTupleWriter.TupleWriterListener
-
addColumn
- Specified by:
addColumn
in interfaceAbstractTupleWriter.TupleWriterListener
-
addColumn
- Specified by:
addColumn
in interfaceAbstractTupleWriter.TupleWriterListener
-
addColumn
- Specified by:
addColumn
in classContainerState
-
hasProjections
public boolean hasProjections() -
columnStates
- Specified by:
columnStates
in classContainerState
-
updateOutput
protected void updateOutput(int curSchemaVersion) -
addOutputColumn
-
outputSchema
-
dump
-