Interface IAggregator
This interface provides implementaion to perform actual calculations on any data type and can perform different operations.
Assembly: Alachisoft.NCache.Runtime.dll
Syntax
[Obsolete("This feature is not in active development and may be removed in a future update.")]
public interface IAggregator
Methods
Aggregate(Object)
This method takes in an object and contains the logic of applying the aggregation operation on the same node (locally) just like with the Combiner. If you wish to combine values using an aggregator before being sent for further processing in the Reducer, you can use the Aggregate() call.
Declaration
object Aggregate(object value)
Parameters
Type | Name | Description |
---|---|---|
System.Object | value | Object. |
Returns
Type | Description |
---|---|
System.Object | Returns aggregated result. |
Examples
The following example illustrates 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)
This method takes in an object and contains the logic of applying the aggregation operation in the Reduce Phase. If you wish to combine values using an aggregator, you can use the AggregateAll() call.
Declaration
object AggregateAll(object value)
Parameters
Type | Name | Description |
---|---|---|
System.Object | value | Object. |
Returns
Type | Description |
---|---|
System.Object | Returns aggregated result. |
Examples
The following example illustrates the implementation of Aggregate.
string function;
//setting current aggregator function
public IntAggregator(string function)
{
this.function = function;
}
//Implementing 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;
}
}