IN - The type of the incoming elements.OUT - The type of elements emitted by the WindowFunction.W - The type of Window that the WindowAssigner assigns.public class NonKeyedWindowOperator<IN,OUT,W extends Window> extends AbstractUdfStreamOperator<OUT,AllWindowFunction<IN,OUT,W>> implements OneInputStreamOperator<IN,OUT>, Triggerable, org.apache.flink.api.java.typeutils.InputTypeConfigurable
WindowOperator,
Serialized Form| Modifier and Type | Class and Description |
|---|---|
protected class |
NonKeyedWindowOperator.Context
The
Context is responsible for keeping track of the state of one pane. |
| Modifier and Type | Field and Description |
|---|---|
protected long |
currentWatermark
To keep track of the current watermark so that we can immediately fire if a trigger
registers an event time callback for a timestamp that lies in the past.
|
protected TimestampedCollector<OUT> |
timestampedCollector
This is given to the
WindowFunction for emitting elements with a given timestamp. |
protected Map<W,NonKeyedWindowOperator.Context> |
windows
The windows (panes) that are currently in-flight.
|
userFunctionchainingStrategy, output| Constructor and Description |
|---|
NonKeyedWindowOperator(WindowAssigner<? super IN,W> windowAssigner,
TypeSerializer<W> windowSerializer,
WindowBufferFactory<? super IN,? extends WindowBuffer<IN>> windowBufferFactory,
AllWindowFunction<IN,OUT,W> windowFunction,
Trigger<? super IN,? super W> trigger)
Creates a new
WindowOperator based on the given policies and user functions. |
| Modifier and Type | Method and Description |
|---|---|
void |
close()
This method is called after all records have been added to the operators via the methods
OneInputStreamOperator.processElement(StreamRecord), or
TwoInputStreamOperator.processElement1(StreamRecord) and
TwoInputStreamOperator.processElement2(StreamRecord). |
protected void |
emitWindow(NonKeyedWindowOperator.Context context) |
NonKeyedWindowOperator<IN,OUT,W> |
enableSetProcessingTime(boolean setProcessingTime)
When this flag is enabled the current processing time is set as the timestamp of elements
upon arrival.
|
Trigger<? super IN,? super W> |
getTrigger() |
WindowAssigner<? super IN,W> |
getWindowAssigner() |
WindowBufferFactory<? super IN,? extends WindowBuffer<IN>> |
getWindowBufferFactory() |
boolean |
isSetProcessingTime() |
void |
open()
This method is called immediately before any elements are processed, it should contain the
operator's initialization logic.
|
void |
processElement(StreamRecord<IN> element)
Processes one element that arrived at this operator.
|
void |
processWatermark(Watermark mark)
Processes a
Watermark. |
void |
restoreState(StreamTaskState taskState)
Restores the operator state, if this operator's execution is recovering from a checkpoint.
|
void |
setInputType(TypeInformation<?> type,
ExecutionConfig executionConfig) |
StreamTaskState |
snapshotOperatorState(long checkpointId,
long timestamp)
Called to draw a state snapshot from the operator.
|
void |
trigger(long time)
This method is invoked with the timestamp for which the trigger was scheduled.
|
dispose, getUserFunction, getUserFunctionParameters, notifyOfCompletedCheckpoint, setOutputType, setupcreateKeyValueState, createKeyValueState, disableInputCopy, getChainingStrategy, getContainingTask, getExecutionConfig, getOperatorConfig, getRuntimeContext, getStateBackend, getUserCodeClassloader, isInputCopyingDisabled, registerTimer, setChainingStrategy, setKeyContext, setKeyContextElementclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitdispose, getChainingStrategy, isInputCopyingDisabled, notifyOfCompletedCheckpoint, setChainingStrategy, setKeyContextElement, setupprotected transient TimestampedCollector<OUT> timestampedCollector
WindowFunction for emitting elements with a given timestamp.protected transient long currentWatermark
protected transient Map<W extends Window,NonKeyedWindowOperator.Context> windows
WindowBuffer
and a TriggerContext that stores the Trigger for that pane.public NonKeyedWindowOperator(WindowAssigner<? super IN,W> windowAssigner, TypeSerializer<W> windowSerializer, WindowBufferFactory<? super IN,? extends WindowBuffer<IN>> windowBufferFactory, AllWindowFunction<IN,OUT,W> windowFunction, Trigger<? super IN,? super W> trigger)
WindowOperator based on the given policies and user functions.public final void setInputType(TypeInformation<?> type, ExecutionConfig executionConfig)
setInputType in interface org.apache.flink.api.java.typeutils.InputTypeConfigurablepublic final void open()
throws Exception
AbstractStreamOperatorThe default implementation does nothing.
open in interface StreamOperator<OUT>open in class AbstractUdfStreamOperator<OUT,AllWindowFunction<IN,OUT,W extends Window>>Exception - An exception in this method causes the operator to fail.public final void close()
throws Exception
AbstractStreamOperatorOneInputStreamOperator.processElement(StreamRecord), or
TwoInputStreamOperator.processElement1(StreamRecord) and
TwoInputStreamOperator.processElement2(StreamRecord).
The method is expected to flush all remaining buffered data. Exceptions during this flushing of buffered should be propagated, in order to cause the operation to be recognized asa failed, because the last data items are not processed properly.
close in interface StreamOperator<OUT>close in class AbstractUdfStreamOperator<OUT,AllWindowFunction<IN,OUT,W extends Window>>Exception - An exception in this method causes the operator to fail.public final void processElement(StreamRecord<IN> element) throws Exception
OneInputStreamOperatorprocessElement in interface OneInputStreamOperator<IN,OUT>Exceptionprotected void emitWindow(NonKeyedWindowOperator.Context context) throws Exception
Exceptionpublic final void processWatermark(Watermark mark) throws Exception
OneInputStreamOperatorWatermark.
This method is guaranteed to not be called concurrently with other methods of the operator.processWatermark in interface OneInputStreamOperator<IN,OUT>ExceptionWatermarkpublic final void trigger(long time)
throws Exception
TriggerableIf the triggering is delayed for whatever reason (trigger timer was blocked, JVM stalled due to a garbage collection), the timestamp supplied to this function will still be the original timestamp for which the trigger was scheduled.
trigger in interface Triggerabletime - The timestamp for which the trigger event was scheduled.Exceptionpublic NonKeyedWindowOperator<IN,OUT,W> enableSetProcessingTime(boolean setProcessingTime)
TimeEvictor with processing
time semantics.public StreamTaskState snapshotOperatorState(long checkpointId, long timestamp) throws Exception
StreamOperatorsnapshotOperatorState in interface StreamOperator<OUT>snapshotOperatorState in class AbstractUdfStreamOperator<OUT,AllWindowFunction<IN,OUT,W extends Window>>checkpointId - The ID of the checkpoint.timestamp - The timestamp of the checkpoint.Exception - Forwards exceptions that occur while drawing snapshots from the operator
and the key/value state.public void restoreState(StreamTaskState taskState) throws Exception
StreamOperatorThis method is called after StreamOperator.setup(StreamTask, StreamConfig, Output)
and before StreamOperator.open().
restoreState in interface StreamOperator<OUT>restoreState in class AbstractUdfStreamOperator<OUT,AllWindowFunction<IN,OUT,W extends Window>>taskState - The state of operator that was snapshotted as part of checkpoint
from which the execution is restored.Exception - Exceptions during state restore should be forwarded, so that the system can
properly react to failed state restore and fail the execution attempt.public boolean isSetProcessingTime()
public WindowAssigner<? super IN,W> getWindowAssigner()
public WindowBufferFactory<? super IN,? extends WindowBuffer<IN>> getWindowBufferFactory()
Copyright © 2014–2016 The Apache Software Foundation. All rights reserved.