Flink CEP State Change Pattern

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

Flink CEP State Change Pattern

Philip Limbeck
Hi!

I am quite new to Flink CEP and try to define a state change pattern
with it. This means that only discrete changes in the event stream
should be detected i.e.

a a b b - triggers a single change from a to b

Considering b the "bad" state, I would like to additionally recognize
the state change from null (i.e. non-existing state) to b:

b b b - triggers a single change from null to b

Initially, I tried to model this behavior as follows:

Pattern<...>begin("first")
.where(<detectStateA>)
.optional()
.next("second")
.where(<detectStateB>)

However, since state b can be detected without state a, having a state
change from a to b results in two identified patterns:
a b
and
b

Additionally, when the "bad" state b is already given, every
subsequent b event will detect a new b pattern which is also not what
I want.

When the "optional" keyword is omitted, obviously no initial b events
are detected.

I know that Flink 1.4.0 will support AFTER_MATCH_SKIP, which I assume
would aid in this situation as a single b event will not take part in
two computation states.

Being currently stuck with 1.3.2 is there a workaround using Flink CEP
to enable this behavior?

I am aware of the fact that this behavior is much easier to build
using plain Flink.

Thank you for your support, any help is appreciated.

Best
Philip
Reply | Threaded
Open this post in threaded view
|

Re: Flink CEP State Change Pattern

Tzu-Li (Gordon) Tai
Hi Philip!

I’m looping in Kostas to this thread. He might be able to provide some insights for your question.

Cheers,
Gordon

On 14 October 2017 at 8:54:45 PM, Philip Limbeck ([hidden email]) wrote:

Hi!

I am quite new to Flink CEP and try to define a state change pattern
with it. This means that only discrete changes in the event stream
should be detected i.e.

a a b b - triggers a single change from a to b

Considering b the "bad" state, I would like to additionally recognize
the state change from null (i.e. non-existing state) to b:

b b b - triggers a single change from null to b

Initially, I tried to model this behavior as follows:

Pattern<...>begin("first")
.where(<detectStateA>)
.optional()
.next("second")
.where(<detectStateB>)

However, since state b can be detected without state a, having a state
change from a to b results in two identified patterns:
a b
and
b

Additionally, when the "bad" state b is already given, every
subsequent b event will detect a new b pattern which is also not what
I want.

When the "optional" keyword is omitted, obviously no initial b events
are detected.

I know that Flink 1.4.0 will support AFTER_MATCH_SKIP, which I assume
would aid in this situation as a single b event will not take part in
two computation states.

Being currently stuck with 1.3.2 is there a workaround using Flink CEP
to enable this behavior?

I am aware of the fact that this behavior is much easier to build
using plain Flink.

Thank you for your support, any help is appreciated.

Best
Philip