There is an issue in Apache JIRA: https://issues.apache.org/jira/browse/FLINK-3703. It allows defining where the matching algorithm should continue after a matching sequence has been found and there are three types of behavior:
from first
- continue keeping all events for future matches (that is the current behavior)after first
- continue after the first element (remove first matching event and continue with the second event)after last
- continue after the last element (effectively discarding all elements of the matching sequence)For example, if we have a sequence of events: A
, B
, C
and pattern first -> second
we'll get next results:
from first
- A -> B
, A -> C
, B -> C
after first
- A -> B
, B -> C
after last
- A -> B
Now the issue is closed with a comment that all of that implemented in other tasks:
This was covered by other issues including the Quantifier implementation, the skip-till-next and some additional issues for continuity within looping patterns.
So, could somebody tell me how to implement defined kinds of behavior using current API of the Flink CEP library?
I've found the answer to my question and I'd like to share this information: the behavior how the matching algorithm should continue after a matching sequence has been found can be defined by AfterMatchSkipStrategy
. But, it works only since version 1.4. Well, we're waiting for the release.
Here is more information: https://ci.apache.org/projects/flink/flink-docs-release-1.4/dev/libs/cep.html#after-match-skip-strategy.