Interface VariantReader

All Superinterfaces:
ColumnReader
All Known Implementing Classes:
UnionReaderImpl

public interface VariantReader extends ColumnReader
Reader for a Drill "union vector." The union vector is presented as a reader over a set of variants. In the old Visual Basic world, "the Variant data type is a tagged union that can be used to represent any other data type." The term is used here to avoid confusion with the "union operator" which is something entirely different.

At read time, the set of possible types is fixed. A request to obtain a reader for an unused type returns a null pointer.

This reader is essentially a map of types: it allows access to type-specific readers for the set of types supported in the current vector. A client checks the type of each value, then uses the proper type-specific reader to access that value.

  • Method Details

    • variantSchema

      VariantMetadata variantSchema()
    • size

      int size()
    • hasType

      boolean hasType(TypeProtos.MinorType type)
      Determine if a given type is supported by the union vector for some value in the result set.
      Parameters:
      type - the Drill minor type to query
      Returns:
      true if a reader for the given type is available, false if a request for a reader of that type will return null.
    • member

      Return the member reader for the given type. The type must be a member of the union. Allows caching readers across rows.
      Parameters:
      type - member type
      Returns:
      reader for that type
    • scalar

      Return the scalar reader for the given type member. The type must be a member of the union. Allows caching readers across rows. Identical to:
      >member(type).scalar()
      Parameters:
      type - member type
      Returns:
      scalar reader for that type
    • dataType

      Return the data type of the current value. (What happens if the row is null, must it be a null of some type?)
      Returns:
      data type of the current data value
    • member

      ObjectReader member()
      Return the reader for the member type of the current row. Same as:
      member(dataType())
      Returns:
      reader for the member type of the current row.
    • scalar

      ScalarReader scalar()
      Return the appropriate scalar reader for the current value.
      Returns:
      null if ColumnReader.isNull() returns true, else the equivalent of scalar( dataType() )
      Throws:
      IllegalStateException - if called for a variant that holds a tuple or an array
    • tuple

      TupleReader tuple()
    • array

      ArrayReader array()