Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
61 lines (39 sloc) 1.42 KB
create schema SmokeSensorEvent(
sensor string,
smoke boolean
);
create schema TemperatureSensorEvent(
sensor string,
temperature double
);
create schema FireEvent(
sensor string,
smoke boolean,
temperature double
);
@Name('Q0') select * from TemperatureSensorEvent
where temperature > 50;
@Name('Q1') select avg(temperature)
from TemperatureSensorEvent;
@Name('Q2') select avg(temperature)
from TemperatureSensorEvent.win:time(4 sec);
@Name('Q3') select avg(temperature)
from TemperatureSensorEvent.win:time_batch(4 sec);
@Name('Q4') select avg(temperature)
from TemperatureSensorEvent.win:length(5);
@Name('Q5') select avg(temperature)
from TemperatureSensorEvent.win:length_batch(5);
@Name('Q6') select avg(temperature)
from TemperatureSensorEvent.win:time(4 sec)
output snapshot every 2 sec;
@Name('Q7') select avg(temperature)
from TemperatureSensorEvent.win:length(4)
output snapshot every 2 events;
@Name('Q8') select a.sensor
from pattern [every (a = SmokeSensorEvent(smoke=true) -> TemperatureSensorEvent(temperature > 50, sensor=a.sensor)
where timer:within(2 sec))];
@Name('Final') insert into FireComplexEvent
select a.sensor as sensor, a.smoke as smoke, b.temperature as temperature
from pattern [every ( a = SmokeSensorEvent(smoke=true) -> b = TemperatureSensorEvent(temperature>5, sensor=a.sensor) where timer:within(2 sec) ) ] ;
@Name('Downstream') select count(*)
from FireComplexEvent.win:time(10 sec)