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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionarray()voidcopy(ColumnReader from) Copy a single value from the given reader, which must be of the same type as this writer.dict()abstract voiddump(HierarchicalFormatter format) abstract WriterEventsevents()The internal state behind this writer.booleanWhether 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.booleannullable()Whether this writer allows nulls.scalar()schema()Returns the schema of the column associated with this writer.voidsetNull()Set the current value to null.voidGeneric 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, waitMethods inherited from interface org.apache.drill.exec.vector.accessor.ObjectWriter
writer
-
Constructor Details
-
AbstractObjectWriter
public AbstractObjectWriter()
-
-
Method Details
-
scalar
- Specified by:
scalarin interfaceObjectWriter
-
tuple
- Specified by:
tuplein interfaceObjectWriter
-
array
- Specified by:
arrayin interfaceObjectWriter
-
variant
- Specified by:
variantin interfaceObjectWriter
-
dict
- Specified by:
dictin interfaceObjectWriter
-
events
Description copied from interface:ObjectWriterThe internal state behind this writer. To be used only by the implementation, not by the client.- Specified by:
eventsin interfaceObjectWriter
-
schema
Description copied from interface:ColumnWriterReturns the schema of the column associated with this writer.- Specified by:
schemain interfaceColumnWriter- Returns:
- schema for this writer's column
-
type
Description copied from interface:ColumnWriterReturn the object (structure) type of this writer.- Specified by:
typein interfaceColumnWriter- Returns:
- type indicating if this is a scalar, tuple or array
-
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.- Specified by:
nullablein interfaceColumnWriter- 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.- Specified by:
setNullin interfaceColumnWriter
-
setObject
Description copied from interface:ColumnWriterGeneric 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:
setObjectin 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:ColumnWriterWhether 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:
isProjectedin interfaceColumnWriter
-
copy
Description copied from interface:ColumnWriterCopy a single value from the given reader, which must be of the same type as this writer.- Specified by:
copyin interfaceColumnWriter- Parameters:
from- reader to provide the data
-
dump
-
toString
-