Class RowSetWriterImpl

java.lang.Object
org.apache.drill.exec.vector.accessor.writer.AbstractTupleWriter
org.apache.drill.exec.physical.rowSet.RowSetWriterImpl
All Implemented Interfaces:
RowSetWriter, ColumnWriter, TupleWriter, WriterEvents, WriterPosition

public class RowSetWriterImpl extends AbstractTupleWriter implements RowSetWriter
Implementation of a row set writer. Only available for newly-created, empty, direct, single row sets. Rewriting is not allowed, nor is writing to a hyper row set.
  • Constructor Details

  • Method Details

    • addRow

      public RowSetWriter addRow(Object... values)
      Description copied from interface: RowSetWriter
      Write a row of values, given by Java objects. Object type must match expected column type. Stops writing, and returns false, if any value causes vector overflow. Value format:
      • For scalars, the value as a suitable Java type (int or Integer, say, for INTEGER values.)
      • For scalar arrays, an array of a suitable Java primitive type for scalars. For example, int[] for an INTEGER column.
      • For a Map, an Object array with values encoded as above. (In fact, the list here is the same as the map format.
      • For a list (repeated map, list of list), an Object array with values encoded as above. (So, for a repeated map, an outer Object map encodes the array, an inner one encodes the map members.
      Specified by:
      addRow in interface RowSetWriter
      Parameters:
      values - variable-length argument list of column values
    • addSingleCol

      public RowSetWriter addSingleCol(Object value)
      Specified by:
      addSingleCol in interface RowSetWriter
    • rowIndex

      public int rowIndex()
      Specified by:
      rowIndex in interface RowSetWriter
    • save

      public void save()
      Description copied from interface: RowSetWriter
      Saves the current row and moves to the next row. Done automatically if using setRow().
      Specified by:
      save in interface RowSetWriter
    • isFull

      public boolean isFull()
      Description copied from interface: RowSetWriter
      Indicates if the current row position is valid for writing. Will be false on the first row, and all subsequent rows until either the maximum number of rows are written, or a vector overflows. After that, will return true. The method returns false as soon as any column writer overflows even in the middle of a row write. That is, this writer does not automatically handle overflow rows because that added complexity is seldom needed for tests.
      Specified by:
      isFull in interface RowSetWriter
      Returns:
      true if the current row can be written, false if not
    • done

      public RowSet.SingleRowSet done()
      Description copied from interface: RowSetWriter
      Finish writing and finalize the row set being written.
      Specified by:
      done in interface RowSetWriter
      Returns:
      the completed, read-only row set without a selection vector
    • lastWriteIndex

      public int lastWriteIndex()
      Description copied from interface: WriterPosition
      Return the last write position in the vector. This may be the same as the writer index position (if the vector was written at that point), or an earlier point. In either case, this value points to the last valid value in the vector.
      Specified by:
      lastWriteIndex in interface WriterPosition
      Overrides:
      lastWriteIndex in class AbstractTupleWriter
      Returns:
      index of the last valid value in the vector
    • 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