Interface ArrayWriter

All Superinterfaces:
ColumnWriter
All Known Subinterfaces:
DictWriter
All Known Implementing Classes:
AbstractArrayWriter, AbstractArrayWriter.BaseArrayWriter, DummyArrayWriter, DummyDictWriter, ListWriterImpl, ObjectArrayWriter, ObjectDictWriter, RepeatedListWriter, ScalarArrayWriter

public interface ArrayWriter extends ColumnWriter
Writer for values into an array. Array writes are write-once, sequential: each call to a setFoo() method writes a value and advances the array index.

The array writer represents a Drill repeated type, including repeated maps. The array writer also represents the Drill list and repeated list types as follows:

  • A repeated scalar type is presented as an array writer with scalar entries. As a convenience, writing to the scalar automatically advances the current array write position, since exactly one item can be written per array entry.
  • A repeated map type is presented as an array writer with tuple entries. The client must advance the array write position explicitly since a tuple can have any number of entries and the array writer cannot determine when a value is complete.
  • A list type is presented as an array of variant entries. The client must explicitly advance the array position.
  • A repeated list type is presented as an array of arrays of variants. The client advances the array position of both lists.
  • Lists of repeated lists have three levels of arrays, repeated lists of repeated lists have four levels of arrays, and so on.

Although the list vector supports a union of any Drill type, the only sane combinations are:

  • One of a (single or repeated) (map or list), or
  • One or more scalar type.
If a particular array has only one type (single/repeated map/list), then, for convenience, the caller can directly request a writer of that type without having to first retrieve the variant (although the indirect route is, of course, available.)
See Also:
  • Method Details

    • size

      int size()
      Number of elements written thus far to the array.
      Returns:
      the number of elements
    • entryType

      ObjectType entryType()
      Return a generic object writer for the array entry.
      Returns:
      generic object reader
    • setNull

      void setNull(boolean isNull)
    • entry

      ObjectWriter entry()
      The object type of the list entry. All entries have the same type.
      Returns:
      the object type of each entry
    • scalar

      ScalarWriter scalar()
    • tuple

      TupleWriter tuple()
    • array

      ArrayWriter array()
    • variant

      VariantWriter variant()
    • dict

      DictWriter dict()
    • save

      void save()
      When the array contains a tuple or an array, call save() after each array value. Not necessary when writing scalars; each set operation calls save automatically.