Class DeltaTrigger<T,W extends Window>
- java.lang.Object
-
- org.apache.flink.streaming.api.windowing.triggers.Trigger<T,W>
-
- org.apache.flink.streaming.api.windowing.triggers.DeltaTrigger<T,W>
-
- Type Parameters:
W- The type ofWindowson which this trigger can operate.
- All Implemented Interfaces:
Serializable
@PublicEvolving public class DeltaTrigger<T,W extends Window> extends Trigger<T,W>
ATriggerthat fires based on aDeltaFunctionand a threshold.This trigger calculates a delta between the data point which triggered last and the currently arrived data point. It triggers if the delta is higher than a specified threshold.
- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.apache.flink.streaming.api.windowing.triggers.Trigger
Trigger.OnMergeContext, Trigger.TriggerContext
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclear(W window, Trigger.TriggerContext ctx)Clears any state that the trigger might still hold for the given window.static <T,W extends Window>
DeltaTrigger<T,W>of(double threshold, DeltaFunction<T> deltaFunction, org.apache.flink.api.common.typeutils.TypeSerializer<T> stateSerializer)Creates a delta trigger from the given threshold andDeltaFunction.TriggerResultonElement(T element, long timestamp, W window, Trigger.TriggerContext ctx)Called for every element that gets added to a pane.TriggerResultonEventTime(long time, W window, Trigger.TriggerContext ctx)Called when an event-time timer that was set using the trigger context fires.TriggerResultonProcessingTime(long time, W window, Trigger.TriggerContext ctx)Called when a processing-time timer that was set using the trigger context fires.StringtoString()
-
-
-
Method Detail
-
onElement
public TriggerResult onElement(T element, long timestamp, W window, Trigger.TriggerContext ctx) throws Exception
Description copied from class:TriggerCalled for every element that gets added to a pane. The result of this will determine whether the pane is evaluated to emit results.- Specified by:
onElementin classTrigger<T,W extends Window>- Parameters:
element- The element that arrived.timestamp- The timestamp of the element that arrived.window- The window to which the element is being added.ctx- A context object that can be used to register timer callbacks.- Throws:
Exception
-
onEventTime
public TriggerResult onEventTime(long time, W window, Trigger.TriggerContext ctx)
Description copied from class:TriggerCalled when an event-time timer that was set using the trigger context fires.- Specified by:
onEventTimein classTrigger<T,W extends Window>- Parameters:
time- The timestamp at which the timer fired.window- The window for which the timer fired.ctx- A context object that can be used to register timer callbacks.
-
onProcessingTime
public TriggerResult onProcessingTime(long time, W window, Trigger.TriggerContext ctx) throws Exception
Description copied from class:TriggerCalled when a processing-time timer that was set using the trigger context fires.
-
clear
public void clear(W window, Trigger.TriggerContext ctx) throws Exception
Description copied from class:TriggerClears any state that the trigger might still hold for the given window. This is called when a window is purged. Timers set usingTrigger.TriggerContext.registerEventTimeTimer(long)andTrigger.TriggerContext.registerProcessingTimeTimer(long)should be deleted here as well as state acquired usingTrigger.TriggerContext.getPartitionedState(StateDescriptor).
-
of
public static <T,W extends Window> DeltaTrigger<T,W> of(double threshold, DeltaFunction<T> deltaFunction, org.apache.flink.api.common.typeutils.TypeSerializer<T> stateSerializer)
Creates a delta trigger from the given threshold andDeltaFunction.- Type Parameters:
T- The type of elements on which this trigger can operate.W- The type ofWindowson which this trigger can operate.- Parameters:
threshold- The threshold at which to trigger.deltaFunction- The delta function to usestateSerializer- TypeSerializer for the data elements.
-
-