Class ContainerState

java.lang.Object
org.apache.drill.exec.physical.resultSet.impl.ContainerState
Direct Known Subclasses:
ListState, RepeatedListState, TupleState, UnionState

public abstract class ContainerState extends Object
Abstract representation of a container of vectors: a row, a map, a repeated map, a list or a union.

The container is responsible for creating new columns in response from a writer listener event. Column creation requires a set of four items:

  • The value vector (which may be null if the column is not projected.
  • The writer for the column.
  • A vector state that manages allocation, overflow, cleanup and other vector-specific tasks.
  • A column state which orchestrates the above three items.
    • Field Details

      • loader

        protected final org.apache.drill.exec.physical.resultSet.impl.LoaderInternals loader
      • projectionSet

        protected final ProjectionFilter projectionSet
      • parentColumn

        protected ColumnState parentColumn
      • vectorCache

        protected final ResultVectorCache vectorCache
        Vector cache for this loader. .
    • Constructor Details

      • ContainerState

        public ContainerState(org.apache.drill.exec.physical.resultSet.impl.LoaderInternals loader, ResultVectorCache vectorCache, ProjectionFilter projectionSet)
      • ContainerState

        public ContainerState(org.apache.drill.exec.physical.resultSet.impl.LoaderInternals loader, ResultVectorCache vectorCache)
    • Method Details

      • bindColumnState

        public void bindColumnState(ColumnState parentState)
      • innerCardinality

        public abstract int innerCardinality()
      • addColumn

        protected abstract void addColumn(ColumnState colState)
      • columnStates

        protected abstract Collection<ColumnState> columnStates()
      • projection

        protected ProjectionFilter projection()
      • isVersioned

        protected abstract boolean isVersioned()
        Reports whether this container is subject to version management. Version management adds columns to the output container at harvest time based on whether they should appear in the output batch.
        Returns:
        true if versioned
      • loader

        protected org.apache.drill.exec.physical.resultSet.impl.LoaderInternals loader()
      • vectorCache

        public ResultVectorCache vectorCache()
      • addColumn

        public ColumnState addColumn(ColumnMetadata columnSchema)
      • updateCardinality

        public void updateCardinality()
        In order to allocate the correct-sized vectors, the container must know its member cardinality: the number of elements in each row. This is 1 for a single map or union, but may be any number for a map array or a list. Then, this value is recursively pushed downward to compute the cardinality of lists of maps that contains lists of maps, and so on.
      • startBatch

        public void startBatch(boolean schemaOnly)
        Start a new batch by shifting the overflow buffers back into the main write vectors and updating the writers.
      • rollover

        public void rollover()
        A column within the row batch overflowed. Prepare to absorb the rest of the in-flight row by rolling values over to a new vector, saving the complete vector for later. This column could have a value for the overflow row, or for some previous row, depending on exactly when and where the overflow occurs.
      • harvestWithLookAhead

        public void harvestWithLookAhead()
        Writing of a row batch is complete, and an overflow occurred. Prepare the vector for harvesting to send downstream. Set aside the look-ahead vector and put the full vector buffer back into the active vector.
      • close

        public void close()
        Clean up state (such as backup vectors) associated with the state for each vector.