public abstract class ResolvedTuple extends Object implements VectorSource
Output columns within the tuple can be projected from the data source, might be null (requested columns that don't match a data source column) or might be a constant (such as an implicit column.) This class orchestrates assembling an output tuple from a collection of these three column types. (Though implicit columns appear only in the root tuple.)
To accomplish this recursive null processing, each tuple is associated with a null builder. (The null builder can be null if projection is implicit with a wildcard; in such a case no null columns can occur. But, even here, with schema persistence, a SELECT * query may need null columns if a second file does not contain a column that appeared in a first file.)
The null builder is bound to each tuple to allow vector persistence via the result vector cache. If we must create a null column `x` in two different readers, then the rules of Drill require that the same vector be used for both (or else a schema change is signaled.) The vector cache works by name (and type). Since maps may contain columns with the same names as other maps, the vector cache must be associated with each tuple. And, by extension, the null builder must also be associated with each tuple.
VectorSource that supplies the
vector for the column, along with the vector's index within that source.
The resolved tuple is bound to an output tuple. The projection mechanism
grabs the input vector from the vector source at the indicated position, and
links it into the output tuple, represented by this projected tuple, at the
position of the resolved column in the child list.
| Modifier and Type | Class and Description |
|---|---|
static class |
ResolvedTuple.ResolvedDict |
static class |
ResolvedTuple.ResolvedDictArray |
static class |
ResolvedTuple.ResolvedMap
Represents a map implied by the project list, whether or not the map
actually appears in the table schema.
|
static class |
ResolvedTuple.ResolvedMapArray
Represents a map tuple (not the map column, rather the value of the
map column.) When projecting, we create a new repeated map vector,
but share the offsets vector from input to output.
|
static class |
ResolvedTuple.ResolvedRow
Represents the top-level tuple which is projected to a
vector container.
|
static class |
ResolvedTuple.ResolvedSingleDict |
static class |
ResolvedTuple.ResolvedSingleMap |
| Modifier and Type | Field and Description |
|---|---|
protected VectorSource |
binding |
protected List<ResolvedTuple> |
children |
protected List<ResolvedColumn> |
members |
protected NullColumnBuilder |
nullBuilder |
| Constructor and Description |
|---|
ResolvedTuple(NullColumnBuilder nullBuilder) |
| Modifier and Type | Method and Description |
|---|---|
void |
add(ResolvedColumn col) |
void |
addChild(ResolvedTuple child) |
abstract void |
addVector(ValueVector vector) |
abstract BufferAllocator |
allocator() |
protected void |
buildColumns()
Merge two or more partial batches to produce a final output batch.
|
void |
buildNulls(ResultVectorCache vectorCache) |
protected void |
cascadeRowCount(int rowCount) |
void |
close() |
List<ResolvedColumn> |
columns() |
abstract int |
innerCardinality(int outerCardinality) |
boolean |
isSimpleProjection() |
void |
loadNulls(int rowCount) |
abstract String |
name() |
NullColumnBuilder |
nullBuilder() |
void |
removeChild(ResolvedTuple child) |
void |
reset()
During planning, discard a partial plan to allow reusing the same (root) tuple
for multiple projection plans.
|
abstract void |
setRowCount(int rowCount) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitvectorprotected final List<ResolvedColumn> members
protected final NullColumnBuilder nullBuilder
protected List<ResolvedTuple> children
protected VectorSource binding
public ResolvedTuple(NullColumnBuilder nullBuilder)
public NullColumnBuilder nullBuilder()
public void add(ResolvedColumn col)
public void addChild(ResolvedTuple child)
public void removeChild(ResolvedTuple child)
public boolean isSimpleProjection()
public List<ResolvedColumn> columns()
public void buildNulls(ResultVectorCache vectorCache)
public void loadNulls(int rowCount)
public abstract int innerCardinality(int outerCardinality)
protected void buildColumns()
For example, consider two partial batches:
(a, d, e)
(c, b)
We may wish to merge them by projecting columns into an output batch
of the form:
(a, b, c, d)
It is not necessary to project all columns from the inputs, but all
columns in the output must have a projection.
The merger is created once per schema, then can be reused for any number of batches. The only restriction is that the partial batches must have the same row count so that the final output batch record count makes sense.
Merging is done by discarding any data in the output, then exchanging the buffers from the input columns to the output, leaving projected columns empty. Note that unprojected columns must be cleared by the caller. The caller will have figured out which columns to project and which not to project.
public abstract void addVector(ValueVector vector)
public abstract void setRowCount(int rowCount)
protected void cascadeRowCount(int rowCount)
public abstract BufferAllocator allocator()
public abstract String name()
public void reset()
public void close()
Copyright © 2021 The Apache Software Foundation. All rights reserved.