Class ScalarArrayWriter
java.lang.Object
org.apache.drill.exec.vector.accessor.writer.AbstractArrayWriter
org.apache.drill.exec.vector.accessor.writer.AbstractArrayWriter.BaseArrayWriter
org.apache.drill.exec.vector.accessor.writer.ScalarArrayWriter
- All Implemented Interfaces:
ArrayWriter
,ColumnWriter
,WriterEvents
,WriterPosition
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.
-
Nested Class Summary
Modifier and TypeClassDescriptionclass
For scalar arrays, incrementing the element index and committing the current value is done automatically since there is exactly one value per array element.Nested classes/interfaces inherited from class org.apache.drill.exec.vector.accessor.writer.AbstractArrayWriter
AbstractArrayWriter.ArrayElementWriterIndex, AbstractArrayWriter.ArrayObjectWriter, AbstractArrayWriter.BaseArrayWriter
Nested classes/interfaces inherited from interface org.apache.drill.exec.vector.accessor.writer.WriterEvents
WriterEvents.ColumnWriterListener, WriterEvents.State
-
Field Summary
Fields inherited from class org.apache.drill.exec.vector.accessor.writer.AbstractArrayWriter
elementIndex, elementObjWriter, offsetsWriter, outerIndex
-
Constructor Summary
ConstructorDescriptionScalarArrayWriter
(ColumnMetadata schema, RepeatedValueVector vector, BaseScalarWriter baseElementWriter) -
Method Summary
Modifier and TypeMethodDescriptionvoid
bindIndex
(ColumnWriterIndex index) Bind the writer to a writer index.build
(ColumnMetadata schema, RepeatedValueVector repeatedVector, BaseScalarWriter baseElementWriter) void
save()
When the array contains a tuple or an array, call save() after each array value.void
setBigDecimalArray
(BigDecimal[] value) void
setBooleanArray
(boolean[] value) void
setBooleanObjectArray
(Boolean[] value) void
setByteArray
(byte[] value) void
setByteObjectArray
(Byte[] value) void
setBytesArray
(byte[][] value) void
setDoubleArray
(double[] value) void
setDoubleObjectArray
(Double[] value) void
setFloatArray
(float[] value) void
setFloatObjectArray
(Float[] value) void
setIntArray
(int[] value) void
setIntObjectArray
(Integer[] value) void
setLongArray
(long[] value) void
setLongObjectArray
(Long[] value) void
Set a repeated vector based on a Java array of the proper type.void
setObjectArray
(Object[] value) void
setPeriodArray
(org.joda.time.Period[] value) void
setShortArray
(short[] value) void
setShortObjectArray
(Short[] value) void
setStringArray
(String[] value) Methods inherited from class org.apache.drill.exec.vector.accessor.writer.AbstractArrayWriter.BaseArrayWriter
dump, endArrayValue, endWrite, lastWriteIndex, postRollover, preRollover, restartRow, saveRow, startRow, startWrite
Methods inherited from class org.apache.drill.exec.vector.accessor.writer.AbstractArrayWriter
array, bindListener, copy, dict, entry, entryType, isProjected, nullable, offsetWriter, rowStartIndex, scalar, schema, setNull, setNull, size, tuple, type, variant, writeIndex
-
Constructor Details
-
ScalarArrayWriter
public ScalarArrayWriter(ColumnMetadata schema, RepeatedValueVector vector, BaseScalarWriter baseElementWriter)
-
-
Method Details
-
build
public static AbstractArrayWriter.ArrayObjectWriter build(ColumnMetadata schema, RepeatedValueVector repeatedVector, BaseScalarWriter baseElementWriter) -
bindIndex
Description copied from interface:WriterEvents
Bind the writer to a writer index.- Specified by:
bindIndex
in interfaceWriterEvents
- Overrides:
bindIndex
in classAbstractArrayWriter.BaseArrayWriter
- Parameters:
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
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
).- Parameters:
array
- value to write to the vector. The Java type of the object indicates the Drill storage type
-
setObjectArray
-
setBooleanArray
public void setBooleanArray(boolean[] value) -
setBooleanObjectArray
-
setBytesArray
public void setBytesArray(byte[][] value) -
setByteArray
public void setByteArray(byte[] value) -
setByteObjectArray
-
setShortArray
public void setShortArray(short[] value) -
setShortObjectArray
-
setIntArray
public void setIntArray(int[] value) -
setIntObjectArray
-
setLongArray
public void setLongArray(long[] value) -
setLongObjectArray
-
setFloatArray
public void setFloatArray(float[] value) -
setFloatObjectArray
-
setDoubleArray
public void setDoubleArray(double[] value) -
setDoubleObjectArray
-
setStringArray
-
setPeriodArray
public void setPeriodArray(org.joda.time.Period[] value) -
setBigDecimalArray
-