You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by "Tarush Grover (JIRA)" <ji...@apache.org> on 2018/05/01 10:30:00 UTC

[jira] [Commented] (FLINK-6420) Cleaner CEP API to specify conditions between events

    [ https://issues.apache.org/jira/browse/FLINK-6420?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16459591#comment-16459591 ] 

Tarush Grover commented on FLINK-6420:
--------------------------------------

Can I take this up?

> 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
(v7.6.3#76005)