public class UnionWriterImpl extends Object implements VariantWriter, WriterEvents
Modifier and Type | Class and Description |
---|---|
static interface |
UnionWriterImpl.UnionShim |
static class |
UnionWriterImpl.VariantObjectWriter |
VariantWriter.VariantWriterListener
WriterEvents.ColumnWriterListener, WriterEvents.State
Constructor and Description |
---|
UnionWriterImpl(ColumnMetadata schema) |
UnionWriterImpl(ColumnMetadata schema,
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, UnionVector vector, AbstractObjectWriter[] variants)
public void bindIndex(ColumnWriterIndex index)
WriterEvents
bindIndex
in interface WriterEvents
index
- the writer index (top level or nested for
arrays)public void bindListener(VariantWriter.VariantWriterListener listener)
public void bindListener(WriterEvents.ColumnWriterListener listener)
WriterEvents
bindListener
in interface WriterEvents
listener
- 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()
ColumnWriter
type
in interface ColumnWriter
public boolean nullable()
ColumnWriter
TypeProtos.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 ColumnWriter
ColumnWriter.setNull()
is supported, false
if notpublic ColumnMetadata schema()
ColumnWriter
schema
in interface ColumnWriter
public VariantMetadata variantSchema()
VariantWriter
variantSchema
in interface VariantWriter
public int size()
VariantWriter
size
in interface VariantWriter
public boolean hasType(TypeProtos.MinorType type)
VariantWriter
hasType
in interface VariantWriter
type
- data typetrue
if a value of the given type has been written
and storage allocated (or storage was allocated implicitly),
false
otherwisepublic void setNull()
ColumnWriter
setNull
in interface ColumnWriter
public 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 VariantWriter
type
- the type of the writer to cachepublic ObjectWriter member(TypeProtos.MinorType type)
VariantWriter
member
in interface VariantWriter
type
- type to set for the current rowpublic void setType(TypeProtos.MinorType type)
VariantWriter
setType
in interface VariantWriter
type
- type to set for the current rowpublic ObjectWriter addMember(ColumnMetadata colSchema)
addMember
in interface VariantWriter
public ObjectWriter addMember(TypeProtos.MinorType type)
addMember
in interface VariantWriter
protected void addMember(AbstractObjectWriter writer)
writer
- the column writer to addpublic ScalarWriter scalar(TypeProtos.MinorType type)
scalar
in interface VariantWriter
public TupleWriter tuple()
tuple
in interface VariantWriter
public ArrayWriter array()
array
in interface VariantWriter
public boolean isProjected()
ColumnWriter
isProjected
in interface ColumnWriter
public void startWrite()
WriterEvents
startWrite
in interface WriterEvents
public void startRow()
WriterEvents
WriterEvents.restartRow()
instead.startRow
in interface WriterEvents
public void endArrayValue()
WriterEvents
WriterEvents.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 WriterEvents
public void restartRow()
WriterEvents
restartRow
in interface WriterEvents
public void saveRow()
WriterEvents
saveRow
in interface WriterEvents
public void preRollover()
WriterEvents
preRollover
in interface WriterEvents
public void postRollover()
WriterEvents
postRollover
in interface WriterEvents
public void endWrite()
WriterEvents
endWrite
in interface WriterEvents
public int lastWriteIndex()
WriterPosition
lastWriteIndex
in interface WriterPosition
public int rowStartIndex()
WriterPosition
rowStartIndex
in interface WriterPosition
public int writeIndex()
WriterPosition
writeIndex
in interface WriterPosition
public void copy(ColumnReader from)
ColumnWriter
copy
in interface ColumnWriter
from
- reader to provide the datapublic void setObject(Object value)
ColumnWriter
setObject
in interface ColumnWriter
value
- value to write to the vector. The Java type of the
object indicates the Drill storage typepublic void dump(HierarchicalFormatter format)
dump
in interface WriterEvents
Copyright © 1970 The Apache Software Foundation. All rights reserved.