Class IterativeCondition<T>
- java.lang.Object
-
- org.apache.flink.cep.pattern.conditions.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 correspondingNFA
.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 aIterativeCondition.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
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
IterativeCondition.Context<T>
The context used when evaluating thecondition
.
-
Constructor Summary
Constructors Constructor Description IterativeCondition()
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description abstract boolean
filter(T value, IterativeCondition.Context<T> ctx)
The filter function that evaluates the predicate.
-
-
-
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
- TheIterativeCondition.Context
used for the evaluation of the function and provides access to the already accepted events in the pattern (seeIterativeCondition.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.
-
-