Class AbstractScalarWriterImpl

java.lang.Object
org.apache.drill.exec.vector.accessor.writer.AbstractScalarWriter
org.apache.drill.exec.vector.accessor.writer.AbstractScalarWriterImpl
All Implemented Interfaces:
ColumnWriter, ScalarWriter, ValueWriter, WriterEvents, WriterPosition
Direct Known Subclasses:
BaseScalarWriter, DummyScalarWriter, NullableScalarWriter

public abstract class AbstractScalarWriterImpl extends AbstractScalarWriter implements WriterEvents
Column writer implementation that acts as the basis for the generated, vector-specific implementations. All set methods throw an exception; subclasses simply override the supported method(s).
  • Field Details

    • schema

      protected ColumnMetadata schema
    • vectorIndex

      protected ColumnWriterIndex vectorIndex
      Indicates the position in the vector to write. Set via an object so that all writers (within the same subtree) can agree on the write position. For example, all top-level, simple columns see the same row index. All columns within a repeated map see the same (inner) index, etc.
  • Constructor Details

    • AbstractScalarWriterImpl

      public AbstractScalarWriterImpl()
  • Method Details

    • type

      public ObjectType type()
      Description copied from interface: ColumnWriter
      Return the object (structure) type of this writer.
      Specified by:
      type in interface ColumnWriter
      Returns:
      type indicating if this is a scalar, tuple or array
    • bindSchema

      public void bindSchema(ColumnMetadata schema)
    • bindIndex

      public void bindIndex(ColumnWriterIndex vectorIndex)
      Description copied from interface: WriterEvents
      Bind the writer to a writer index.
      Specified by:
      bindIndex in interface WriterEvents
      Parameters:
      vectorIndex - the writer index (top level or nested for arrays)
    • rowStartIndex

      public int rowStartIndex()
      Description copied from interface: WriterPosition
      Position within the vector of the first value for the current row. Note that this is always the first value for the row, even for a writer deeply nested within a hierarchy of arrays. (The first position for the current array is not exposed in this API.)
      Specified by:
      rowStartIndex in interface WriterPosition
      Returns:
      the vector offset of the first value for the current row
    • writeIndex

      public int writeIndex()
      Description copied from interface: WriterPosition
      Current write index for the writer. This is the global array location for arrays, same as the row index for top-level columns.
      Specified by:
      writeIndex in interface WriterPosition
      Returns:
      current write index
    • schema

      public ColumnMetadata schema()
      Description copied from interface: ColumnWriter
      Returns the schema of the column associated with this writer.
      Specified by:
      schema in interface ColumnWriter
      Returns:
      schema for this writer's column
    • vector

      public abstract BaseDataValueVector vector()
    • startWrite

      public void startWrite()
      Description copied from interface: WriterEvents
      Start a write (batch) operation. Performs any vector initialization required at the start of a batch (especially for offset vectors.)
      Specified by:
      startWrite in interface WriterEvents
    • startRow

      public void startRow()
      Description copied from interface: WriterEvents
      Start a new row. To be called only when a row is not active. To restart a row, call WriterEvents.restartRow() instead.
      Specified by:
      startRow in interface WriterEvents
    • endArrayValue

      public void endArrayValue()
      Description copied from interface: WriterEvents
      End a value. Similar to WriterEvents.saveRow(), but the save of a value is conditional on saving the row. This version is primarily of use in tuples nested inside arrays: it saves each tuple within the array, advancing to a new position in the array. The update of the array's offset vector based on the cumulative value saves is done when saving the row.
      Specified by:
      endArrayValue in interface WriterEvents
    • saveRow

      public void saveRow()
      Description copied from interface: WriterEvents
      Saves a row. Commits offset vector locations and advances each to the next position. Can be called only when a row is active.
      Specified by:
      saveRow in interface WriterEvents
    • isProjected

      public boolean isProjected()
      Description copied from interface: ColumnWriter
      Whether this writer is projected (is backed by a materialized vector), or is unprojected (is just a dummy writer.) In most cases, clients can ignore whether the column is projected and just write to the writer. This flag handles those special cases where it is helpful to know if the column is projected or not.
      Specified by:
      isProjected in interface ColumnWriter
    • dump

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