This page gives some advice to create a new Aggregation function.
This page is under construction.
Interfaces for a new function
An aggregation function needs to implement one of the following interfaces:
de.uniol.inf.is.odysseus.aggregation.functions.IIncrementalAggregationFunction
An incremental aggregation functions gets a notification when an element gets valid (enters the window) or gets invalid (leaves the window). You have to hold a state to return the current aggregation value on request.void addNew(T newElement);
This method is called when a new element gets valid. You should add this value to the state.
For example AVG function: State holdssum
andcount
.sum += newElement
andcount++
void removeOutdated(Collection<T> outdatedElements, T trigger, PointInTime pointInTime);
This method is called when a set of elements get invalid. You should remove these values from the state.
For example AVG function: For each element in outdatedElements:sum -= element
andcount--
Object[] evalute(T trigger, PointInTime pointInTime);
This method is called when a new aggregation value should returned.
For example AVG function:return sum/count
de.uniol.inf.is.odysseus.aggregation.functions.INonIncrementalAggregationFunction
An non-incremental function gets a set of all elements in the current window. It does not have to hold a state.Object[] evaluate(Collection<T> elements, T trigger, PointInTime pointInTime);
This method is called when a new aggregation value should returned.elements
holds all elements in the window that starts atpointInTime
.
In de.uniol.inf.is.odysseus.aggregation.functions
there are also abstract classes.
Function Registry and Function Factories
- Implement
de.uniol.inf.is.odysseus.aggregation.functions.factory.IAggregationFunctionFactory
to allow Odysseus to create a new function. - Add OSGi service to add function to the registry (
de.uniol.inf.is.odysseus.aggregation.AggregationFunctionRegistry
).