Siddhi查询使用当前事件的值和最后事件的值来计算新值

时间:2014-09-12 10:05:49

标签: wso2 wso2cep siddhi

每当事件到达时,都需要查询以使用当前事件的值和最后事件的值来计算新值并将其插入到新流中。 举个例子:

event [1]              : speed =  0 timestamp = 1410513924817    Calculated value(Acceleration) : 0
event [2]              : speed =  5 timestamp = 1410513924818    Calculated value(Acceleration) : ( 5 - 0)/1 = 5
event [3]              : speed = 10 timestamp = 1410513924819    Calculated value(Acceleration) : (10- 5)/1  = 5
event [4]              : speed = 13 timestamp = 1410513924820    Calculated value(Acceleration) : (13-10)/1  = 3
event [5]              : speed = 14 timestamp = 1410513924821    Calculated value(Acceleration) : (14-13)/1  = 1
event [6](current)     : speed = 15 timestamp = 1410513924822    Calculated value(Acceleration) : (15-14)/1  = 1

当使用#window.lengthBatch(2)时,它允许为每两个事件计算一次加速度。不符合要求。 有什么想法吗?

1 个答案:

答案 0 :(得分:1)

你可以使用序列

E.g

from a=SpeedStream,b=SpeedStream
select b.speed-a.speed as acceleration, b.speed as currentSpeed
insert into AccelerationStream