W
- The type of Windows
on which this trigger can operate.@PublicEvolving public class DeltaTrigger<T,W extends Window> extends Trigger<T,W>
Trigger
that fires based on a DeltaFunction
and 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.
Trigger.OnMergeContext, Trigger.TriggerContext
Modifier and Type | Method and Description |
---|---|
void |
clear(W window,
Trigger.TriggerContext ctx)
Clears any state that the trigger might still hold for the given window.
|
static <T,W extends Window> |
of(double threshold,
DeltaFunction<T> deltaFunction,
TypeSerializer<T> stateSerializer)
Creates a delta trigger from the given threshold and
DeltaFunction . |
TriggerResult |
onElement(T element,
long timestamp,
W window,
Trigger.TriggerContext ctx)
Called for every element that gets added to a pane.
|
TriggerResult |
onEventTime(long time,
W window,
Trigger.TriggerContext ctx)
Called when an event-time timer that was set using the trigger context fires.
|
TriggerResult |
onProcessingTime(long time,
W window,
Trigger.TriggerContext ctx)
Called when a processing-time timer that was set using the trigger context fires.
|
String |
toString() |
public TriggerResult onElement(T element, long timestamp, W window, Trigger.TriggerContext ctx) throws Exception
Trigger
onElement
in class Trigger<T,W extends Window>
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.Exception
public TriggerResult onEventTime(long time, W window, Trigger.TriggerContext ctx)
Trigger
onEventTime
in class Trigger<T,W extends Window>
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.public TriggerResult onProcessingTime(long time, W window, Trigger.TriggerContext ctx) throws Exception
Trigger
public void clear(W window, Trigger.TriggerContext ctx) throws Exception
Trigger
Trigger.TriggerContext.registerEventTimeTimer(long)
and
Trigger.TriggerContext.registerProcessingTimeTimer(long)
should be deleted here as well as
state acquired using Trigger.TriggerContext.getPartitionedState(StateDescriptor)
.public static <T,W extends Window> DeltaTrigger<T,W> of(double threshold, DeltaFunction<T> deltaFunction, TypeSerializer<T> stateSerializer)
DeltaFunction
.T
- The type of elements on which this trigger can operate.W
- The type of Windows
on which this trigger can operate.threshold
- The threshold at which to trigger.deltaFunction
- The delta function to usestateSerializer
- TypeSerializer for the data elements.Copyright © 2014–2024 The Apache Software Foundation. All rights reserved.