Aggregate analytic functions are a single class that implements the UserDefinedAggregationFunctionAdapter interface in the de.rtm.push.adapters package of the MashZone NextGen RAQL User Defined Function API.
Like window analytic functions, aggregate analytic functions have access to all rows, or records in the current group, partition or window. They perform an aggregate calculation that uses all records to return a single result. Depending on where they are used in RAQL queries, this single result may be all the query returns or it may be returned as a column on every row.
To accomplish this, aggregate analytic functions use the following methods:
There are also several 'housekeeping' methods you must implement: getAggregateType(), getParameterTypes(), isEmptyAggregate(S state), negativeCall(S state, Serializable[] values) and supportsPN().
You set up your development environment for aggregate analytic functions just the same as for plain functions. See Set Up Your Development Environment for details. Write the class for your aggregate analytic function and then Configure, Compile, Deploy and Test User-Defined Functions.
We’re going to use two examples. The first example, My Average Aggregate Example is an implementation of the built-in avg(Number column) method. This example shows the basics of an aggregate analytics function, how to track state for intermediate steps and then perform the final calculation.
The second example, Kurtosis Using a Third Party Library, uses methods in the Apache Commons Math library to calculate the kurtosis for a column. This is an example of how to use third-party libraries.