streamcruncher.api.aggregator
Class AbstractAggregator

java.lang.Object
  extended by streamcruncher.api.aggregator.AbstractAggregator
Direct Known Subclasses:
TimeWF2PartitionAggTest.TestAggregator

public abstract class AbstractAggregator
extends java.lang.Object

Custom Aggregator functions can be plugged into the Kernel before the Query is registered. The APIs provide a means to register and unregister these custom functions. Such custom Aggregators must extend this Class. The Sub-classes must have a no argument constructor.

When the Kernel creates a Window in a Partition that uses the function name against which this Aggregate is registered, an instance of the registered Class is created and used. When the Window expires, the corresponding Aggregator instance is also discarded.


Nested Class Summary
static class AbstractAggregator.AggregationStage
           This feature is to provide a choice for the User to decide whether an Event's entrance into a Window only or both entrance and exit should affect the aggregate.
 
Constructor Summary
AbstractAggregator()
           
 
Method Summary
abstract  java.lang.Object aggregate(java.util.List<java.lang.Object[]> removedValues, java.util.List<java.lang.Object[]> addedValues)
           At the end of each Query execution, this method will be called to aggregate the Events in the Window over which this Aggregate is created.
 AbstractAggregator.AggregationStage getAggregationStage()
           
 java.util.LinkedHashMap<java.lang.String,java.lang.String> getColumnNamesAndTypes()
           
 java.lang.String[] getParams()
           
 void init(java.lang.String[] params, java.util.LinkedHashMap<java.lang.String,java.lang.String> columnNamesAndTypes, AbstractAggregator.AggregationStage aggregationStage)
          Note: This class' method must be invoked even if it is over-ridden (i.e super.init(...)).
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractAggregator

public AbstractAggregator()
Method Detail

init

public void init(java.lang.String[] params,
                 java.util.LinkedHashMap<java.lang.String,java.lang.String> columnNamesAndTypes,
                 AbstractAggregator.AggregationStage aggregationStage)
Note: This class' method must be invoked even if it is over-ridden (i.e super.init(...)).

Parameters:
params - Parameters that were supplied to the function in the "Running Query". Ex: A definition such as with custom(test_fn, order_id, J) as test_fn_val will produce String[]{"order_id", "J"}
columnNamesAndTypes - The same order in which the columns are placed in Lists in aggregate(List, List).
aggregationStage -

getColumnNamesAndTypes

public java.util.LinkedHashMap<java.lang.String,java.lang.String> getColumnNamesAndTypes()

getParams

public java.lang.String[] getParams()

getAggregationStage

public AbstractAggregator.AggregationStage getAggregationStage()

aggregate

public abstract java.lang.Object aggregate(java.util.List<java.lang.Object[]> removedValues,
                                           java.util.List<java.lang.Object[]> addedValues)

At the end of each Query execution, this method will be called to aggregate the Events in the Window over which this Aggregate is created.

One of the parameters (added/removed) can be null. But, never both.

Parameters:
removedValues - List of rows that were removed in the current cycle. Each array in the list is a group of columns in that Row.
addedValues - List of rows added in the current cycle. Each array in the list is a group of columns in that Row.
Returns:
The aggregated value or null for some cases (Ex: In-built functions return a null if the aggregate calculation yields a NaN).
See Also:
for the names and types of the data/columns.


Copyright © 2006 - 2008 Ashwin Jayaprakash. All Rights Reserved. (Docs generated on 3-November-2007 )