flink-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dawid Wysakowicz <wysakowicz.da...@gmail.com>
Subject Re: CEP condition expression and its event consuming strategy
Date Thu, 27 Jul 2017 07:17:40 GMT
Hi Chao,

Ad. 1 You could implement it with IterativeCondition. Sth like this:

Pattern<Event, ?> pattern = Pattern.<Event>begin("first").where(new SimpleCondition<Event>()
{
   @Override
   public boolean filter(Event value) throws Exception {
      return value.equals("A") || value.equals("B");
   }
}).followedBy("second").where(new IterativeCondition<Event>() {
   @Override
   public boolean filter(Event value, Context<Event> ctx) throws Exception {
      return (value.equals("A") || value.equals("B")) && !value.equals(ctx.getEventsForPattern("first"));
   }
}).

Ad. 2 Unfortunately right now as you said Pattern restarts each other event and it is not
possible to change that strategy. There is ongoing work to introduce AfterMatchSkipStrategy[1],
but at best it will be merged in 1.4.0. I did not give it much thought, but I would try implement
some discarding logic.

Regards,
Dawid

[1] https://issues.apache.org/jira/browse/FLINK-7169

> On 26 Jul 2017, at 22:45, Chao Wang <chaowang@wustl.edu> wrote:
> 
> Hi,
> 
> I have two questions regarding the use of the Flink CEP library (flink-cep_2.11:1.3.1),
as follows:
> 
> 1. I'd like to know how to use the API to express "emit event C in the presence of events
A and B, with no restriction on the arriving order of A and B"? I've tried by creating two
patterns, one for "A and then B" and the other for "B and then A", and consequently using
two patternStreams to handle each case, which emits C. It worked but to me this approach seems
redundant.
> 
> 2. Given the above objective expression, how to consume the accepted events so that they
will not be used for future matchings? For example, with the arriving sequence {A, B, A},
the CEP should only emit one C (due to the matching of {A,B}), not two Cs (due to {A,B} and
{B,A}). Similarly, with the arriving sequence {B, A, B, A}, the CPE should only emit two Cs,
not three.
> 
> 
> Thanks,
> 
> Chao
> 


Mime
View raw message