Class ScalarArrayWriter

All Implemented Interfaces:
ArrayWriter, ColumnWriter, WriterEvents, WriterPosition

public class ScalarArrayWriter extends AbstractArrayWriter.BaseArrayWriter
Writer for a column that holds an array of scalars. This writer manages the array itself. A type-specific child writer manages the elements within the array. The overall row index (usually) provides the index into the offset vector. An array-specific element index provides the index into elements.

This class manages the offset vector directly. Doing so saves one read and one write to direct memory per element value.

Provides generic write methods for testing and other times when convenience is more important than speed.

The scalar writer for array-valued columns appends values: once a value is written, it cannot be changed. As a result, writer methods have no item index; each set advances the array to the next position. This is an abstract base class; subclasses are generated for each repeated value vector type.

  • Constructor Details

  • Method Details

    • build

      public static AbstractArrayWriter.ArrayObjectWriter build(ColumnMetadata schema, RepeatedValueVector repeatedVector, BaseScalarWriter baseElementWriter)
    • bindIndex

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

      public void save()
      Description copied from interface: ArrayWriter
      When the array contains a tuple or an array, call save() after each array value. Not necessary when writing scalars; each set operation calls save automatically.
    • setObject

      public void setObject(Object array)
      Set a repeated vector based on a Java array of the proper type. This function involves parsing the array type and so is suitable only for test code. The array can be either a primitive (int [], say) or a typed array of boxed values (Integer[], say).
      array - value to write to the vector. The Java type of the object indicates the Drill storage type
    • setObjectArray

      public void setObjectArray(Object[] value)
    • setBooleanArray

      public void setBooleanArray(boolean[] value)
    • setBooleanObjectArray

      public void setBooleanObjectArray(Boolean[] value)
    • setBytesArray

      public void setBytesArray(byte[][] value)
    • setByteArray

      public void setByteArray(byte[] value)
    • setByteObjectArray

      public void setByteObjectArray(Byte[] value)
    • setShortArray

      public void setShortArray(short[] value)
    • setShortObjectArray

      public void setShortObjectArray(Short[] value)
    • setIntArray

      public void setIntArray(int[] value)
    • setIntObjectArray

      public void setIntObjectArray(Integer[] value)
    • setLongArray

      public void setLongArray(long[] value)
    • setLongObjectArray

      public void setLongObjectArray(Long[] value)
    • setFloatArray

      public void setFloatArray(float[] value)
    • setFloatObjectArray

      public void setFloatObjectArray(Float[] value)
    • setDoubleArray

      public void setDoubleArray(double[] value)
    • setDoubleObjectArray

      public void setDoubleObjectArray(Double[] value)
    • setStringArray

      public void setStringArray(String[] value)
    • setPeriodArray

      public void setPeriodArray(org.joda.time.Period[] value)
    • setBigDecimalArray

      public void setBigDecimalArray(BigDecimal[] value)