Esper滑动窗口接缝的输出,当事件发生在另一次离开后

时间:2017-02-04 01:14:27

标签: event-handling esper sliding-window event-listener

从Esper示例中,我只是编写简单的EPL:

select symbol, avg(price) as avgprice,count(*) as count,            
current_timestamp() as time from StockTick.win:time(0.4 sec)
group by symbol

每100毫秒,我将数据提供给Esper,如下所示:

StockTick={symbol='YHOO', price=100}
t=t.plus(0.1 seconds)
StockTick={symbol='YHOO', price=65}
t=t.plus(0.1 seconds)
StockTick={symbol='YHOO', price=75}
t=t.plus(0.1 seconds)
StockTick={symbol='YHOO', price=65}
t=t.plus(0.1 seconds)
StockTick={symbol='YHOO', price=100}
t=t.plus(0.1 seconds)
StockTick={symbol='YHOO', price=15}

但我收到的输出让我感到困惑

Statement: AVGTABLE
Insert
AVGTABLE-output={symbol='YHOO', avgprice=76.25, count=4, time=300}
At: 1970-01-01 00:00:00.400
Statement: AVGTABLE
Insert
AVGTABLE-output={symbol='YHOO',avgprice=68.33333333333333, count=3,     
time=400}
At: 1970-01-01 00:00:00.400
Statement: AVGTABLE
Insert
AVGTABLE-output={symbol='YHOO', avgprice=76.25, count=4, time=400}
At: 1970-01-01 00:00:00.500
Statement: AVGTABLE
Insert
AVGTABLE-output={symbol='YHOO', avgprice=80.0, count=3, time=500}
At: 1970-01-01 00:00:00.500
Statement: AVGTABLE
Insert
AVGTABLE-output={symbol='YHOO', avgprice=63.75, count=4, time=500}
At: 1970-01-01 00:00:00.600
Statement: AVGTABLE
Insert
AVGTABLE-output={symbol='YHOO', avgprice=60.0, count=3, time=600}

在时间400和500,这里有2个输出,我猜它似乎是由于一个事件在另一个之前离开了窗口。它们为什么会显示在此处,因为我不选择irstream,如何在UpdateEventListener中避免使用它?

1 个答案:

答案 0 :(得分:0)

当事件从时间窗口到期时,平均值会发生变化,因此听众会看到新的平均值,因为旧的平均值不再正确。通过不使用时间窗来避免它,例如... from StockTick group by ...