Class AbstractScalarWriterImpl
java.lang.Object
org.apache.drill.exec.vector.accessor.writer.AbstractScalarWriter
org.apache.drill.exec.vector.accessor.writer.AbstractScalarWriterImpl
- All Implemented Interfaces:
ColumnWriter
,ScalarWriter
,ValueWriter
,WriterEvents
,WriterPosition
- Direct Known Subclasses:
BaseScalarWriter
,DummyScalarWriter
,NullableScalarWriter
Column writer implementation that acts as the basis for the
generated, vector-specific implementations. All set methods
throw an exception; subclasses simply override the supported
method(s).
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
Wraps a scalar writer and its event handler to provide a uniform JSON-like interface for all writer types.Nested classes/interfaces inherited from interface org.apache.drill.exec.vector.accessor.writer.WriterEvents
WriterEvents.ColumnWriterListener, WriterEvents.State
-
Field Summary
Modifier and TypeFieldDescriptionprotected ColumnMetadata
protected ColumnWriterIndex
Indicates the position in the vector to write. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
bindIndex
(ColumnWriterIndex vectorIndex) Bind the writer to a writer index.void
bindSchema
(ColumnMetadata schema) void
dump
(HierarchicalFormatter format) void
End a value.boolean
Whether this writer is projected (is backed by a materialized vector), or is unprojected (is just a dummy writer.) In most cases, clients can ignore whether the column is projected and just write to the writer.int
Position within the vector of the first value for the current row.void
saveRow()
Saves a row.schema()
Returns the schema of the column associated with this writer.void
startRow()
Start a new row.void
Start a write (batch) operation.type()
Return the object (structure) type of this writer.abstract BaseDataValueVector
vector()
int
Current write index for the writer.Methods inherited from class org.apache.drill.exec.vector.accessor.writer.AbstractScalarWriter
bindListener, 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, nullable, setNull
Methods inherited from interface org.apache.drill.exec.vector.accessor.ScalarWriter
setDefaultValue, valueType
Methods inherited from interface org.apache.drill.exec.vector.accessor.ValueWriter
appendBytes, setBoolean, setBytes, setDate, setDecimal, setDouble, setFloat, setInt, setLong, setNull, setPeriod, setString, setTime, setTimestamp, setValue
Methods inherited from interface org.apache.drill.exec.vector.accessor.writer.WriterEvents
bindListener, endWrite, postRollover, preRollover, restartRow
Methods inherited from interface org.apache.drill.exec.vector.accessor.WriterPosition
lastWriteIndex
-
Field Details
-
schema
-
vectorIndex
Indicates the position in the vector to write. Set via an object so that all writers (within the same subtree) can agree on the write position. For example, all top-level, simple columns see the same row index. All columns within a repeated map see the same (inner) index, etc.
-
-
Constructor Details
-
AbstractScalarWriterImpl
public AbstractScalarWriterImpl()
-
-
Method Details
-
type
Description copied from interface:ColumnWriter
Return the object (structure) type of this writer.- Specified by:
type
in interfaceColumnWriter
- Returns:
- type indicating if this is a scalar, tuple or array
-
bindSchema
-
bindIndex
Description copied from interface:WriterEvents
Bind the writer to a writer index.- Specified by:
bindIndex
in interfaceWriterEvents
- Parameters:
vectorIndex
- 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 interfaceWriterPosition
- Returns:
- the vector offset of the first value for the current row
-
writeIndex
public int writeIndex()Description copied from interface:WriterPosition
Current write index for the writer. This is the global array location for arrays, same as the row index for top-level columns.- Specified by:
writeIndex
in interfaceWriterPosition
- Returns:
- current write index
-
schema
Description copied from interface:ColumnWriter
Returns the schema of the column associated with this writer.- Specified by:
schema
in interfaceColumnWriter
- Returns:
- schema for this writer's column
-
vector
-
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
-
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
-
endArrayValue
public void endArrayValue()Description copied from interface:WriterEvents
End a value. Similar toWriterEvents.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 interfaceWriterEvents
-
saveRow
public void saveRow()Description copied from interface:WriterEvents
Saves a row. Commits offset vector locations and advances each to the next position. Can be called only when a row is active.- Specified by:
saveRow
in interfaceWriterEvents
-
isProjected
public boolean isProjected()Description copied from interface:ColumnWriter
Whether this writer is projected (is backed by a materialized vector), or is unprojected (is just a dummy writer.) In most cases, clients can ignore whether the column is projected and just write to the writer. This flag handles those special cases where it is helpful to know if the column is projected or not.- Specified by:
isProjected
in interfaceColumnWriter
-
dump
- Specified by:
dump
in interfaceWriterEvents
-