Interface PullResultSetReader

All Known Implementing Classes:
PullResultSetReaderImpl

public interface PullResultSetReader
Iterates over the set of batches in a result set, providing a row set reader to iterate over the rows within each batch. Handles schema changes between batches. A typical use is to iterate over batches from an upstream operator. Protocol:

Protocol

  1. Create an instance.
  2. For each incoming batch:
    1. Call #start() to attach the batch. The associated BatchAccessor reports if the schema has changed.
    2. Call reader() to obtain a reader.
    3. Iterate over the batch using the reader.
    4. Call #release() to free the memory for the incoming batch. Or, to call #detach() to keep the batch memory.
  3. Call close() after all batches are read.
  • Create the result set reader via a specific subclass. If a query has a null result (no rows, no schema), the code which creates this class should instead indicate that no results are available. This class is only for the cases
  • Call schema(), if desired, to obtain the schema for this result set.
  • Call next() to advance to the first batch.
  • If next() returns true, then call reader() to obtain a reader over rows. This reader also provides the batch schema.
  • Use the reader to iterate over rows in the batch.
  • Call next() to advance to the next batch and repeat.

The implementation may perform complex tasks behind the scenes: coordinate with the query runner (if remote), drive an operator (if within a DAG), etc. The implementation takes an interface that interfaces with the source of batches.

Designed to handle batches arriving from a single upstream operator. Uses Drill's strict form of schema identity: that not only must the column definitions match; the vectors must be identical from one batch to the next. If the vectors differ, then this class assumes a new schema has occurred, and will rebuild all the underlying readers, which can be costly.

  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Close this reader.
    boolean
    Advance to the next batch of data.
    Obtain a reader to iterate over the rows of the batch.
    Return the schema for this result set.
    int
     
  • Method Details

    • next

      boolean next()
      Advance to the next batch of data. The iterator starts positioned before the first batch (but after obtaining a schema.)
      Returns:
      true if another batch is available, false if EOF
    • schema

      TupleMetadata schema()
      Return the schema for this result set.
    • schemaVersion

      int schemaVersion()
    • reader

      RowSetReader reader()
      Obtain a reader to iterate over the rows of the batch. The return value will likely be the same reader each time, so that this call is optional after the first batch.
    • close

      void close()
      Close this reader. Releases any memory still assigned to any attached batch. Call #detach() first if you want to preserve the batch memory.