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.ScalarObjectWriterNested classes/interfaces inherited from interface org.apache.drill.exec.vector.accessor.writer.WriterEvents
WriterEvents.ColumnWriterListener, WriterEvents.State -
Field Summary
FieldsFields inherited from class org.apache.drill.exec.vector.accessor.writer.BaseScalarWriter
capacity, drillBuf, emptyValue, listener, MIN_BUFFER_SIZEFields inherited from class org.apache.drill.exec.vector.accessor.writer.AbstractScalarWriterImpl
schema, vectorIndex -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidbindIndex(ColumnWriterIndex index) Bind the writer to a writer index.voiddump(HierarchicalFormatter format) final voidendWrite()End a batch: finalize any vector values.intReturn the last write position in the vector.voidThe vectors backing this writer rolled over.protected final intprepareAppend(int width) protected final intprepareWrite(int width) final voidThe vectors backing this vector are about to roll over.voidDuring a writer to a row, rewind the the current index position to restart the row.protected final voidAll change of buffer comes through this function to allow capturing the buffer address and capacity.voidvoidstartRow()Start a new row.voidStart 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, setTimestampMethods inherited from class org.apache.drill.exec.vector.accessor.writer.AbstractScalarWriterImpl
endArrayValue, isProjected, rowStartIndex, saveRow, schema, type, vector, writeIndexMethods inherited from class org.apache.drill.exec.vector.accessor.writer.AbstractScalarWriter
conversionError, extendedType, setObject, toStringMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.apache.drill.exec.vector.accessor.ColumnWriter
copyMethods inherited from interface org.apache.drill.exec.vector.accessor.ScalarWriter
setDefaultValue, valueTypeMethods inherited from interface org.apache.drill.exec.vector.accessor.ValueWriter
setValue
-
Field Details
-
offsetsWriter
-
-
Constructor Details
-
BaseVarWidthWriter
-
-
Method Details
-
bindIndex
Description copied from interface:WriterEventsBind the writer to a writer index.- Specified by:
bindIndexin interfaceWriterEvents- Overrides:
bindIndexin classAbstractScalarWriterImpl- Parameters:
index- the writer index (top level or nested for arrays)
-
startWrite
public void startWrite()Description copied from interface:WriterEventsStart a write (batch) operation. Performs any vector initialization required at the start of a batch (especially for offset vectors.)- Specified by:
startWritein interfaceWriterEvents- Overrides:
startWritein classAbstractScalarWriterImpl
-
startRow
public void startRow()Description copied from interface:WriterEventsStart a new row. To be called only when a row is not active. To restart a row, callWriterEvents.restartRow()instead.- Specified by:
startRowin interfaceWriterEvents- Overrides:
startRowin classAbstractScalarWriterImpl
-
prepareWrite
protected final int prepareWrite(int width) -
prepareAppend
protected final int prepareAppend(int width) -
setBuffer
protected final void setBuffer()Description copied from class:BaseScalarWriterAll 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:
setBufferin classBaseScalarWriter
-
skipNulls
public void skipNulls()- Specified by:
skipNullsin classBaseScalarWriter
-
restartRow
public void restartRow()Description copied from interface:WriterEventsDuring 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:WriterPositionReturn 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:WriterEventsThe 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:WriterEventsThe 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:WriterEventsEnd a batch: finalize any vector values. -
dump
- Specified by:
dumpin interfaceWriterEvents- Overrides:
dumpin classBaseScalarWriter
-