Class BaseVarWidthWriter

All Implemented Interfaces:
ColumnWriter, ScalarWriter, ValueWriter, WriterEvents, WriterPosition
Direct Known Subclasses:
ColumnAccessors.Var16CharColumnWriter, ColumnAccessors.VarBinaryColumnWriter, ColumnAccessors.VarCharColumnWriter, ColumnAccessors.VarDecimalColumnWriter

public abstract class BaseVarWidthWriter extends BaseScalarWriter
Base class for variable-width (VarChar, VarBinary, etc.) writers. Handles the additional complexity that such writers work with both an offset vector and a data vector. The offset vector is written using a specialized offset vector writer. The last write index is defined as the the last write position in the offset vector; not the last write position in the variable-width vector.

Most and value events are forwarded to the offset vector.

This class handles filling empty values with a default value. Doing so is trick as we must coordinate both this vector and the offset vector; checking for resize and overflow on each step. Also, when filling empties, we cannot use the normal "set" functions as they are what trigger the empty filling. Instead, we have to write to the "last write" position, not the current row positon.

  • Field Details

  • Constructor Details

    • BaseVarWidthWriter

      public BaseVarWidthWriter(UInt4Vector offsetVector)
  • Method Details

    • bindIndex

      public void bindIndex(ColumnWriterIndex index)
      Description copied from interface: WriterEvents
      Bind the writer to a writer index.
      Specified by:
      bindIndex in interface WriterEvents
      Overrides:
      bindIndex in class AbstractScalarWriterImpl
      Parameters:
      index - the writer index (top level or nested for arrays)
    • 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
      Overrides:
      startWrite in class AbstractScalarWriterImpl
    • 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
      Overrides:
      startRow in class AbstractScalarWriterImpl
    • prepareWrite

      protected final int prepareWrite(int width)
    • prepareAppend

      protected final int prepareAppend(int width)
    • setBuffer

      protected final void setBuffer()
      Description copied from class: BaseScalarWriter
      All change of buffer comes through this function to allow capturing the buffer address and capacity. Only two ways to set the buffer: by binding to a vector in bindVector(), or by resizing the vector in prepareWrite().
      Specified by:
      setBuffer in class BaseScalarWriter
    • skipNulls

      public void skipNulls()
      Specified by:
      skipNulls in class BaseScalarWriter
    • restartRow

      public void restartRow()
      Description copied from interface: WriterEvents
      During a writer to a row, rewind the the current index position to restart the row. Done when abandoning the current row, such as when filtering out a row at read time.
    • lastWriteIndex

      public int lastWriteIndex()
      Description copied from interface: WriterPosition
      Return the last write position in the vector. This may be the same as the writer index position (if the vector was written at that point), or an earlier point. In either case, this value points to the last valid value in the vector.
      Returns:
      index of the last valid value in the vector
    • preRollover

      public final void preRollover()
      Description copied from interface: WriterEvents
      The vectors backing this vector are about to roll over. Finish the current batch up to, but not including, the current row.
    • postRollover

      public void postRollover()
      Description copied from interface: WriterEvents
      The vectors backing this writer rolled over. This means that data for the current row has been rolled over into a new vector. Offsets and indexes should be shifted based on the understanding that data for the current row now resides at the start of a new vector instead of its previous location elsewhere in an old vector.
    • endWrite

      public final void endWrite()
      Description copied from interface: WriterEvents
      End a batch: finalize any vector values.
    • dump

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