T
- The type of elements on which this trigger can operate.W
- The type of Windows
on which this trigger can operate.@PublicEvolving public class PurgingTrigger<T,W extends Window> extends Trigger<T,W>
Trigger
into a purging Trigger
.
When the nested trigger fires, this will return a FIRE_AND_PURGE
TriggerResult
.
Trigger.OnMergeContext, Trigger.TriggerContext
Modifier and Type | Method and Description |
---|---|
boolean |
canMerge()
Returns true if this trigger supports merging of trigger state and can therefore be used with
a
MergingWindowAssigner . |
void |
clear(W window,
Trigger.TriggerContext ctx)
Clears any state that the trigger might still hold for the given window.
|
Trigger<T,W> |
getNestedTrigger() |
static <T,W extends Window> |
of(Trigger<T,W> nestedTrigger)
Creates a new purging trigger from the given
Trigger . |
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.
|
void |
onMerge(W window,
Trigger.OnMergeContext ctx)
Called when several windows have been merged into one window by the
WindowAssigner . |
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) throws Exception
Trigger
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 boolean canMerge()
Trigger
MergingWindowAssigner
.
If this returns true
you must properly implement Trigger.onMerge(Window,
OnMergeContext)
public void onMerge(W window, Trigger.OnMergeContext ctx) throws Exception
Trigger
WindowAssigner
.public static <T,W extends Window> PurgingTrigger<T,W> of(Trigger<T,W> nestedTrigger)
Trigger
.nestedTrigger
- The trigger that is wrapped by this purging trigger@VisibleForTesting public Trigger<T,W> getNestedTrigger()
Copyright © 2014–2024 The Apache Software Foundation. All rights reserved.