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 theStreamElementQueue. 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 UnorderedStreamElementQueue(int capacity)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidemitCompletedElement(org.apache.flink.streaming.api.operators.TimestampedCollector<OUT> output)Emits one completed element from the head of this queue into the given output.booleanhasCompletedElements()Checks if there is at least one completed head element.booleanisEmpty()True if the queue is empty; otherwise false.intsize()Return the size of the queue.Optional<ResultFuture<OUT>>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>values()Returns the collection ofStreamElementcurrently contained in this queue for checkpointing.
-
-
-
Method Detail
-
tryPut
public Optional<ResultFuture<OUT>> tryPut(org.apache.flink.streaming.runtime.streamrecord.StreamElement streamElement)
Description copied from interface:StreamElementQueueTries 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:
tryPutin interfaceStreamElementQueue<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:StreamElementQueueChecks if there is at least one completed head element.- Specified by:
hasCompletedElementsin interfaceStreamElementQueue<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:StreamElementQueueEmits 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:
emitCompletedElementin interfaceStreamElementQueue<OUT>- Parameters:
output- the output into which to emit
-
values
public List<org.apache.flink.streaming.runtime.streamrecord.StreamElement> values()
Description copied from interface:StreamElementQueueReturns the collection ofStreamElementcurrently contained in this queue for checkpointing.This includes all non-emitted, completed and non-completed elements.
- Specified by:
valuesin interfaceStreamElementQueue<OUT>- Returns:
- List of currently contained
StreamElement.
-
isEmpty
public boolean isEmpty()
Description copied from interface:StreamElementQueueTrue if the queue is empty; otherwise false.- Specified by:
isEmptyin interfaceStreamElementQueue<OUT>- Returns:
- True if the queue is empty; otherwise false.
-
size
public int size()
Description copied from interface:StreamElementQueueReturn the size of the queue.- Specified by:
sizein interfaceStreamElementQueue<OUT>- Returns:
- The number of elements contained in this queue.
-
-