protected class WindowOperator.Context extends Object implements Trigger.TriggerContext
Context is responsible for keeping track of the state of one pane.
A pane is the bucket of elements that have the same key (assigned by the
KeySelector) and same Window. An element can
be in multiple panes of it was assigned to multiple windows by the
WindowAssigner. These panes all
have their own instance of the Trigger.
| Modifier and Type | Field and Description |
|---|---|
protected K |
key |
protected long |
processingTimeTimer |
protected HashMap<String,Serializable> |
state |
protected long |
watermarkTimer |
protected W |
window |
protected WindowBuffer<IN> |
windowBuffer |
| Modifier | Constructor and Description |
|---|---|
protected |
WindowOperator.Context(DataInputView in,
ClassLoader userClassloader)
Constructs a new
Context by reading from a DataInputView that
contains a serialized context that we wrote in
writeToState(StateBackend.CheckpointStateOutputView) |
|
WindowOperator.Context(K key,
W window,
WindowBuffer<IN> windowBuffer) |
| Modifier and Type | Method and Description |
|---|---|
<S extends Serializable> |
getKeyValueState(String name,
S defaultState)
Retrieves an
OperatorState object that can be used to interact with
fault-tolerant state that is scoped to the window and key of the current
trigger invocation. |
Trigger.TriggerResult |
onElement(StreamRecord<IN> element) |
Trigger.TriggerResult |
onEventTime(long time) |
Trigger.TriggerResult |
onProcessingTime(long time) |
void |
registerEventTimeTimer(long time)
Register an event-time callback.
|
void |
registerProcessingTimeTimer(long time)
Register a system time callback.
|
protected void |
writeToState(StateBackend.CheckpointStateOutputView out)
Writes the
Context to the given state checkpoint output. |
protected K key
protected WindowBuffer<IN> windowBuffer
protected HashMap<String,Serializable> state
protected long watermarkTimer
protected long processingTimeTimer
public WindowOperator.Context(K key, W window, WindowBuffer<IN> windowBuffer)
protected WindowOperator.Context(DataInputView in, ClassLoader userClassloader) throws Exception
Context by reading from a DataInputView that
contains a serialized context that we wrote in
writeToState(StateBackend.CheckpointStateOutputView)Exceptionprotected void writeToState(StateBackend.CheckpointStateOutputView out) throws IOException
Context to the given state checkpoint output.IOExceptionpublic <S extends Serializable> OperatorState<S> getKeyValueState(String name, S defaultState)
Trigger.TriggerContextOperatorState object that can be used to interact with
fault-tolerant state that is scoped to the window and key of the current
trigger invocation.getKeyValueState in interface Trigger.TriggerContextname - A unique key for the state.defaultState - The default value of the state.public void registerProcessingTimeTimer(long time)
Trigger.TriggerContextTrigger.onProcessingTime(long, Window, TriggerContext) is called with the time specified here.registerProcessingTimeTimer in interface Trigger.TriggerContexttime - The time at which to invoke Trigger.onProcessingTime(long, Window, TriggerContext)public void registerEventTimeTimer(long time)
Trigger.TriggerContextTrigger.onEventTime(long, Window, TriggerContext) is called with the time specified here.registerEventTimeTimer in interface Trigger.TriggerContexttime - The watermark at which to invoke Trigger.onEventTime(long, Window, TriggerContext)Watermarkpublic Trigger.TriggerResult onElement(StreamRecord<IN> element) throws Exception
Exceptionpublic Trigger.TriggerResult onProcessingTime(long time) throws Exception
Exceptionpublic Trigger.TriggerResult onEventTime(long time) throws Exception
ExceptionCopyright © 2014–2016 The Apache Software Foundation. All rights reserved.