Esper/NEsper EPL event Statement

让人想犯罪 __ 提交于 2021-01-29 07:26:57

问题


I'm new in Esper. Can anyone help me define the EPL statement to catch the event when the following situation occurs:

  • Assumming that there are events with 3 attributes - (string)Symbol, (boolean)Value, (datetime)Timestamp. For example event1 (Symbol-apple, Value-true, Timestamp- 2020.10.07 14:00:00), event2 (Symbol-orange, Value-true, Timestamp- 2020.10.07 14:00:00) and event3 (Symbol-banana, Value-false, Timestamp- 2020.10.07 14:00:00). If they have same (or almost the same) Timestamp only one of them can have attribute - Value as true. In this example event2 matchs the requirement and should be captured.

How can I define the statement to catch it?

Thanks for any help.

Narsu


回答1:


The "window" is an aggregation function (see manual) returns the events. The enumeration methods (selectfrom, countof, see manual) are for filtering and selecting. Something like this.

select window(*).selectFrom(v => v.value=true) as eventWithTrueFlag
from Event#length(3) 
having window(*).countOf(v => v.value=true)=1 and 
  prev(1, timestamp)=timestamp and prev(2, timestamp)=timestamp

"Event" is your event type. You didn't say what your event type is named. "Prev" is the previous function (see manual).



来源:https://stackoverflow.com/questions/64244157/esper-nesper-epl-event-statement

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