Class UnorderedStreamElementQueue<OUT>

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

@Internal public final class UnorderedStreamElementQueue<OUT> extends Object implements StreamElementQueue<OUT>
Unordered implementation of the StreamElementQueue. The unordered stream element queue provides asynchronous results as soon as they are completed. Additionally, it maintains the watermark-stream record order.

Elements can be logically grouped into different segments separated by watermarks. A segment needs to be completely emitted before entries from a following segment are emitted. Thus, no stream record can be overtaken by a watermark and no watermark can overtake a stream record. However, stream records falling in the same segment between two watermarks can overtake each other (their emission order is not guaranteed).

  • 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

    • UnorderedStreamElementQueue

      public UnorderedStreamElementQueue(int capacity)
  • Method Details

    • 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.
    • 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.