Class NullableScalarWriter

All Implemented Interfaces:
ColumnWriter, ScalarWriter, ValueWriter, WriterEvents, WriterPosition

public class NullableScalarWriter extends AbstractScalarWriterImpl
  • Constructor Details

  • Method Details

    • build

      public static AbstractScalarWriterImpl.ScalarObjectWriter build(ColumnMetadata schema, NullableVector nullableVector, BaseScalarWriter baseWriter)
    • bitsWriter

      public BaseScalarWriter bitsWriter()
    • baseWriter

      public BaseScalarWriter baseWriter()
    • vector

      public BaseDataValueVector vector()
      Specified by:
      vector in class AbstractScalarWriterImpl
    • 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)
    • 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
      Overrides:
      rowStartIndex in class AbstractScalarWriterImpl
      Returns:
      the vector offset of the first value for the current row
    • valueType

      public ValueType valueType()
      Description copied from interface: ScalarWriter
      Describe the type of the value. This is a compression of the value vector type: it describes which method will return the vector value.
      Returns:
      the value type which indicates which get method is valid for the column
    • 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.
    • nullable

      public boolean nullable()
      Description copied from interface: ColumnWriter
      Whether this writer allows nulls. This is not as simple as checking for the TypeProtos.DataMode.OPTIONAL type in the schema. List entries are nullable, if they are primitive, but not if they are maps or lists. Unions are nullable, regardless of cardinality.
      Returns:
      true if a call to ColumnWriter.setNull() is supported, false if not
    • setNull

      public void setNull()
      Description copied from interface: ColumnWriter
      Set the current value to null. Support depends on the underlying implementation: only nullable types support this operation. throws IllegalStateException if called on a non-nullable value.
    • setBoolean

      public void setBoolean(boolean value)
    • setInt

      public void setInt(int value)
    • setLong

      public void setLong(long value)
    • setFloat

      public void setFloat(float value)
    • setDouble

      public void setDouble(double value)
    • setString

      public void setString(String value)
    • setBytes

      public void setBytes(byte[] value, int len)
    • appendBytes

      public void appendBytes(byte[] value, int len)
    • setDecimal

      public void setDecimal(BigDecimal value)
    • setPeriod

      public void setPeriod(org.joda.time.Period value)
    • setDate

      public void setDate(LocalDate value)
    • setTime

      public void setTime(LocalTime value)
    • setTimestamp

      public void setTimestamp(Instant value)
    • setValue

      public void setValue(Object value)
      Description copied from interface: ValueWriter
      Write value to a vector as a Java object of the "native" type for the column. This form is available only on scalar writers. The object must be of the form for the primary write method above.

      Primarily to be used when the code already knows the object type.

      Parameters:
      value - a value that matches the primary setter above, or null to set the column to null
      See Also:
    • copy

      public void copy(ColumnReader from)
      Description copied from interface: ColumnWriter
      Copy a single value from the given reader, which must be of the same type as this writer.
      Parameters:
      from - reader to provide the data
    • preRollover

      public 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.
    • 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
    • bindListener

      public void bindListener(WriterEvents.ColumnWriterListener listener)
      Description copied from interface: WriterEvents
      Bind a listener to the underlying vector writer. This listener reports on vector events (overflow, growth), and so is called only when the writer is backed by a vector. The listener is ignored (and never called) for dummy (non-projected) columns. If the column is compound (such as for a nullable or repeated column, or for a map), then the writer is bound to the individual components.
      Specified by:
      bindListener in interface WriterEvents
      Overrides:
      bindListener in class AbstractScalarWriter
      Parameters:
      listener - the vector event listener to bind
    • 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
    • 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
      Overrides:
      endArrayValue in class AbstractScalarWriterImpl
    • endWrite

      public 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 AbstractScalarWriterImpl
    • setDefaultValue

      public void setDefaultValue(Object value)
      Description copied from interface: ScalarWriter
      Set the default value to be used to fill empties for this writer. Only valid for required writers: null writers set this is-set bit to 0 and set the data value to 0.
      Parameters:
      value - the value to set. Cannot be null. The type of the value must match that legal for ValueWriter.setValue(Object)