Skip to main content
Version: Current

Aggregate Sliding

Mode: Streaming

Description​

note

This page describes the behavior specific to aggregations in the sliding window. For concepts and configuration common to all time-window aggregations, see Aggregations in time windows.

A sliding window calculates aggregate values over the most recent period of time. For example, a one-hour sliding window contains events from the most recent hour.

Whenever a new event arrives, the window moves forward to include that event, and the incoming event is enriched with aggregate values calculated over the current window. By default, an updated aggregate is produced only when a new event enters the window. If emitWhenEventLeft is true, Nussknacker produces an additional aggregate event when an older event leaves the window. This makes changes caused by both entering and leaving events observable downstream. As this is a new event, variables belonging to the original events, such as #input and #inputMeta, are therefore unavailable downstream.

Sliding window; emitWhenLeft=false

For simplicity, all events share the same groupBy value (= "purple")

 

Sliding window concept; emitWhenLeft=true

For simplicity, all events share the same groupBy value (= "purple")

Let's use the following example in case the above explanation is not clear. Imagine you are counting Porsches passing a point on a motorway using a one-hour sliding window, with a separate count for each color. To keep the example simple, consider only red Porsches. Suppose two pass the observation point: one at 9:25 and another at 9:45.

The following table shows aggregates emitted by the sliding-window in each configuration option.

TimeWhat happenedCount (emitWhenEventLeft is false)Count (emitWhenEventLeft is true)
9.25amFirst red Porsche enters11
9.45amSecond red Porsche enters22
10.25amFirst Porsche leaves the 1h windowN/A1
10.45amSecond Porsche leaves the 1h windowN/A0

Parameters and configuration​

Parameters common to all windows are described here.

NameDescription
windowLengthWindow `length
emitWhenEventLeftIf true, an additional aggregate event is emitted when an event leaves the window. Default: false.