Stream Processing and Complex Events
IoT applications receive too many low-level measurements to handle individually. Stream processing and complex event processing filter, aggregate, and interpret dynamic data before it reaches the application.
Stream processing
A data stream is an unbounded, continuous sequence of timestamped items. Stream processing extends database processing with selections, joins, and aggregates over streams. A data-stream management system (DSMS) may combine streams with static/historical data.
A continuous query is registered once and keeps producing results while new data arrives, unlike a one-time query over a finite database. Windows make the infinite input manageable:
- Sliding: last 10 seconds, continuously updated.
- Stepped: last 10 seconds, evaluated every 5 seconds.
- Tumbling: non-overlapping 10-second windows, evaluated every 10 seconds.
- Tuple-based: last N samples.
Queries may be re-evaluated eagerly on every item (fresh but expensive) or periodically (cheaper but possibly stale/missing short patterns). CQELS extends SPARQL to process linked streams and static linked data.
Example pseudo-query:
CONTINUOUS QUERY hot_room
ON TemperatureReadings
WINDOW SLIDING 5 minutes, SLIDE 1 minute
SELECT room, AVG(temperature)
GROUP BY room
WHERE temperature > 0
EMIT EVERY 1 minuteComplex event processing (CEP)
CEP treats information as event notifications. An atomic event is a raw occurrence; a complex event is a meaningful temporal/spatial constellation of atomic events. CEP extends publish/subscribe with filtering and composition to detect patterns from several domains.
Events have a type, payload, and metadata such as source, timestamp, location, accuracy, or detection probability. Event-condition-action (ECA) rules have the form:
ON event-pattern
IF condition
DO actionThe action may create a higher-level event, notify an application, or trigger an actuator. Conditions can include values, event ordering, time ranges, location, aggregation, and historical trends.
Comparison
| Stream processing | CEP | |
|---|---|---|
| Information model | Continuous timestamped data items. | Atomic and composed event notifications. |
| Main focus | Filtering, joins, aggregation, and query results. | Detecting meaningful temporal/spatial patterns and triggering actions. |
| Origin/relationship | Extension of database/DSMS systems. | Extension of publish/subscribe with event filtering/composition. |
| Typical result | A continuously updated average or count. | “Two slow-traffic events in the same area within 30 minutes.” |
Both run continuously, filter input, can maintain temporal context, and can emit results/actions. Do not reduce ECA to only stateless threshold checks: the lecture allows temporal and historical conditions.
Sources
master-cs/raw/iot/4.3-IoT-Connected Data - Streams and Complex Events.mdmaster-cs/raw/iot/Question Sheet Week 5.md