Aggregate Operator: Field-Based Dimension Options

With a field-based dimension, a new window is established and evaluated based on the value of a numeric field in the incoming tuple. A tuple containing the results of the aggregation is emitted and the window closed when a tuple arrives whose field value exceeds the specified range of the open window.

The drop-down list of fields next to the Field button shows all fields in the incoming tuple of type int, long, double, or timestamp.

The field you select is typically a timestamp field, with the assumption that a timestamp field's values continue to increase with each new tuple, but tuples do not necessarily arrive at regular intervals. The window for a dimension based on a timestamp field can be set to emit and close based on elapsed time. However, the field you select can be any field containing numeric values.

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

TYPE = VALUE

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 by which to advance the window. Think of this setting as a slider for multiple windows.

      Note

      When you set an advance, the results can be sensitive to the advance of data actually received at runtime. For example, consider a dimension where the window size and advance are both 1, and at runtime a sequence of tuples arrives with the values 0 and 9.2, respectively. The first window opens at the value 0, as expected. However, the second window opens at 9.0, even though your advance is set to 1. This is because the Aggregate operator automatically advances the start of your next window to the next expression value received. The values between 0 and 9 represent empty windows, and are ignored by the Aggregate operator.

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

      For example, consider a field-based dimension based on a timestamp field, with a window size of 30 (seconds) and an Advance of 30. With no offset, we might see a series of windows at the following start intervals (based on the timestamps of the input tuples):

      0, 30, 60, 90...
      

      With an offset of 3, the same windows would have these starting timestamps:

      3, 33, 63, 93...
      

      Window starts are further influenced by whether the Open windows before first tuple option is set, as described below.

    The units for the values of Advance and Offset depend on the data type of the selected field. For example, if the selected field has the timestamp data type, an Advance value of 30 advances the window by 30 seconds.

    It is a typechecking error to try to specify a value of Advance greater than the value of Window size.

Window size: Select one of these options:
  • Do not close window based on this dimension: When 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]: When selected, sets the size of the window. The window is closed and an aggregation results tuple is emitted when a tuple is received whose key field's value exceeds the specified limit.

    When the Window size is the same as the Advance, only one window is open at a time for each group. When the Advance is less than the Window size, and the Open windows before first tuple option is set, windows overlap each other. For example, with a window size of 30 seconds and an Advance of 15, windows would be created every 15 seconds and stay open for 30 seconds.

Emission policy: Select one of these options:
  • No intermediate emissions based on this dimension: When selected, this dimension does not force an immediate emission of a results tuple.

  • Intermediate emission every [number]: When selected, allows tuples to be emitted before the window closes. For example, if the selected field has the timestamp data type and the Window size is set to 8, you could specify an intermediate emission every 4 seconds, instead of waiting for the Window size limit to be met.

Optional windows: For field-based aggregates, the only available option in this section is Open windows before first tuple.

When this check box is cleared (the default setting), the first window is not created until the specified Window size is reached, and the operator emits tuples only when windows meet the criteria above.

Selecting this check box only has an effect when the Advance value is less than the Window size value. In this case, the results depend on whether you specify any group-by fields in the Group Options tab:

  • With no grouping specified, this option's effect is to open the first window immediately and begin to accumulate any tuples that arrive before the Window size is reached. One or more extra tuples are emitted at the beginning, and after any gap in the accumulating values.

  • With groups specified, this option's effect is to open the first window immediately as above, and to emit extra tuples for partial, intermediate windows.


Back to Top ^