Whenever an event arrives there needs be a query to calculate a new value using current event's value and last event's value and insert it in to a new stream. For an example:
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
When using #window.lengthBatch(2) it allows to calculate the acceleration once for each two events. Does not fulfil the requirement. Any thoughts?
you can use a sequence,
E.g
from a=SpeedStream,b=SpeedStream
select b.speed-a.speed as acceleration, b.speed as currentSpeed
insert into AccelerationStream