Class IterativeCondition<T>

  • All Implemented Interfaces:
    Serializable, org.apache.flink.api.common.functions.Function
    Direct Known Subclasses:
    RichIterativeCondition, SimpleCondition

    @PublicEvolving
    public abstract class IterativeCondition<T>
    extends Object
    implements org.apache.flink.api.common.functions.Function, Serializable
    A user-defined condition that decides if an element should be accepted in the pattern or not. Accepting an element also signals a state transition for the corresponding NFA.

    A condition can be a simple filter or a more complex condition that iterates over the previously accepted elements in the pattern and decides to accept a new element or not based on some statistic over these elements. In the former case, the condition should extend the SimpleCondition class. In the later, the condition should extend this class, which gives you also access to the previously accepted elements through a IterativeCondition.Context.

    An iterative condition that accepts an element if i) its name is middle, and ii) the sum of the prices of all accepted elements is less than 5 would look like:

    {@code
     private class MyCondition extends IterativeCondition {
    See Also:
    Serialized Form
    • Constructor Detail

      • IterativeCondition

        public IterativeCondition()
    • Method Detail

      • filter

        public abstract boolean filter​(T value,
                                       IterativeCondition.Context<T> ctx)
                                throws Exception
        The filter function that evaluates the predicate.

        IMPORTANT: The system assumes that the function does not modify the elements on which the predicate is applied. Violating this assumption can lead to incorrect results.

        Parameters:
        value - The value to be tested.
        ctx - The IterativeCondition.Context used for the evaluation of the function and provides access to the already accepted events in the pattern (see IterativeCondition.Context.getEventsForPattern(String)).
        Returns:
        true for values that should be retained, false for values to be filtered out.
        Throws:
        Exception - This method may throw exceptions. Throwing an exception will cause the operation to fail and may trigger recovery.