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| 限定符和类型 | 字段和说明 |
|---|---|
protected K |
key |
protected Collection<W> |
mergedWindows |
protected W |
window |
| 限定符和类型 | 方法和说明 |
|---|---|
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,
org.apache.flink.api.common.typeinfo.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. |
org.apache.flink.metrics.MetricGroup |
getMetricGroup()
Returns the metric group for this
Trigger. |
<S extends org.apache.flink.api.common.state.State> |
getPartitionedState(org.apache.flink.api.common.state.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 org.apache.flink.api.common.state.MergingState<?,?>> |
mergePartitionedState(org.apache.flink.api.common.state.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 org.apache.flink.metrics.MetricGroup getMetricGroup()
Trigger.TriggerContextTrigger. 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 在接口中 Trigger.TriggerContextpublic long getCurrentWatermark()
Trigger.TriggerContextgetCurrentWatermark 在接口中 Trigger.TriggerContextpublic <S extends Serializable> org.apache.flink.api.common.state.ValueState<S> getKeyValueState(String name, Class<S> stateType, S defaultState)
Trigger.TriggerContextValueState 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 在接口中 Trigger.TriggerContextS - 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> org.apache.flink.api.common.state.ValueState<S> getKeyValueState(String name, org.apache.flink.api.common.typeinfo.TypeInformation<S> stateType, S defaultState)
Trigger.TriggerContextValueState 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 在接口中 Trigger.TriggerContextS - 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 org.apache.flink.api.common.state.State> S getPartitionedState(org.apache.flink.api.common.state.StateDescriptor<S,?> stateDescriptor)
Trigger.TriggerContextState 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 在接口中 Trigger.TriggerContextS - The type of the state.stateDescriptor - The StateDescriptor that contains the name and type of the
state that is being accessed.public <S extends org.apache.flink.api.common.state.MergingState<?,?>> void mergePartitionedState(org.apache.flink.api.common.state.StateDescriptor<S,?> stateDescriptor)
mergePartitionedState 在接口中 Trigger.OnMergeContextpublic long getCurrentProcessingTime()
Trigger.TriggerContextpublic void registerProcessingTimeTimer(long time)
Trigger.TriggerContextTrigger.onProcessingTime(long, Window, TriggerContext) is called with the time specified here.registerProcessingTimeTimer 在接口中 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 在接口中 Trigger.TriggerContexttime - The watermark at which to invoke Trigger.onEventTime(long, Window, TriggerContext)Watermarkpublic void deleteProcessingTimeTimer(long time)
Trigger.TriggerContextpublic void deleteEventTimeTimer(long time)
Trigger.TriggerContextdeleteEventTimeTimer 在接口中 Trigger.TriggerContextpublic TriggerResult onElement(StreamRecord<IN> element) throws Exception
Exceptionpublic TriggerResult onProcessingTime(long time) throws Exception
Exceptionpublic TriggerResult onEventTime(long time) throws Exception
Exceptionpublic void onMerge(Collection<W> mergedWindows) throws Exception
ExceptionCopyright © 2014–2021 The Apache Software Foundation. All rights reserved.