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 minute

Complex 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 action

The 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 processingCEP
Information modelContinuous timestamped data items.Atomic and composed event notifications.
Main focusFiltering, joins, aggregation, and query results.Detecting meaningful temporal/spatial patterns and triggering actions.
Origin/relationshipExtension of database/DSMS systems.Extension of publish/subscribe with event filtering/composition.
Typical resultA 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.md
  • master-cs/raw/iot/Question Sheet Week 5.md