public interface VariantWriter extends ColumnWriter
At write time, the set of possible types is expanded upon the
first write to each type. A request to obtain a writer for type
will create the underlying storage vector if needed, then return
a write of the proper type. Note that unlike most other writers,
the caller is required to call the
#scalar(MinorType)
method for each value so that this
writer knows which type of value is to be stored.
Alternatively, the client can cache a writer by calling
#memberWriter(MinorType)
to retrieve a writer (without setting
the type for a row), then calling the set method on that writer for each
row, and calling #setType(MinorType)
for each row.
This writer acts as somewhat like a map: it allows access to type-specific writers.
Although the union and list vectors supports a union of any Drill type, the only sane combinations are:
VariantReader}
Modifier and Type | Interface and Description |
---|---|
static interface |
VariantWriter.VariantWriterListener |
Modifier and Type | Method and Description |
---|---|
ObjectWriter |
addMember(ColumnMetadata schema) |
ObjectWriter |
addMember(TypeProtos.MinorType type) |
ArrayWriter |
array() |
boolean |
hasType(TypeProtos.MinorType type)
Determine if the union vector has materialized storage for the
given type.
|
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.
|
ScalarWriter |
scalar(TypeProtos.MinorType type) |
void |
setType(TypeProtos.MinorType type)
Explicitly set the type of the present value.
|
int |
size()
Returns the number of types in the variant.
|
TupleWriter |
tuple() |
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.
|
copy, isProjected, nullable, schema, setNull, setObject, type
VariantMetadata variantSchema()
int size()
boolean hasType(TypeProtos.MinorType type)
type
- data typetrue
if a value of the given type has been written
and storage allocated (or storage was allocated implicitly),
false
otherwiseObjectWriter addMember(TypeProtos.MinorType type)
ObjectWriter addMember(ColumnMetadata schema)
ObjectWriter memberWriter(TypeProtos.MinorType type)
#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.type
- the type of the writer to cachevoid setType(TypeProtos.MinorType type)
type
- type to set for the current rowObjectWriter member(TypeProtos.MinorType type)
type
- type to set for the current rowScalarWriter scalar(TypeProtos.MinorType type)
TupleWriter tuple()
ArrayWriter array()
Copyright © 1970 The Apache Software Foundation. All rights reserved.