Class WindowOperator.Context
- java.lang.Object
-
- org.apache.flink.streaming.runtime.operators.windowing.WindowOperator.Context
-
- All Implemented Interfaces:
Trigger.OnMergeContext,Trigger.TriggerContext
public class WindowOperator.Context extends Object implements Trigger.OnMergeContext
Contextis a utility for handlingTriggerinvocations. It can be reused by setting thekeyandwindowfields. No internal state must be kept in theContext
-
-
Field Summary
Fields Modifier and Type Field Description protected Kkeyprotected Collection<W>mergedWindowsprotected Wwindow
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclear()voiddeleteEventTimeTimer(long time)Delete the event-time trigger for the given time.voiddeleteProcessingTimeTimer(long time)Delete the processing time trigger for the given time.longgetCurrentProcessingTime()Returns the current processing time.longgetCurrentWatermark()Returns the current watermark time.org.apache.flink.metrics.MetricGroupgetMetricGroup()Returns the metric group for thisTrigger.<S extends org.apache.flink.api.common.state.State>
SgetPartitionedState(org.apache.flink.api.common.state.StateDescriptor<S,?> stateDescriptor)Retrieves aStateobject 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<?,?>>
voidmergePartitionedState(org.apache.flink.api.common.state.StateDescriptor<S,?> stateDescriptor)TriggerResultonElement(StreamRecord<IN> element)TriggerResultonEventTime(long time)voidonMerge(Collection<W> mergedWindows)TriggerResultonProcessingTime(long time)voidregisterEventTimeTimer(long time)Register an event-time callback.voidregisterProcessingTimeTimer(long time)Register a system time callback.StringtoString()
-
-
-
Method Detail
-
getMetricGroup
public org.apache.flink.metrics.MetricGroup getMetricGroup()
Description copied from interface:Trigger.TriggerContextReturns the metric group for thisTrigger. This is the same metric group that would be returned fromRuntimeContext.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.- Specified by:
getMetricGroupin interfaceTrigger.TriggerContext
-
getCurrentWatermark
public long getCurrentWatermark()
Description copied from interface:Trigger.TriggerContextReturns the current watermark time.- Specified by:
getCurrentWatermarkin interfaceTrigger.TriggerContext
-
getPartitionedState
public <S extends org.apache.flink.api.common.state.State> S getPartitionedState(org.apache.flink.api.common.state.StateDescriptor<S,?> stateDescriptor)
Description copied from interface:Trigger.TriggerContextRetrieves aStateobject that can be used to interact with fault-tolerant state that is scoped to the window and key of the current trigger invocation.- Specified by:
getPartitionedStatein interfaceTrigger.TriggerContext- Type Parameters:
S- The type of the state.- Parameters:
stateDescriptor- The StateDescriptor that contains the name and type of the state that is being accessed.- Returns:
- The partitioned state object.
-
mergePartitionedState
public <S extends org.apache.flink.api.common.state.MergingState<?,?>> void mergePartitionedState(org.apache.flink.api.common.state.StateDescriptor<S,?> stateDescriptor)
- Specified by:
mergePartitionedStatein interfaceTrigger.OnMergeContext
-
getCurrentProcessingTime
public long getCurrentProcessingTime()
Description copied from interface:Trigger.TriggerContextReturns the current processing time.- Specified by:
getCurrentProcessingTimein interfaceTrigger.TriggerContext
-
registerProcessingTimeTimer
public void registerProcessingTimeTimer(long time)
Description copied from interface:Trigger.TriggerContextRegister a system time callback. When the current system time passes the specified timeTrigger.onProcessingTime(long, Window, TriggerContext)is called with the time specified here.- Specified by:
registerProcessingTimeTimerin interfaceTrigger.TriggerContext- Parameters:
time- The time at which to invokeTrigger.onProcessingTime(long, Window, TriggerContext)
-
registerEventTimeTimer
public void registerEventTimeTimer(long time)
Description copied from interface:Trigger.TriggerContextRegister an event-time callback. When the current watermark passes the specified timeTrigger.onEventTime(long, Window, TriggerContext)is called with the time specified here.- Specified by:
registerEventTimeTimerin interfaceTrigger.TriggerContext- Parameters:
time- The watermark at which to invokeTrigger.onEventTime(long, Window, TriggerContext)- See Also:
Watermark
-
deleteProcessingTimeTimer
public void deleteProcessingTimeTimer(long time)
Description copied from interface:Trigger.TriggerContextDelete the processing time trigger for the given time.- Specified by:
deleteProcessingTimeTimerin interfaceTrigger.TriggerContext
-
deleteEventTimeTimer
public void deleteEventTimeTimer(long time)
Description copied from interface:Trigger.TriggerContextDelete the event-time trigger for the given time.- Specified by:
deleteEventTimeTimerin interfaceTrigger.TriggerContext
-
onElement
public TriggerResult onElement(StreamRecord<IN> element) throws Exception
- Throws:
Exception
-
onProcessingTime
public TriggerResult onProcessingTime(long time) throws Exception
- Throws:
Exception
-
onEventTime
public TriggerResult onEventTime(long time) throws Exception
- Throws:
Exception
-
onMerge
public void onMerge(Collection<W> mergedWindows) throws Exception
- Throws:
Exception
-
-