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.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
在接口中 Trigger.TriggerContext
public long getCurrentWatermark()
Trigger.TriggerContext
getCurrentWatermark
在接口中 Trigger.TriggerContext
public <S extends Serializable> org.apache.flink.api.common.state.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
在接口中 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> org.apache.flink.api.common.state.ValueState<S> getKeyValueState(String name, org.apache.flink.api.common.typeinfo.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
在接口中 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 org.apache.flink.api.common.state.State> S getPartitionedState(org.apache.flink.api.common.state.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
在接口中 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 org.apache.flink.api.common.state.MergingState<?,?>> void mergePartitionedState(org.apache.flink.api.common.state.StateDescriptor<S,?> stateDescriptor)
mergePartitionedState
在接口中 Trigger.OnMergeContext
public long getCurrentProcessingTime()
Trigger.TriggerContext
public void registerProcessingTimeTimer(long time)
Trigger.TriggerContext
Trigger.onProcessingTime(long, Window, TriggerContext)
is called with the time specified here.registerProcessingTimeTimer
在接口中 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
在接口中 Trigger.TriggerContext
time
- The watermark at which to invoke Trigger.onEventTime(long, Window, TriggerContext)
Watermark
public void deleteProcessingTimeTimer(long time)
Trigger.TriggerContext
public void deleteEventTimeTimer(long time)
Trigger.TriggerContext
deleteEventTimeTimer
在接口中 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–2019 The Apache Software Foundation. All rights reserved.