Class RepeatedVectorState

All Implemented Interfaces:

public class RepeatedVectorState extends Object implements VectorState
Vector state for a scalar array (repeated scalar) vector. Manages both the offsets vector and data vector during overflow and other operations.
  • Constructor Details

  • Method Details

    • vector

      public <T extends ValueVector> T vector()
      Description copied from interface: VectorState
      Underlying vector: the one presented to the consumer of the result set loader.
      Specified by:
      vector in interface VectorState
    • allocate

      public int allocate(int cardinality)
      Description copied from interface: VectorState
      Allocate a new vector with the number of elements given. If the vector is an array, then the cardinality given is the number of arrays.
      Specified by:
      allocate in interface VectorState
      cardinality - number of elements desired in the allocated vector
      the number of bytes allocated
    • rollover

      public void rollover(int newCardinality)
      The column is a scalar or an array of scalars. We need to roll over both the column values and the offsets that point to those values. The index provided is the index into the offset vector. We use that to obtain the index of the values to roll-over.

      Data structure:

       RepeatedVectorState (this class)
       +- OffsetVectorState
       .  +- OffsetVectorWriter (A)
       .  +- Offset vector (B)
       .  +- Backup (e.g. look-ahead) offset vector
       +- ValuesVectorState
       .  +- Scalar (element) writer (C)
       .  +- Data (elements) vector (D)
       .  +- Backup elements vector
       +- Array Writer
       .  +- ColumnWriterIndex (for array as a whole)
       .  +- OffsetVectorWriter (A)
       .  .  +- Offset vector (B)
       .  +- ArrayElementWriterIndex
       .  +- ScalarWriter (D)
       .  .  +- ArrayElementWriterIndex
       .  .  +- Scalar vector (D)

      The top group of objects point into the writer objects in the second group. Letters in parens show the connections.

      To perform the roll-over, we must:

      • Copy values from the current vectors to a set of new, look-ahead vectors.
      • Swap buffers between the main and "backup" vectors, effectively moving the "full" batch to the sidelines, putting the look-ahead vectors into play in order to finish writing the current row.
      • Update the writers to point to the look-ahead buffers, including the initial set of data copied into those vectors.
      • Update the vector indexes to point to the next write positions after the values copied during roll-over.
      Specified by:
      rollover in interface VectorState
      newCardinality - the number of outer elements to create in the look-ahead vector
    • harvestWithLookAhead

      public void harvestWithLookAhead()
      Description copied from interface: VectorState
      A batch is being harvested after an overflow. Put the full batch back into the main vector so it can be harvested.
      Specified by:
      harvestWithLookAhead in interface VectorState
    • startBatchWithLookAhead

      public void startBatchWithLookAhead()
      Description copied from interface: VectorState
      A new batch is starting while an look-ahead vector exists. Move the look-ahead buffers into the main vector to prepare for writing the rest of the batch.
      Specified by:
      startBatchWithLookAhead in interface VectorState
    • close

      public void close()
      Description copied from interface: VectorState
      Clear the vector(s) associated with this state.
      Specified by:
      close in interface VectorState
    • isProjected

      public boolean isProjected()
      Description copied from interface: VectorState
      Report whether this column is projected (has materialized vectors), or is unprojected (has no materialized backing.)
      Specified by:
      isProjected in interface VectorState
      true if the column is projected to the output, false if not
    • dump

      public void dump(HierarchicalFormatter format)
      Specified by:
      dump in interface VectorState