Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Excerpt
hiddentrue

Siddhi Inbuilt Aggregate Functions in wiki format

Following are the supported inbuilt aggregate functions of Siddhi.

Table of Contents
maxLevel3
minLevel3

sum
Anchor
sum
sum

Syntax<long|double> sum(<int|long|double|float> arg)
Extension TypeAggregate Function
DescriptionCalculates the sum for all the events.
ParameterThe value that needs to be summed.
Return TypeReturns long if the input parameter type is int or long, and returns double if the input parameter type is float or double.
Examples
  • sum(20) returns sum of 20s as a long value for each event arrival and expiry. sum(temp) returns the sum of all temp attributes based on each event arrival and expiry.

 

<long|double> sum(<int|long|double|float> arg)

  • Extension TypeAggregate Function 
  • Description: Sums all the events.
  • Parameterarg: The value that need to be summed.
  • Return Type: Returns long if the input parameter type is int or long and Returns double if the input parameter type is float or double.
  • Examplessum(20) returns sum of 20s as a long value for each event arrival and expiry. sum(temp) returns the sum of all temp attributes based on each event arrival and expiry.

avg
Anchor
avg
avg

Syntax 
Extension Type 
Description 
Parameter 
Return Type 
Examples

<double> avg(<int|long|double|float> arg)

  • Extension Type: Aggregate Function
  • Description: Calculates the average for all the events.
  • Parameter: arg: The value that need to be averaged.
  • Return Type: Returns calculated average value as a double.
  • Examples: avg(temp) returns the average temp value for all the events based on their arrival and expiry.

max
Anchor
max
max

Syntax 
Extension Type 
Description 
Parameter 
Return Type 
Examples

<int|long|double|float> max(<int|long|double|float> arg)

  • Extension Type: Aggregate Function
  • Description: Returns the max value for all the events.
  • Parameter: arg: The value that need to be compared to find the max value.
  • Return Type: Returns max value in same type as the input.
  • Examples: max(temp) returns the maximum temp value recorded for all the events based on their arrival and expiry.

min
Anchor
min
min

Syntax 
Extension Type 
Description 
Parameter 
Return Type 
Examples

<int|long|double|float> min(<int|long|double|float> arg)

  • Extension Type: Aggregate Function
  • Description: Returns the min value for all the events.
  • Parameter: arg: The value that need to be compared to find the min value.
  • Return Type: Returns min value in same type as the input.
  • Examples: min(temp) returns the minimum temp value recorded for all the events based on their arrival and expiry.

count
Anchor
count
count

Syntax 
Extension Type 
Description 
Parameter 
Return Type 
Examples

<long> count()

  • Extension Type: Aggregate Function
  • Description: Returns the count of all the events.
  • Return Type: Returns event count as a long.
  • Examples: count() will return the count of all the events.

stddev
Anchor
stddev
stddev

Syntax 
Extension Type 
Description 
Parameter 
Return Type 
Examples

<double> stddev(<int|long|double|float> arg)

...