notNext() and next(negation) not yielding same output in Flink CEP

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

notNext() and next(negation) not yielding same output in Flink CEP

Yassine MARZOUGUI
Hi all,

I would like to match the maximal consecutive sequences of events of type A in a stream.
I'm using the following :
Pattern.begin("start").where(event is not A)
.next("middle").where(event is A).oneOrMore().consecutive()
.next("not").where(event is not A)
I This give the output I want. However if I use notNext("not").where(event is A) instead of next("not").where(event is not A), the middle patterns contain only sequences of single elements of type A.
My understaning is that notNext() in this case is equivalent to next(negation), so why is the output different?

Thank you in advance.

Best,
Yassine
Reply | Threaded
Open this post in threaded view
|

Re: notNext() and next(negation) not yielding same output in Flink CEP

Dawid Wysakowicz
Hi Yassine,

First of all notNext(A) is not equal to next(not A). notNext should be considered as a “stopCondition” which tells if an event matching the A condition occurs the current partial match is discarded. The next(not A) on the other hand accepts every event that do not match the A condition.

So let’s analyze a sequence of events like “b c a1 a2 a3 d”. For the first version with next(not A) the output will be “c a1 a2 a3 d” which is what you expect, I think. In the other version with notNext(A) a partial match “c a1” will be discarded after “a2” as the notNext says that after the A’s there should be no A.

I hope this helps understanding how notNext works.

Regards,
Dawid

> On 22 Jul 2017, at 20:32, Yassine MARZOUGUI <[hidden email]> wrote:
>
> Hi all,
>
> I would like to match the maximal consecutive sequences of events of type A in a stream.
> I'm using the following :
> Pattern.begin("start").where(event is not A)
> .next("middle").where(event is A).oneOrMore().consecutive()
> .next("not").where(event is not A)
> I This give the output I want. However if I use notNext("not").where(event is A) instead of next("not").where(event is not A), the middle patterns contain only sequences of single elements of type A.
> My understaning is that notNext() in this case is equivalent to next(negation), so why is the output different?
>
> Thank you in advance.
>
> Best,
> Yassine


signature.asc (817 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: notNext() and next(negation) not yielding same output in Flink CEP

Yassine MARZOUGUI
Hi Dawid,

Thanks a lot for the explanation, it's all clear now.

Best,
Yassine

2017-07-23 13:11 GMT+02:00 Dawid Wysakowicz <[hidden email]>:
Hi Yassine,

First of all notNext(A) is not equal to next(not A). notNext should be considered as a “stopCondition” which tells if an event matching the A condition occurs the current partial match is discarded. The next(not A) on the other hand accepts every event that do not match the A condition.

So let’s analyze a sequence of events like “b c a1 a2 a3 d”. For the first version with next(not A) the output will be “c a1 a2 a3 d” which is what you expect, I think. In the other version with notNext(A) a partial match “c a1” will be discarded after “a2” as the notNext says that after the A’s there should be no A.

I hope this helps understanding how notNext works.

Regards,
Dawid

> On 22 Jul 2017, at 20:32, Yassine MARZOUGUI <[hidden email]> wrote:
>
> Hi all,
>
> I would like to match the maximal consecutive sequences of events of type A in a stream.
> I'm using the following :
> Pattern.begin("start").where(event is not A)
> .next("middle").where(event is A).oneOrMore().consecutive()
> .next("not").where(event is not A)
> I This give the output I want. However if I use notNext("not").where(event is A) instead of next("not").where(event is not A), the middle patterns contain only sequences of single elements of type A.
> My understaning is that notNext() in this case is equivalent to next(negation), so why is the output different?
>
> Thank you in advance.
>
> Best,
> Yassine