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:
|
| Window size: |
Select one of these options:
|
| Emission policy: |
Select one of these options:
|
