Hi Elias,

If I understand correctly your use case, you want for an input:

event_1 = (type=1, value_a=K, value_b=X)
event_2 = (type=2, value_a=K, value_b=X)
event_3 = (type=1, value_a=K, value_b=Y)

to get a match:

event_1, event_2

and discard event_3, right?

In this case, Dawid is correct and from a first look at your code, it should 
work.
If not, what is the output that you get?

Kostas


> On Apr 26, 2017, at 8:39 AM, Dawid Wysakowicz <wysakowicz.da...@gmail.com> 
> wrote:
> 
> Hi Elias,
> 
> You can do it with 1.3 and IterativeConditions. Method 
> ctx.getEventsForPattern("foo") returns only those events that were matched in 
> "foo" pattern in that particular branch.
> I mean that for a sequence like (type =1, value_b = X); (type=1, value_b=Y); 
> (type=2, value_b=X) both events of type = 1 create a seperate pattern branch 
> and the event with type = 2 will be checked for a match twice for both of 
> those branches.
> 
> Regards,
> Dawid
> 
> 2017-04-26 7:48 GMT+02:00 Elias Levy <fearsome.lucid...@gmail.com 
> <mailto:fearsome.lucid...@gmail.com>>:
> There doesn't appear to be a way to join events across conditions using the 
> CEP library.
> 
> Consider events of the form (type, value_a, value_b) on a stream keyed by the 
> value_a field.  
> 
> Under 1.2 you can create a pattern that for a given value_a, as specified by 
> the stream key, there is a match if an event of type 1 is followed by an 
> event of type 2 (e.g. 
> begin("foo").where(_.type==1).followedBy("bar").where(_.type==2).  But this 
> will return a match regardless of whether value_b in the first event matches 
> value_b in the second event.
> 
> 1.3 snapshot introduces iterative conditions, but this is insufficient.  In 
> 1.3 you can do:
> 
> begin("foo").where(_.type==1).followedBy("bar").where(
>     (v, ctx) => {
>        v.type == 2 &&
>        ctx.getEventsForPattern("foo").asScala.exists(prev => prev.value_b == 
> v.value_b)
>     })
> 
> This will accept the current event if any if any previously had a value_b 
> that matches the current event. But the matches will include all previous 
> events, even those that did not match the current event at value_b, instead 
> of only matching the previous event where value_b equals the current event.
> 
> Is there a way to only output the match there previous event matches the 
> current event value_b (e.g. foo == (type=1, value_a=K, value_b=X) and bar == 
> (type=2, value_a=K, value_b=X)?
> 
> 
> 

Reply via email to