Class DeltaTrigger<T,​W extends Window>

  • Type Parameters:
    W - The type of Windows on which this trigger can operate.
    All Implemented Interfaces:
    Serializable

    @PublicEvolving
    public class DeltaTrigger<T,​W extends Window>
    extends Trigger<T,​W>
    A 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.

    See Also:
    Serialized Form
    • Method Detail

      • onElement

        public TriggerResult onElement​(T element,
                                       long timestamp,
                                       W window,
                                       Trigger.TriggerContext ctx)
                                throws Exception
        Description copied from class: Trigger
        Called 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:
        onElement in class Trigger<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: Trigger
        Called when an event-time timer that was set using the trigger context fires.
        Specified by:
        onEventTime in class Trigger<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: Trigger
        Called when a processing-time timer that was set using the trigger context fires.
        Specified by:
        onProcessingTime in class Trigger<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.
        Throws:
        Exception
      • of

        public static <T,​W extends WindowDeltaTrigger<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 and DeltaFunction.
        Type Parameters:
        T - The type of elements on which this trigger can operate.
        W - The type of Windows on which this trigger can operate.
        Parameters:
        threshold - The threshold at which to trigger.
        deltaFunction - The delta function to use
        stateSerializer - TypeSerializer for the data elements.