Aggregate Operator: Time-Based Dimension Options

In the Aggregate operator Dimensions tab, you can open the Edit Dimension dialog to add, edit, or remove dimensions from the Aggregate operator. With a time-based dimension, a new window is managed and evaluated based on the time a tuple arrives. For example, a tuple containing the aggregate results may be emitted and the window closed when a tuple arrives outside the period allowed for the currently open window. The new tuple begins the next window.

Caution

Using a time-based dimension can cause unnecessary waits in testing or operation, makes deterministic tuple-by-tuple playback in unit tests and feed simulations impossible, and complicates high availability design patterns.

In general, StreamBase Systems recommends avoiding the use of the time-based dimension for most applications. Instead, use a field-based dimension with a timestamp field, or a predicate dimension with an expression such as lastval(input1.time) - firstval(input1.time) > seconds(30) to create a 30 second window.

If your application does require an Aggregate operator to be driven by wall-clock time, use a Metronome or Heartbeat operator to send tuples that trigger the processing you need. In this case, the best practice is to separate your business logic that includes the Aggregate operator into an isolated inner module, and place infrastructure-connected operators, such as a Metronome, in an outer module that drives the inner module by passing in a timestamp field as a parameter.

The following example clarifies the behavior of the time-based dimension option:

  • An aggregate is set with the dimension for window opening and closing to 60 seconds with no intermediate output.

  • A tuple arrives at 58 seconds.

  • Time 60 seconds goes by with no output.

  • A tuple arrives at time 62 seconds. This closes the current window and produces an output tuple. The tuple that arrived at 62 seconds is placed into the next window.

The following table describes the options available in the Edit Dimension dialog for time-based dimensions.

TYPE = TIME

Category Options and Meaning
Opening policy: Select one of these options:
  • Do not open window based on this dimension: If selected, this dimension cannot cause the opening of a new window for the Aggregate.

  • Open per:

    • Advance: The amount in seconds by which to advance the window. Think of this setting as a "slider" for multiple windows.

    • Offset: A value by which to increment the start of windows. Windows will start at the offset plus positive integer multiples of the Advance. By default, the value of offset is 0.

      To understand offsets, consider a time-based dimension where the window size is 1 hour (3600 seconds). With no offset, windows advance by multiples of the window advance. So with an advance of 3600 we expect to see windows at exact hourly intervals, like 8:00, 9:00, 10:00, and so on. But suppose you want windows to start at fifteen minutes past the hour. If you set the offset to 900 seconds, the preceding window start times would change to 8:15, 9:15, 10:15, and so on.

Window size: Select one of these options:
  • Do not close window based on this dimension: If selected, this dimension cannot cause the closing of a new window for the Aggregate. If a new window is never opened, and Do not close is selected, this creates an infinite sized window that never closes (for the life of the StreamBase Server instance).

  • Close and emit after [number] seconds: If selected, sets the number of seconds the window will remain open. When the number of seconds elapses, the window closes and an aggregate tuple is emitted.

Emission policy: Select one of these options:
  • No intermediate emissions based on this dimension: If selected, this dimension does not force an immediate emission of a results tuple (after applying the function's calculation to the tuples in the window).

  • Intermediate emission every [number] seconds: If selected, allows tuples to be emitted before the window closes. For example, one could emit a tuple every second during the 30-second window, instead of waiting for the window to close.


Back to Top ^