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

public abstract class AbstractObjectWriter extends Object implements ObjectWriter
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 Details

    • AbstractObjectWriter

      public AbstractObjectWriter()
  • Method Details

    • scalar

      public ScalarWriter scalar()
      Specified by:
      scalar in interface ObjectWriter
    • tuple

      public TupleWriter tuple()
      Specified by:
      tuple in interface ObjectWriter
    • array

      public ArrayWriter array()
      Specified by:
      array in interface ObjectWriter
    • variant

      public VariantWriter variant()
      Specified by:
      variant in interface ObjectWriter
    • dict

      public DictWriter dict()
      Specified by:
      dict in interface ObjectWriter
    • events

      public abstract WriterEvents 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 interface ObjectWriter
    • schema

      public ColumnMetadata schema()
      Description copied from interface: ColumnWriter
      Returns the schema of the column associated with this writer.
      Specified by:
      schema in interface ColumnWriter
      Returns:
      schema for this writer's column
    • type

      public ObjectType type()
      Description copied from interface: ColumnWriter
      Return the object (structure) type of this writer.
      Specified by:
      type in interface ColumnWriter
      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 the 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.
      Specified by:
      nullable in interface ColumnWriter
      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 interface ColumnWriter
    • setObject

      public void setObject(Object value)
      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 interface ColumnWriter
      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 interface ColumnWriter
    • copy

      public void copy(ColumnReader from)
      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 interface ColumnWriter
      Parameters:
      from - reader to provide the data
    • dump

      public abstract void dump(HierarchicalFormatter format)
    • toString

      public String toString()
      Overrides:
      toString in class Object