W
- The type of Windows
on which this trigger can operate.@PublicEvolving public class CountTrigger<W extends Window> extends Trigger<Object,W>
Trigger
that fires once the count of elements in a pane reaches the given count.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.
|
static <W extends Window> |
of(long maxCount)
Creates a trigger that fires once the number of elements in a pane reaches the given count.
|
TriggerResult |
onElement(Object 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(Object element, long timestamp, W window, Trigger.TriggerContext ctx) throws Exception
Trigger
onElement
in class Trigger<Object,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<Object,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 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 <W extends Window> CountTrigger<W> of(long maxCount)
W
- The type of Windows
on which this trigger can operate.maxCount
- The count of elements at which to fire.Copyright © 2014–2020 The Apache Software Foundation. All rights reserved.