Elias Levy created FLINK-6420:
---------------------------------

             Summary: Cleaner CEP API to specify conditions between events
                 Key: FLINK-6420
                 URL: https://issues.apache.org/jira/browse/FLINK-6420
             Project: Flink
          Issue Type: Improvement
          Components: CEP
    Affects Versions: 1.3.0
            Reporter: Elias Levy
            Priority: Minor


Flink 1.3 will introduce so-called iterative conditions, which allow the 
predicate to look up events already matched by conditions in the pattern.  This 
permits specifying conditions between matched events, similar to a conditional 
join between tables in SQL.  Alas, the API could be simplified to specify such 
conditions more declaratively.

At the moment you have to do something like
{code}
    Pattern.
      .begin[Foo]("first")
        .where( first => first.baz == 1 )
      .followedBy("next")
        .where({ (next, ctx) =>
          val first = ctx.getEventsForPattern("first").next
          first.bar == next.bar && next => next.boo = "x"
        })
{code}
which is not very clean.  It would friendlier if you could do something like:
{code}
    Pattern.
      .begin[Foo]("first")
        .where( first => first.baz == 1 )
      .followedBy("next")
        .relatedTo("first", { (first, next) => first.bar == next.bar })
        .where( next => next.boo = "x" )
{code}
Something along these lines would work well when the condition being tested 
against matches a single event (single quantifier).  

If the condition being tested can accept multiple events (e.g. times 
quantifier) two other methods could be used {{relatedToAny}} and 
{{relatedToAll}}, each of which takes a predicate function.  In both cases each 
previously accepted element of the requested condition is evaluated against the 
predicate.  In the former case if any evaluation returns true the condition is 
satisfied.  In the later case all evaluations must return true for the 
condition to be satisfied.




--
This message was sent by Atlassian JIRA
(v6.3.15#6346)

Reply via email to