Class BaseVarWidthWriter
java.lang.Object
org.apache.drill.exec.vector.accessor.writer.AbstractScalarWriter
org.apache.drill.exec.vector.accessor.writer.AbstractScalarWriterImpl
org.apache.drill.exec.vector.accessor.writer.BaseScalarWriter
org.apache.drill.exec.vector.accessor.writer.BaseVarWidthWriter
- All Implemented Interfaces:
ColumnWriter
,ScalarWriter
,ValueWriter
,WriterEvents
,WriterPosition
- Direct Known Subclasses:
ColumnAccessors.Var16CharColumnWriter
,ColumnAccessors.VarBinaryColumnWriter
,ColumnAccessors.VarCharColumnWriter
,ColumnAccessors.VarDecimalColumnWriter
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.
-
Nested Class Summary
Nested classes/interfaces inherited from class org.apache.drill.exec.vector.accessor.writer.AbstractScalarWriterImpl
AbstractScalarWriterImpl.ScalarObjectWriter
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.BaseScalarWriter
capacity, drillBuf, emptyValue, listener, MIN_BUFFER_SIZE
Fields inherited from class org.apache.drill.exec.vector.accessor.writer.AbstractScalarWriterImpl
schema, vectorIndex
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
bindIndex
(ColumnWriterIndex index) Bind the writer to a writer index.void
dump
(HierarchicalFormatter format) final void
endWrite()
End a batch: finalize any vector values.int
Return the last write position in the vector.void
The vectors backing this writer rolled over.protected final int
prepareAppend
(int width) protected final int
prepareWrite
(int width) final void
The vectors backing this vector are about to roll over.void
During a writer to a row, rewind the the current index position to restart the row.protected final void
All change of buffer comes through this function to allow capturing the buffer address and capacity.void
void
startRow()
Start a new row.void
Start a write (batch) operation.Methods inherited from class org.apache.drill.exec.vector.accessor.writer.BaseScalarWriter
appendBytes, bindListener, bindSchema, canExpand, nullable, overflowed, realloc, setBoolean, setBytes, setDate, setDecimal, setDouble, setFloat, setInt, setLong, setNull, setPeriod, setString, setTime, setTimestamp
Methods inherited from class org.apache.drill.exec.vector.accessor.writer.AbstractScalarWriterImpl
endArrayValue, isProjected, rowStartIndex, saveRow, schema, type, vector, writeIndex
Methods inherited from class org.apache.drill.exec.vector.accessor.writer.AbstractScalarWriter
conversionError, extendedType, setObject, toString
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.apache.drill.exec.vector.accessor.ColumnWriter
copy
Methods inherited from interface org.apache.drill.exec.vector.accessor.ScalarWriter
setDefaultValue, valueType
Methods inherited from interface org.apache.drill.exec.vector.accessor.ValueWriter
setValue
-
Field Details
-
offsetsWriter
-
-
Constructor Details
-
BaseVarWidthWriter
-
-
Method Details
-
bindIndex
Description copied from interface:WriterEvents
Bind the writer to a writer index.- Specified by:
bindIndex
in interfaceWriterEvents
- Overrides:
bindIndex
in classAbstractScalarWriterImpl
- 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 interfaceWriterEvents
- Overrides:
startWrite
in classAbstractScalarWriterImpl
-
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, callWriterEvents.restartRow()
instead.- Specified by:
startRow
in interfaceWriterEvents
- Overrides:
startRow
in classAbstractScalarWriterImpl
-
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 classBaseScalarWriter
-
skipNulls
public void skipNulls()- Specified by:
skipNulls
in classBaseScalarWriter
-
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
- Specified by:
dump
in interfaceWriterEvents
- Overrides:
dump
in classBaseScalarWriter
-