flink-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Elias Levy (JIRA)" <j...@apache.org>
Subject [jira] [Created] (FLINK-6420) Cleaner CEP API to specify conditions between events
Date Sat, 29 Apr 2017 00:34:04 GMT
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
        .where( first => first.baz == 1 )
        .where({ (next, ctx) =>
          val first = ctx.getEventsForPattern("first").next
          first.bar == next.bar && next => next.boo = "x"
which is not very clean.  It would friendlier if you could do something like:
        .where( first => first.baz == 1 )
        .relatedTo("first", { (first, next) => first.bar == next.bar })
        .where( next => next.boo = "x" )
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

View raw message