Esper window usage: Recalculation based on event leaving window

本小妞迷上赌 提交于 2020-01-14 04:06:07

问题


I need somewhat like this.

//Create a named window (w1)
Create window w1....

//then insert events into window
insert into w1....
select amount,.....
from....
where...

//remove from window
on RemoveEventArrived as r
Delete from w1
where w1.id = r.id

Now insert into another event from w1 named window

//inserting into final output event
insert into derivedevent
select sum(w.amount)
from w1 as w

suppose event sequence:
1. Event with id=1 and amount= 100 arrived.
   o/p of sum(amount) triggered and gives 100.

2. Event withid = 2 and amount=200 arrived.
  o/p of sum(amount) triggered and gives 300.

3. **Remove** Event with id=1 arrived.
o/p of sum(amount) triggered and gives 200.

4. Event with id = 3 and amount=500 arrived
o/p of sum(amount) triggered and gives  700

but somewhat 3rd event could not trigger derivedevent recalculatin automatically.
While arrival of 4th event triggers and gives output as required.
Any standard way of doing it?

I want to calculate sum of amount whether a new event arrive into window or leaving it.


回答1:


The 3. event (remove) does trigger output of a new sum by "insert into derivedevent", unless nothing was removed, therefore perhaps your id keys are wrong. Send a minimal test case to the esper user mailing list if still having trouble. Or use @Audit to see what the engine does internally for each statement.



来源:https://stackoverflow.com/questions/13595930/esper-window-usage-recalculation-based-on-event-leaving-window

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