Search code examples
apache-flinkflink-cep

How to use "every" pattern operator in Flink CEP


In Esper CEP engine event patterns, there's Every operator which indicates that the pattern sub-expression should restart when the sub-expression qualified by the every keyword evaluates to true or false.

According to this document, We can use every operator in different ways like:

    A -> B
    every ( A -> B )
    every A -> B
    A -> every B
    every A -> every B

I would like to know which of these patterns are possible in Flink CEP? I want to use every A -> B in Flink but don't know how.

And which one of the above patterns this default CEP pattern in Flink represents? (Using Flink v1.1.4)

Pattern<Event, ?> pattern = Pattern.begin("start").where(evt -> evt.getId() == 42)
    .followedBy("end").where(evt -> evt.getName().equals("end"));

Thanks in advance.


Solution

  • Flink provides some documentation as to how to use every which says that if you specify subtype then it will be called for every iteration

    start.subtype(SubEvent.class).where(new SimpleCondition<SubEvent>() {
        @Override
        public boolean filter(SubEvent value) {
            return ... // some condition
        }
    });
    

    But in my opinion, it is not what you are looking for. However, you can have a look at a light-weight Siddhi- Flink CEP library by using which you will be able to use siddhi query language in Flink