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 ClassesNested 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
Fields inherited from class org.apache.drill.exec.vector.accessor.writer.AbstractScalarWriterImpl
schema, vectorIndex -
Constructor Summary
ConstructorsConstructorDescriptionNullableScalarWriter(ColumnMetadata schema, NullableVector nullableVector, BaseScalarWriter baseWriter) -
Method Summary
Modifier and TypeMethodDescriptionvoidappendBytes(byte[] value, int len) voidbindIndex(ColumnWriterIndex index) Bind the writer to a writer index.voidBind a listener to the underlying vector writer.build(ColumnMetadata schema, NullableVector nullableVector, BaseScalarWriter baseWriter) voidcopy(ColumnReader from) Copy a single value from the given reader, which must be of the same type as this writer.voiddump(HierarchicalFormatter format) voidEnd a value.voidendWrite()End a batch: finalize any vector values.intReturn the last write position in the vector.booleannullable()Whether this writer allows nulls.voidThe vectors backing this writer rolled over.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.intPosition within the vector of the first value for the current row.voidsetBoolean(boolean value) voidsetBytes(byte[] value, int len) voidvoidsetDecimal(BigDecimal value) voidsetDefaultValue(Object value) Set the default value to be used to fill empties for this writer.voidsetDouble(double value) voidsetFloat(float value) voidsetInt(int value) voidsetLong(long value) voidsetNull()Set the current value to null.voidsetPeriod(org.joda.time.Period value) voidvoidvoidsetTimestamp(Instant value) voidWrite value to a vector as a Java object of the "native" type for the column.voidstartRow()Start a new row.voidStart 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, writeIndexMethods 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:
vectorin classAbstractScalarWriterImpl
-
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)
-
rowStartIndex
public int rowStartIndex()Description copied from interface:WriterPositionPosition 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:
rowStartIndexin interfaceWriterPosition- Overrides:
rowStartIndexin classAbstractScalarWriterImpl- Returns:
- the vector offset of the first value for the current row
-
valueType
Description copied from interface:ScalarWriterDescribe 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: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. -
nullable
public boolean nullable()Description copied from interface:ColumnWriterWhether this writer allows nulls. This is not as simple as checking for theTypeProtos.DataMode.OPTIONALtype 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:ColumnWriterSet 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:ValueWriterWrite 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:ColumnWriterCopy 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: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. -
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
-
bindListener
Description copied from interface:WriterEventsBind 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:
bindListenerin interfaceWriterEvents- Overrides:
bindListenerin classAbstractScalarWriter- Parameters:
listener- the vector event listener to bind
-
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
-
endArrayValue
public void endArrayValue()Description copied from interface:WriterEventsEnd 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:
endArrayValuein interfaceWriterEvents- Overrides:
endArrayValuein classAbstractScalarWriterImpl
-
endWrite
public void endWrite()Description copied from interface:WriterEventsEnd a batch: finalize any vector values. -
dump
- Specified by:
dumpin interfaceWriterEvents- Overrides:
dumpin classAbstractScalarWriterImpl
-
setDefaultValue
Description copied from interface:ScalarWriterSet 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)
-