Interface IAggregator
Performs actual grouping and analytical operations on data. Aggregator can perform following operations: Average, Sum, Min, Max, Count, Distinct. If result after aggregation execution is null than default value of built in Aggregator for that specific type is returned. Custom aggregator, for custom data types and custom functions like Mean, Median, Mode can also be implementated.
Namespace:
Assembly: Alachisoft.NCache.Runtime.dll
Syntax
public interface IAggregator
Aggregate(Object)
Performs given logic of aggregation on a on local node like combiner.
Declaration
object Aggregate(object value)
Parameters
Type | Name | Description |
---|---|---|
System.Object | value | object |
Returns
Type | Description |
---|---|
System.Object | Retuns aggregated result. |
Examples
Following example illustrate the implementation of Aggregate.
string function;
//setting current aggregator function
public IntAggregator(string function)
{
this.function = function;
}
//Implementing interface function
public object Aggregate(object value)
{
return calculate(value);
}
//Function to calculate values
private object calculate(object value)
{
switch (function)
{
case "MIN":
value = int.MinValue;
return value;
case "MAX":
value = int.MaxValue;
return value;
default:
return 0;
}
}
AggregateAll(Object)
Performs given logic of aggregation on server nodes like Reduce phase operation.
Declaration
object AggregateAll(object value)
Parameters
Type | Name | Description |
---|---|---|
System.Object | value | object |
Returns
Type | Description |
---|---|
System.Object | Retuns aggregated result. |
Examples
Following example illustrate the implementation of Aggregate.
string function;
//setting current aggregator function
public IntAggregator(string function)
{
this.function = function;
}
//Implementating interface function
public object AggregateAll(object value)
{
return calculate(value); //implement inside logic.
}
//Function to calculate values
private object calculate(object value)
{
switch (function)
{
case "MIN":
value = int.MinValue;
return value;
case "MAX":
value = int.MaxValue;
return value;
default:
return 0;
}
}