Esper窗口用法:根据事件离开窗口重新计算

时间:2012-11-28 00:47:34

标签: java esper complex-event-processing

我需要有点像这样。

//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命名为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

但有些第三事件无法自动触发derivedevent recalculatin 当第4个事件的到来触发并根据需要提供输出。
任何标准的做法吗?

我想计算新事件是否到达窗口或离开窗口的金额总和。

1 个答案:

答案 0 :(得分:1)

3.事件(删除)确实通过"插入到derivedevent"触发输出新的和,除非没有删除任何内容,因此您的id键可能是错误的。 如果仍有问题,请将最小测试用例发送到esper用户邮件列表。 或者使用@Audit查看每个语句内部引擎的作用。