Object - streams : Sum

Aggregator to perform summation of values in a stream.

Methods

Fields

  • iSum int 0
  • Holds the sum when the value being aggregated is of type integer.

  • fSum float 0.0
  • Holds the sum when the value being aggregated is of type float.

process

(anydata value, EventType eventType)

returns anydata

Updates the current sum of numeric values based on the eventType. If the eventType is streams:CURRENT, value is added to the current sum. If the eventType is streams:EXPIRED, value is subtracted from the current sum. If the eventType is streams:RESET, Current summation will be reset, regardless the value.

Parameters

  • value anydata
  • The numeric value being aggregated to the current sum.

  • eventType EventType
  • Type of the incoming event streams:CURRENT, streams:EXPIRED or streams:RESET.

  • Return Type

    (anydata)
  • aggregated summation after the given value.

copy

()

returns Aggregator

Returns a copy of the Sum aggregator without its current state.

  • Return Type

    (Aggregator)
  • Returns Sum aggregator.

saveState

()

returns map

Return current state to be saved as a map of any typed values.

  • Return Type

    (map)
  • A map of any typed values.

restoreState

Restores the saved state which is passed as a map of any typed values.

Parameters

  • state map
  • A map of typed any values. This map contains the values to be restored from the persisted data.