Interface TupleWriter

All Superinterfaces:
ColumnWriter
All Known Subinterfaces:
RowSetLoader, RowSetWriter
All Known Implementing Classes:
AbstractTupleWriter, DictEntryWriter, MapWriter, MapWriter.ArrayMapWriter, MapWriter.DummyArrayMapWriter, MapWriter.DummyMapWriter, MapWriter.SingleMapWriter, RowSetLoaderImpl, RowSetWriterImpl

public interface TupleWriter extends ColumnWriter
Writer for a tuple. A tuple is composed of columns with a fixed order and unique names: either can be used to reference columns. Columns are scalar (simple values), tuples (i.e. maps), or arrays (of scalars, tuples or arrays.) The row itself is just the top-level (anonymous) tuple. Generally, implementers of this interface provide additional services on the implementation of the top-level tuple (often called a "row writer.") Columns are accessible via the associated column writer by name or index. Column indexes are defined by the tuple schema.

Consumers of this interface can define the schema up front, or can define the schema as the write progresses. To avoid redundant checks to see if a column is already defined, consumers can simply ask for a column by name. The column() (and related) methods will throw an (unchecked) TupleWriter.UndefinedColumnException exception if the column is undefined. The consumer can catch the exception, define the column, and fetch the column writer again. New columns may be added via this interface at any time; the new column takes the next available index.

Also provides a convenience method to set the column value from a Java object. The caller is responsible for providing the correct object type for each column. (The object type must match the column accessor type.)

Convenience methods allow getting a column as a scalar, tuple or array. These methods throw an exception if the column is not of the requested type.

  • Method Details Link icon

    • isProjected Link icon

      boolean isProjected(String columnName)
      Reports whether the given column is projected. Useful for clients that can simply skip over unprojected columns.
    • addColumn Link icon

      int addColumn(ColumnMetadata column)
      Add a column to the tuple (row or map) that backs this writer. Support for this operation depends on whether the client code has registered a listener to implement the addition. Throws an exception if no listener is implemented, or if the add request is otherwise invalid (duplicate name, etc.)
      Parameters:
      column - the metadata for the column to add
      Returns:
      the index of the newly added column which can be used to access the newly added writer
    • addColumn Link icon

      int addColumn(MaterializedField schema)
    • tupleSchema Link icon

      TupleMetadata tupleSchema()
    • size Link icon

      int size()
    • column Link icon

      ObjectWriter column(int colIndex)
    • column Link icon

      ObjectWriter column(String colName)
    • scalar Link icon

      ScalarWriter scalar(int colIndex)
    • scalar Link icon

      ScalarWriter scalar(String colName)
    • tuple Link icon

      TupleWriter tuple(int colIndex)
    • tuple Link icon

      TupleWriter tuple(String colName)
    • array Link icon

      ArrayWriter array(int colIndex)
    • array Link icon

      ArrayWriter array(String colName)
    • variant Link icon

      VariantWriter variant(int colIndex)
    • variant Link icon

      VariantWriter variant(String colName)
    • dict Link icon

      DictWriter dict(int colIndex)
    • dict Link icon

      DictWriter dict(String colName)
    • type Link icon

      ObjectType type(int colIndex)
    • type Link icon

      ObjectType type(String colName)
    • set Link icon

      void set(int colIndex, Object value)
      Write a value to the given column, automatically calling the proper setType method for the data. While this method is convenient for testing, it incurs quite a bit of type-checking overhead and is not suitable for production code.
      Parameters:
      colIndex - the index of the column to set
      value - the value to set. The type of the object must be compatible with the type of the target column