2012-11-28 66 views
1

我需要這樣。Esper窗口的使用:基於事件離開窗口的重新計算

//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 

現在插入到另一個事件從W1命名的窗口

//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 

,但有些事件3不能自動觸發derivedevent recalculatin。
第4個事件到達時觸發並根據需要輸出。
任何標準的做法?

我想計算一個新事件是否進入窗口或離開它的總量。

回答

1

3.事件(remove)通過「insert into derivedevent」觸發輸出一個新和,除非沒有被刪除,因此也許你的id鍵是錯誤的。 如果仍然遇到問題,可以向esper用戶郵件列表發送一個最小的測試用例。 或使用@Audit來查看引擎在內部對每條語句執行的操作。

+0

我已更新問題請仔細查看。特別是第四項活動根據需要提供o/p。 –