How to describe this complex scene by cep?

139 views Asked by At
  1. This is my Event schema

EventA (FieldA string, FieldB string, FiledC string) EventB (FieldD string, FieldE string)

  1. I want the query like:
    1. devide events into group window, group EventA by FieldA, FieldB ,group EventB by FieldE
    2. If events occured in this order: EventA -> EventA -> EventA -> EventB -> EventB,and distinct( EventA.FieldC ) >= 3,and every EventB.FieldE equals every EventA.FieldB(join part),then generate a correlate event.

The problem is that:the count of EventA (3) is for the group window.For example: ["1","2","3"],["1","2","4"],["1","2","5"] can trigger "EventA -> EventA -> EventA"(3 events in one group window ),and ["1","2","3"],["1","3","4"],["1","4","5"] can not(3 group window , each has 1 event) and so as the 2 EventB.

so the complete example is: ["1","2","3"],["1","2","4"],["1","2","5"],["a","2"],["b","2"]

I find it's hard even in naturl language to descript the situation, and I have no idea how to descript this in CEP;

I use context in esper to solve problem that the count is for the group window not for the stream(in siddhi,partition).It is suit for the single EventA or EventB,but if EventA and EventB has to do a patten, the two independent context can not use together.And I tried Context Nesting like:

create context PartAB context PartA partition by FieldA and FieldB from EventA, context PartB partition by FieldE from EventB

and it seems doesn't work.

Thanks for anyone that can help this situation.

1

There are 1 answers

2
user650839 On

First question comes to mind is how are "FieldA, FieldB" and "FieldE" related? I.e. its is string-append for example where "FieldA || FieldB == FieldE" or what is the operation to compare these fields?

In Esper use a context like this one:

create context PartAB 
  partition by to_be_determined_A_B from EventA,
               to_be_determined_E from EventB

This not-nested partitioned context makes sure events land in the same partition (nested context would create all possible combinations and that is not what you want).

You could compute the "to_be_determined_A_B" with an insert-into or by adding a new field to your event. Here is a sample insert-into:

insert into EventAWithFieldCombined select FieldA||FieldB combinedAB, * from EventA

... and the context could look like this...

create context PartAB 
  partition by combinedAB from EventAWithFieldCombined,
               FieldE from EventB