public class UnionWriterImpl extends Object implements VariantWriter, WriterEvents
| Modifier and Type | Class and Description |
|---|---|
static interface |
UnionWriterImpl.UnionShim |
static class |
UnionWriterImpl.VariantObjectWriter |
VariantWriter.VariantWriterListenerWriterEvents.ColumnWriterListener, WriterEvents.State| Constructor and Description |
|---|
UnionWriterImpl(ColumnMetadata schema) |
UnionWriterImpl(ColumnMetadata schema,
org.apache.drill.exec.vector.complex.UnionVector vector,
AbstractObjectWriter[] variants) |
| Modifier and Type | Method and Description |
|---|---|
protected void |
addMember(AbstractObjectWriter writer)
Add a column writer to an existing union writer.
|
ObjectWriter |
addMember(ColumnMetadata colSchema) |
ObjectWriter |
addMember(TypeProtos.MinorType type) |
ArrayWriter |
array() |
void |
bindIndex(ColumnWriterIndex index)
Bind the writer to a writer index.
|
void |
bindListener(VariantWriter.VariantWriterListener listener) |
void |
bindListener(WriterEvents.ColumnWriterListener listener)
Bind a listener to the underlying vector writer.
|
void |
bindShim(UnionWriterImpl.UnionShim shim) |
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) |
WriterPosition |
elementPosition() |
void |
endArrayValue()
End a value.
|
void |
endWrite()
End a batch: finalize any vector values.
|
boolean |
hasType(TypeProtos.MinorType type)
Determine if the union vector has materialized storage for the
given type.
|
ColumnWriterIndex |
index() |
boolean |
isProjected()
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 |
lastWriteIndex()
Return the last write position in the vector.
|
VariantWriter.VariantWriterListener |
listener() |
ObjectWriter |
member(TypeProtos.MinorType type)
Set the type of the present value and get the writer for
that type.
|
ObjectWriter |
memberWriter(TypeProtos.MinorType type)
Create or retrieve a writer for the given type.
|
boolean |
nullable()
Whether this writer allows nulls.
|
void |
postRollover()
The vectors backing this writer rolled over.
|
void |
preRollover()
The vectors backing this vector are about to roll over.
|
void |
restartRow()
During a writer to a row, rewind the the current index position to
restart the row.
|
int |
rowStartIndex()
Position within the vector of the first value for the current row.
|
void |
saveRow()
Saves a row.
|
ScalarWriter |
scalar(TypeProtos.MinorType type) |
ColumnMetadata |
schema()
Returns the schema of the column associated with this writer.
|
void |
setNull()
Set the current value to null.
|
void |
setObject(Object value)
Generic technique to write data as a generic Java object.
|
void |
setType(TypeProtos.MinorType type)
Explicitly set the type of the present value.
|
UnionWriterImpl.UnionShim |
shim() |
int |
size()
Returns the number of types in the variant.
|
void |
startRow()
Start a new row.
|
void |
startWrite()
Start a write (batch) operation.
|
WriterEvents.State |
state() |
TupleWriter |
tuple() |
ObjectType |
type()
Return the object (structure) type of this writer.
|
VariantMetadata |
variantSchema()
Metadata description of the variant that includes the set of
types, along with extended properties of the types such as
expected allocations sizes, expected array cardinality, etc.
|
int |
writeIndex()
Current write index for the writer.
|
public UnionWriterImpl(ColumnMetadata schema)
public UnionWriterImpl(ColumnMetadata schema, org.apache.drill.exec.vector.complex.UnionVector vector, AbstractObjectWriter[] variants)
public void bindIndex(ColumnWriterIndex index)
WriterEventsbindIndex in interface WriterEventsindex - the writer index (top level or nested for
arrays)public void bindListener(VariantWriter.VariantWriterListener listener)
public void bindListener(WriterEvents.ColumnWriterListener listener)
WriterEventsbindListener in interface WriterEventslistener - the vector event listener to bindpublic WriterEvents.State state()
public ColumnWriterIndex index()
public VariantWriter.VariantWriterListener listener()
public UnionWriterImpl.UnionShim shim()
public WriterPosition elementPosition()
public void bindShim(UnionWriterImpl.UnionShim shim)
public ObjectType type()
ColumnWritertype in interface ColumnWriterpublic boolean nullable()
ColumnWriterTypeProtos.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.nullable in interface ColumnWriterColumnWriter.setNull() is supported, false
if notpublic ColumnMetadata schema()
ColumnWriterschema in interface ColumnWriterpublic VariantMetadata variantSchema()
VariantWritervariantSchema in interface VariantWriterpublic int size()
VariantWritersize in interface VariantWriterpublic boolean hasType(TypeProtos.MinorType type)
VariantWriterhasType in interface VariantWritertype - data typetrue if a value of the given type has been written
and storage allocated (or storage was allocated implicitly),
false otherwisepublic void setNull()
ColumnWritersetNull in interface ColumnWriterpublic ObjectWriter memberWriter(TypeProtos.MinorType type)
VariantWriter#setType(MinorType) per row when the writers are
cached. This method can be called at any time as it does not depend
on an active batch.memberWriter in interface VariantWritertype - the type of the writer to cachepublic ObjectWriter member(TypeProtos.MinorType type)
VariantWritermember in interface VariantWritertype - type to set for the current rowpublic void setType(TypeProtos.MinorType type)
VariantWritersetType in interface VariantWritertype - type to set for the current rowpublic ObjectWriter addMember(ColumnMetadata colSchema)
addMember in interface VariantWriterpublic ObjectWriter addMember(TypeProtos.MinorType type)
addMember in interface VariantWriterprotected void addMember(AbstractObjectWriter writer)
colWriter - the column writer to addpublic ScalarWriter scalar(TypeProtos.MinorType type)
scalar in interface VariantWriterpublic TupleWriter tuple()
tuple in interface VariantWriterpublic ArrayWriter array()
array in interface VariantWriterpublic boolean isProjected()
ColumnWriterisProjected in interface ColumnWriterpublic void startWrite()
WriterEventsstartWrite in interface WriterEventspublic void startRow()
WriterEventsWriterEvents.restartRow() instead.startRow in interface WriterEventspublic void endArrayValue()
WriterEventsWriterEvents.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.endArrayValue in interface WriterEventspublic void restartRow()
WriterEventsrestartRow in interface WriterEventspublic void saveRow()
WriterEventssaveRow in interface WriterEventspublic void preRollover()
WriterEventspreRollover in interface WriterEventspublic void postRollover()
WriterEventspostRollover in interface WriterEventspublic void endWrite()
WriterEventsendWrite in interface WriterEventspublic int lastWriteIndex()
WriterPositionlastWriteIndex in interface WriterPositionpublic int rowStartIndex()
WriterPositionrowStartIndex in interface WriterPositionpublic int writeIndex()
WriterPositionwriteIndex in interface WriterPositionpublic void copy(ColumnReader from)
ColumnWritercopy in interface ColumnWriterfrom - reader to provide the datapublic void setObject(Object value)
ColumnWritersetObject in interface ColumnWritervalue - value to write to the vector. The Java type of the
object indicates the Drill storage typepublic void dump(HierarchicalFormatter format)
dump in interface WriterEventsCopyright © 2021 The Apache Software Foundation. All rights reserved.