Class AbstractObjectWriter
java.lang.Object
org.apache.drill.exec.vector.accessor.writer.AbstractObjectWriter
- All Implemented Interfaces:
ColumnWriter
,ObjectWriter
- Direct Known Subclasses:
AbstractArrayWriter.ArrayObjectWriter
,AbstractScalarWriterImpl.ScalarObjectWriter
,AbstractTupleWriter.TupleObjectWriter
,UnionWriterImpl.VariantObjectWriter
Abstract base class for the object layer in writers. This class acts
as the glue between a column and the data type of that column, per the
JSON model which Drill uses. This base class provides stubs for most
methods so that type-specific subclasses can simply fill in the bits
needed for that particular class.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionarray()
void
copy
(ColumnReader from) Copy a single value from the given reader, which must be of the same type as this writer.dict()
abstract void
dump
(HierarchicalFormatter format) abstract WriterEvents
events()
The internal state behind this writer.boolean
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.boolean
nullable()
Whether this writer allows nulls.scalar()
schema()
Returns the schema of the column associated with this writer.void
setNull()
Set the current value to null.void
Generic technique to write data as a generic Java object.toString()
tuple()
type()
Return the object (structure) type of this writer.variant()
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.apache.drill.exec.vector.accessor.ObjectWriter
writer
-
Constructor Details
-
AbstractObjectWriter
public AbstractObjectWriter()
-
-
Method Details
-
scalar
- Specified by:
scalar
in interfaceObjectWriter
-
tuple
- Specified by:
tuple
in interfaceObjectWriter
-
array
- Specified by:
array
in interfaceObjectWriter
-
variant
- Specified by:
variant
in interfaceObjectWriter
-
dict
- Specified by:
dict
in interfaceObjectWriter
-
events
Description copied from interface:ObjectWriter
The internal state behind this writer. To be used only by the implementation, not by the client.- Specified by:
events
in interfaceObjectWriter
-
schema
Description copied from interface:ColumnWriter
Returns the schema of the column associated with this writer.- Specified by:
schema
in interfaceColumnWriter
- Returns:
- schema for this writer's column
-
type
Description copied from interface:ColumnWriter
Return the object (structure) type of this writer.- Specified by:
type
in interfaceColumnWriter
- Returns:
- type indicating if this is a scalar, tuple or array
-
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.- Specified by:
nullable
in interfaceColumnWriter
- 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.- Specified by:
setNull
in interfaceColumnWriter
-
setObject
Description copied from interface:ColumnWriter
Generic technique to write data as a generic Java object. The type of the object must match the target writer. Primarily for testing.- Scalar: The type of the Java object must match the type of the target vector. String or byte[] can be used for Varchar vectors.
- Array: Write the array given an array of values. The object must be a Java array. The type of the array must match the type of element in the repeated vector. That is, if the vector is a Repeated Int, provide an int[] array.
- Tuple (map or row): The Java object must be an array of objects in which the members of the array have a 1:1 correspondence with the members of the tuple in the order defined by the writer metadata. That is, if the map is (Int, Varchar), provide a Object[] array like this: {10, "fred"}.
- Union: Uses the Java object type to determine the type of the backing vector. Creates a vector of the required type if needed.
- Specified by:
setObject
in interfaceColumnWriter
- Parameters:
value
- value to write to the vector. The Java type of the object indicates the Drill storage type
-
isProjected
public boolean isProjected()Description copied from interface:ColumnWriter
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. This flag handles those special cases where it is helpful to know if the column is projected or not.- Specified by:
isProjected
in interfaceColumnWriter
-
copy
Description copied from interface:ColumnWriter
Copy a single value from the given reader, which must be of the same type as this writer.- Specified by:
copy
in interfaceColumnWriter
- Parameters:
from
- reader to provide the data
-
dump
-
toString
-