Class NullableScalarWriter
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.NullableScalarWriter
- All Implemented Interfaces:
ColumnWriter
,ScalarWriter
,ValueWriter
,WriterEvents
,WriterPosition
-
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.AbstractScalarWriterImpl
schema, vectorIndex
-
Constructor Summary
ConstructorDescriptionNullableScalarWriter
(ColumnMetadata schema, NullableVector nullableVector, BaseScalarWriter baseWriter) -
Method Summary
Modifier and TypeMethodDescriptionvoid
appendBytes
(byte[] value, int len) void
bindIndex
(ColumnWriterIndex index) Bind the writer to a writer index.void
Bind a listener to the underlying vector writer.build
(ColumnMetadata schema, NullableVector nullableVector, BaseScalarWriter baseWriter) void
copy
(ColumnReader from) Copy a single value from the given reader, which must be of the same type as this writer.void
dump
(HierarchicalFormatter format) void
End a value.void
endWrite()
End a batch: finalize any vector values.int
Return the last write position in the vector.boolean
nullable()
Whether this writer allows nulls.void
The vectors backing this writer rolled over.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.int
Position within the vector of the first value for the current row.void
setBoolean
(boolean value) void
setBytes
(byte[] value, int len) void
void
setDecimal
(BigDecimal value) void
setDefaultValue
(Object value) Set the default value to be used to fill empties for this writer.void
setDouble
(double value) void
setFloat
(float value) void
setInt
(int value) void
setLong
(long value) void
setNull()
Set the current value to null.void
setPeriod
(org.joda.time.Period value) void
void
void
setTimestamp
(Instant value) void
Write value to a vector as a Java object of the "native" type for the column.void
startRow()
Start a new row.void
Start a write (batch) operation.Describe the type of the value.vector()
Methods inherited from class org.apache.drill.exec.vector.accessor.writer.AbstractScalarWriterImpl
bindSchema, isProjected, saveRow, schema, type, writeIndex
Methods inherited from class org.apache.drill.exec.vector.accessor.writer.AbstractScalarWriter
conversionError, extendedType, setObject, toString
-
Constructor Details
-
NullableScalarWriter
public NullableScalarWriter(ColumnMetadata schema, NullableVector nullableVector, BaseScalarWriter baseWriter)
-
-
Method Details
-
build
public static AbstractScalarWriterImpl.ScalarObjectWriter build(ColumnMetadata schema, NullableVector nullableVector, BaseScalarWriter baseWriter) -
bitsWriter
-
baseWriter
-
vector
- Specified by:
vector
in classAbstractScalarWriterImpl
-
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)
-
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
- Overrides:
rowStartIndex
in classAbstractScalarWriterImpl
- Returns:
- the vector offset of the first value for the current row
-
valueType
Description copied from interface:ScalarWriter
Describe the type of the value. This is a compression of the value vector type: it describes which method will return the vector value.- Returns:
- the value type which indicates which get method is valid for the column
-
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. -
nullable
public boolean nullable()Description copied from interface:ColumnWriter
Whether this writer allows nulls. This is not as simple as checking for theTypeProtos.DataMode.OPTIONAL
type in the schema. List entries are nullable, if they are primitive, but not if they are maps or lists. Unions are nullable, regardless of cardinality.- Returns:
- true if a call to
ColumnWriter.setNull()
is supported, false if not
-
setNull
public void setNull()Description copied from interface:ColumnWriter
Set the current value to null. Support depends on the underlying implementation: only nullable types support this operation. throws IllegalStateException if called on a non-nullable value. -
setBoolean
public void setBoolean(boolean value) -
setInt
public void setInt(int value) -
setLong
public void setLong(long value) -
setFloat
public void setFloat(float value) -
setDouble
public void setDouble(double value) -
setString
-
setBytes
public void setBytes(byte[] value, int len) -
appendBytes
public void appendBytes(byte[] value, int len) -
setDecimal
-
setPeriod
public void setPeriod(org.joda.time.Period value) -
setDate
-
setTime
-
setTimestamp
-
setValue
Description copied from interface:ValueWriter
Write value to a vector as a Java object of the "native" type for the column. This form is available only on scalar writers. The object must be of the form for the primary write method above.Primarily to be used when the code already knows the object type.
- Parameters:
value
- a value that matches the primary setter above, or null to set the column to null- See Also:
-
copy
Description copied from interface:ColumnWriter
Copy a single value from the given reader, which must be of the same type as this writer.- Parameters:
from
- reader to provide the data
-
preRollover
public 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. -
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
-
bindListener
Description copied from interface:WriterEvents
Bind a listener to the underlying vector writer. This listener reports on vector events (overflow, growth), and so is called only when the writer is backed by a vector. The listener is ignored (and never called) for dummy (non-projected) columns. If the column is compound (such as for a nullable or repeated column, or for a map), then the writer is bound to the individual components.- Specified by:
bindListener
in interfaceWriterEvents
- Overrides:
bindListener
in classAbstractScalarWriter
- Parameters:
listener
- the vector event listener to bind
-
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
-
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
- Overrides:
endArrayValue
in classAbstractScalarWriterImpl
-
endWrite
public void endWrite()Description copied from interface:WriterEvents
End a batch: finalize any vector values. -
dump
- Specified by:
dump
in interfaceWriterEvents
- Overrides:
dump
in classAbstractScalarWriterImpl
-
setDefaultValue
Description copied from interface:ScalarWriter
Set the default value to be used to fill empties for this writer. Only valid for required writers: null writers set this is-set bit to 0 and set the data value to 0.- Parameters:
value
- the value to set. Cannot be null. The type of the value must match that legal forValueWriter.setValue(Object)
-