Class OrderedStreamElementQueue<OUT>

java.lang.Object
org.apache.flink.streaming.api.operators.async.queue.OrderedStreamElementQueue<OUT>
All Implemented Interfaces:
StreamElementQueue<OUT>

@Internal public final class OrderedStreamElementQueue<OUT> extends Object implements StreamElementQueue<OUT>
Ordered StreamElementQueue implementation. The ordered stream element queue provides asynchronous results in the order in which the StreamElementQueueEntry have been added to the queue. Thus, even if the completion order can be arbitrary, the output order strictly follows the insertion order (element cannot overtake each other).
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    emitCompletedElement(org.apache.flink.streaming.api.operators.TimestampedCollector<OUT> output)
    Emits one completed element from the head of this queue into the given output.
    boolean
    Checks if there is at least one completed head element.
    boolean
    True if the queue is empty; otherwise false.
    int
    Return the size of the queue.
    tryPut(org.apache.flink.streaming.runtime.streamrecord.StreamElement streamElement)
    Tries to put the given element in the queue.
    List<org.apache.flink.streaming.runtime.streamrecord.StreamElement>
    Returns the collection of StreamElement currently contained in this queue for checkpointing.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • OrderedStreamElementQueue

      public OrderedStreamElementQueue(int capacity)
  • Method Details

    • hasCompletedElements

      public boolean hasCompletedElements()
      Description copied from interface: StreamElementQueue
      Checks if there is at least one completed head element.
      Specified by:
      hasCompletedElements in interface StreamElementQueue<OUT>
      Returns:
      True if there is a completed head element.
    • emitCompletedElement

      public void emitCompletedElement(org.apache.flink.streaming.api.operators.TimestampedCollector<OUT> output)
      Description copied from interface: StreamElementQueue
      Emits one completed element from the head of this queue into the given output.

      Will not emit any element if no element has been completed (check StreamElementQueue.hasCompletedElements() before entering any critical section).

      Specified by:
      emitCompletedElement in interface StreamElementQueue<OUT>
      Parameters:
      output - the output into which to emit
    • values

      public List<org.apache.flink.streaming.runtime.streamrecord.StreamElement> values()
      Description copied from interface: StreamElementQueue
      Returns the collection of StreamElement currently contained in this queue for checkpointing.

      This includes all non-emitted, completed and non-completed elements.

      Specified by:
      values in interface StreamElementQueue<OUT>
      Returns:
      List of currently contained StreamElement.
    • isEmpty

      public boolean isEmpty()
      Description copied from interface: StreamElementQueue
      True if the queue is empty; otherwise false.
      Specified by:
      isEmpty in interface StreamElementQueue<OUT>
      Returns:
      True if the queue is empty; otherwise false.
    • size

      public int size()
      Description copied from interface: StreamElementQueue
      Return the size of the queue.
      Specified by:
      size in interface StreamElementQueue<OUT>
      Returns:
      The number of elements contained in this queue.
    • tryPut

      public Optional<ResultFuture<OUT>> tryPut(org.apache.flink.streaming.runtime.streamrecord.StreamElement streamElement)
      Description copied from interface: StreamElementQueue
      Tries to put the given element in the queue. This operation succeeds if the queue has capacity left and fails if the queue is full.

      This method returns a handle to the inserted element that allows to set the result of the computation.

      Specified by:
      tryPut in interface StreamElementQueue<OUT>
      Parameters:
      streamElement - the element to be inserted.
      Returns:
      A handle to the element if successful or Optional.empty() otherwise.