Enum RecordBatch.IterOutcome

java.lang.Object
java.lang.Enum<RecordBatch.IterOutcome>
org.apache.drill.exec.record.RecordBatch.IterOutcome
All Implemented Interfaces:
Serializable, Comparable<RecordBatch.IterOutcome>
Enclosing interface:
RecordBatch

public static enum RecordBatch.IterOutcome extends Enum<RecordBatch.IterOutcome>
Describes the outcome of incrementing RecordBatch forward by a call to RecordBatch.next().

Key characteristics of the return value sequence:

  • OK_NEW_SCHEMA always appears unless STOP appears. (A batch returns OK_NEW_SCHEMA before returning NONE even if the batch has zero rows.)
  • OK_NEW_SCHEMA always appears before OK appears.
  • The last value is always NONE or STOP, and NONE and STOP appear only as the last value.

Details

For normal completion, the basic sequence of return values from calls to next() on a RecordBatch is:

  1. an OK_NEW_SCHEMA value followed by zero or more OK values,
  2. zero or more subsequences each having an OK_NEW_SCHEMA value followed by zero or more OK values, and then
  3. a NONE value.

In addition to that basic sequence, NOT_YET values can appear anywhere in the subsequence before the terminal value (NONE or STOP).

For abnormal termination, the sequence is truncated (before the NONE) and ends with an exception. That is, the sequence begins with a subsequence that is some prefix of a normal-completion sequence and that does not contain NONE, and ends with the caller throwing a (query-fatal) exception.

The normal-completion return sequence is matched by the following regular-expression-style grammar:

     ( NOT_YET*  OK_NEW_SCHEMA
       NOT_YET*  OK )*
     )+
     NOT_YET*    <exception>

Obsolete Outcomes

The former OUT_OF_MEMORY state was never really used. It is now handled by calling FragmentContext#requestMemory() at the point that the operator realizes it is short on memory.

The former STOP state was replaced with a "fail fast" approach that throws an exception when an error is detected.

  • Enum Constant Details

    • NONE

      public static final RecordBatch.IterOutcome NONE
      Normal completion of batch.

      The call to RecordBatch.next() read no records, the batch has and will have no more results to return, and next() must not be called again.

      This value will be returned only after OK_NEW_SCHEMA has been returned at least once (not necessarily immediately after).

      Also after a RecordBatch returns NONE a RecordBatch should:

      • Contain the last valid schema seen by the operator.
      • Contain a VectorContainer with empty columns corresponding to the last valid schema.
      • Return a record count of 0.

    • OK

      public static final RecordBatch.IterOutcome OK
      Zero or more records with same schema.

      The call to RecordBatch.next() read zero or more records, the schema has not changed since the last time OK_NEW_SCHEMA was returned, and the batch will have more results to return (at least completion or abnormal termination (NONE or STOP)). (next() should be called again.)

      This will be returned only after OK_NEW_SCHEMA has been returned at least once (not necessarily immediately after).

    • OK_NEW_SCHEMA

      public static final RecordBatch.IterOutcome OK_NEW_SCHEMA
      New schema, maybe with records.

      The call to RecordBatch.next() changed the schema and vector structures and read zero or more records, and the batch will have more results to return (at least completion or abnormal termination (NONE or STOP)). (next() should be called again.)

    • NOT_YET

      public static final RecordBatch.IterOutcome NOT_YET
      No data yet.

      The call to RecordBatch.next() read no data, and the batch will have more results to return in the future (at least completion or abnormal termination (NONE or STOP)). The caller should call next() again, but should do so later (including by returning NOT_YET to its caller).

      Normally, the caller should perform any locally available work while waiting for incoming data from the callee, for example, doing partial sorts on already received data while waiting for additional data to sort.

      Used by batches that haven't received incoming data yet.

    • EMIT

      public static final RecordBatch.IterOutcome EMIT
      Emit record to produce output batches.

      The call to RecordBatch.next(), read zero or more records with no change in schema as compared to last time. It is an indication from upstream operator to unblock and produce an output batch based on all the records current operator possess. The caller should return this outcome to it's downstream operators except LateralJoinRecordBatch, which will consume any EMIT from right branch but will pass through EMIT from left branch.

      Caller should produce one or more output record batch based on all the current data and restart fresh for any new input. If there are multiple output batches then caller should send EMIT only with last batch and OK with all previous batches. For example: Hash Join when received EMIT on build side will stop build side and call next() on probe side until it sees EMIT. On seeing EMIT from probe side, it should perform JOIN and produce output batches. Later it should clear all the data on both build and probe side of input and again start from build side.

  • Method Details

    • values

      public static RecordBatch.IterOutcome[] values()
      Returns an array containing the constants of this enum type, in the order they are declared.
      Returns:
      an array containing the constants of this enum type, in the order they are declared
    • valueOf

      public static RecordBatch.IterOutcome valueOf(String name)
      Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum type has no constant with the specified name
      NullPointerException - if the argument is null
    • isError

      public boolean isError()