How to describe this complex scene by cep?

喜夏-厌秋 提交于 2019-12-13 08:10:26

问题


  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:


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


来源:https://stackoverflow.com/questions/41498805/how-to-describe-this-complex-scene-by-cep

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!