Value based Filtering

This application demonstrates filter out events based on simple conditions such as number value, range or null type.

define stream TemperatureStream (
 sensorId string, temperature double);

@info(name = 'EqualsFilter')
from TemperatureStream[ sensorId == 'A1234']
select *
insert into SenorA1234TemperatureStream;

@info(name = 'RangeFilter') 
from TemperatureStream[ temperature > -2 and temperature < 40]
select *
insert into NormalTemperatureStream;

@info(name = 'NullFilter') 
from TemperatureStream[ sensorId is null ]
select *
insert into InValidTemperatureStream;
define stream TemperatureStream (
 sensorId string, temperature double);

Defines TemperatureStream stream to process events having sensorId and temperature(F).

@info(name = 'EqualsFilter')
from TemperatureStream[ sensorId == 'A1234']

Filter out events with sensorId equalling A1234

select *
insert into SenorA1234TemperatureStream;
@info(name = 'RangeFilter') 
from TemperatureStream[ temperature > -2 and temperature < 40]

Filter out events where -2 < temperature < 40

select *
insert into NormalTemperatureStream;
@info(name = 'NullFilter') 
from TemperatureStream[ sensorId is null ]

Filter out events with SensorId being null

select *
insert into InValidTemperatureStream;

Input

Below events are sent to TemperatureStream,

  1. ['A1234', 39]
  2. ['sensor1', 35]
  3. [null, 43]

Output

After processing, the following events will be arriving at each stream:

  • SenorA1234TemperatureStream:
    ['A1234', 39] only

  • NormalTemperatureStream:
    ['sensor1', 35] only

  • InValidTemperatureStream:
    [null, 43] only

Top