public class WindowOperator.Context extends Object implements Trigger.OnMergeContext
Context
is a utility for handling Trigger
invocations. It can be reused by
setting the key
and window
fields. No internal state must be kept in the
Context
Modifier and Type | Field and Description |
---|---|
protected K |
key |
protected Collection<W> |
mergedWindows |
protected W |
window |
Modifier and Type | Method and Description |
---|---|
void |
clear() |
void |
deleteEventTimeTimer(long time)
Delete the event-time trigger for the given time.
|
void |
deleteProcessingTimeTimer(long time)
Delete the processing time trigger for the given time.
|
long |
getCurrentProcessingTime()
Returns the current processing time.
|
long |
getCurrentWatermark()
Returns the current watermark time.
|
<S extends Serializable> |
getKeyValueState(String name,
Class<S> stateType,
S defaultState)
Retrieves a
ValueState object that can be used to interact with fault-tolerant
state that is scoped to the window and key of the current trigger invocation. |
<S extends Serializable> |
getKeyValueState(String name,
TypeInformation<S> stateType,
S defaultState)
Retrieves a
ValueState object that can be used to interact with fault-tolerant
state that is scoped to the window and key of the current trigger invocation. |
MetricGroup |
getMetricGroup()
Returns the metric group for this
Trigger . |
<S extends State> |
getPartitionedState(StateDescriptor<S,?> stateDescriptor)
Retrieves a
State object that can be used to interact with fault-tolerant state
that is scoped to the window and key of the current trigger invocation. |
<S extends MergingState<?,?>> |
mergePartitionedState(StateDescriptor<S,?> stateDescriptor) |
TriggerResult |
onElement(StreamRecord<IN> element) |
TriggerResult |
onEventTime(long time) |
void |
onMerge(Collection<W> mergedWindows) |
TriggerResult |
onProcessingTime(long time) |
void |
registerEventTimeTimer(long time)
Register an event-time callback.
|
void |
registerProcessingTimeTimer(long time)
Register a system time callback.
|
String |
toString() |
protected K key
protected Collection<W extends Window> mergedWindows
public MetricGroup getMetricGroup()
Trigger.TriggerContext
Trigger
. This is the same metric group that
would be returned from RuntimeContext.getMetricGroup()
in a user function.
You must not call methods that create metric objects (such as MetricGroup.counter(int)
multiple times but instead call once and store the metric
object in a field.
getMetricGroup
in interface Trigger.TriggerContext
public long getCurrentWatermark()
Trigger.TriggerContext
getCurrentWatermark
in interface Trigger.TriggerContext
public <S extends Serializable> ValueState<S> getKeyValueState(String name, Class<S> stateType, S defaultState)
Trigger.TriggerContext
ValueState
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.TriggerContext
S
- The type of the state.name
- The name of the key/value state.stateType
- The class of the type that is stored in the state. Used to generate
serializers for managed memory and checkpointing.defaultState
- The default state value, returned when the state is accessed and no
value has yet been set for the key. May be null.public <S extends Serializable> ValueState<S> getKeyValueState(String name, TypeInformation<S> stateType, S defaultState)
Trigger.TriggerContext
ValueState
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.TriggerContext
S
- The type of the state.name
- The name of the key/value state.stateType
- The type information for the type that is stored in the state. Used to
create serializers for managed memory and checkpoints.defaultState
- The default state value, returned when the state is accessed and no
value has yet been set for the key. May be null.public <S extends State> S getPartitionedState(StateDescriptor<S,?> stateDescriptor)
Trigger.TriggerContext
State
object that can be used to interact with fault-tolerant state
that is scoped to the window and key of the current trigger invocation.getPartitionedState
in interface Trigger.TriggerContext
S
- The type of the state.stateDescriptor
- The StateDescriptor that contains the name and type of the state
that is being accessed.public <S extends MergingState<?,?>> void mergePartitionedState(StateDescriptor<S,?> stateDescriptor)
mergePartitionedState
in interface Trigger.OnMergeContext
public long getCurrentProcessingTime()
Trigger.TriggerContext
getCurrentProcessingTime
in interface Trigger.TriggerContext
public void registerProcessingTimeTimer(long time)
Trigger.TriggerContext
Trigger.onProcessingTime(long, Window, TriggerContext)
is called with the time
specified here.registerProcessingTimeTimer
in interface Trigger.TriggerContext
time
- The time at which to invoke Trigger.onProcessingTime(long, Window,
TriggerContext)
public void registerEventTimeTimer(long time)
Trigger.TriggerContext
Trigger.onEventTime(long, Window, TriggerContext)
is called with the time
specified here.registerEventTimeTimer
in interface Trigger.TriggerContext
time
- The watermark at which to invoke Trigger.onEventTime(long, Window,
TriggerContext)
Watermark
public void deleteProcessingTimeTimer(long time)
Trigger.TriggerContext
deleteProcessingTimeTimer
in interface Trigger.TriggerContext
public void deleteEventTimeTimer(long time)
Trigger.TriggerContext
deleteEventTimeTimer
in interface Trigger.TriggerContext
public TriggerResult onElement(StreamRecord<IN> element) throws Exception
Exception
public TriggerResult onProcessingTime(long time) throws Exception
Exception
public TriggerResult onEventTime(long time) throws Exception
Exception
public void onMerge(Collection<W> mergedWindows) throws Exception
Exception
Copyright © 2014–2023 The Apache Software Foundation. All rights reserved.