Method Aggregate
Aggregate(IValueExtractor, IAggregator)
Built upon MapReduce framework, processes distributed data records to return compiled and statistical results for analytical purposes.
Declaration
public virtual object Aggregate(IValueExtractor extractor, IAggregator aggregator)
Parameters
Type | Name | Description |
---|---|---|
IValueExtractor | extractor | Implementation of IValueExtractor to extract the meaningful attributes from given objects |
IAggregator | aggregator | For actual grouping and analytical operations on given data using Map Reduce Combiner and Reducer |
Returns
Type | Description |
---|---|
System.Object | Returns a single result depending upon given extractor. |
Examples
IAggregator 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. User can also implement custom aggregator, as well as aggregator for custom data types and also for custom functions like Mean, Median, Mode.
Cache _cache= NCache.InitializeCache("myCache");
product1 = new Product(3, "Tunnbr?d", "", 4, 2);
product2 = new Product(4, "Tunnbr?d", "", 5, 9);
_cache.Add("2202", product1);
_cache.Add("2203", product2);
int value = (int)cache.Aggregate(new BasicTypeExtractor(), BuiltInAggregator.IntegerSum());
// IValueExtractor Implementation
public class BasicTypeExtractor : IValueExtractor
{
public object Extract(object value)
{
try
{
if (value.GetType() == typeof(int))
{
return 0;
}
if (value.GetType() == typeof(float))
{
return 0.0;
}
}
catch (Exception e)
{
//handle exception
}
return value;
}
}
Aggregate(IValueExtractor, IAggregator, Int32)
It is built on MapReduce framework. It processes distributed data records to return compiled and statistical results for analytical purposes. Time out can also be specified. After that specified time, time out exception will be thrown and thread will be terminated.
Declaration
public virtual object Aggregate(IValueExtractor extractor, IAggregator aggregator, int timeout)
Parameters
Type | Name | Description |
---|---|---|
IValueExtractor | extractor | Implementation of IValueExtractor to extract the meaningful attributes from given objects |
IAggregator | aggregator | Returns a single result depending upon given extractor. |
System.Int32 | timeout | Time in millisecond in which if result is not returned, thread will be terminated and exception or null will be given. |
Returns
Type | Description |
---|---|
System.Object | Returns a single result depending upon given extractor. |
Examples
IAggregator 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. User can also implement custom aggregator, as well as aggregator for custom data types and also for custom functions like Mean, Median, Mode.
Cache _cache= NCache.InitializeCache("myCache");
product1 = new Product(3, "Tunnbr?d", "", 4, 2);
product2 = new Product(4, "Tunnbr?d", "", 5, 9);
_cache.Add("2202", product1);
_cache.Add("2203", product2);
object result =_cache.Aggregate(new BasicTypeExtractor(), BuiltInAggregator.Count(), 60000);
// IValueExtractor Implementaion
public class BasicTypeExtractor : IValueExtractor
{
public object Extract(object value)
{
try
{
if (value.GetType() == typeof(int))
{
return 0;
}
if (value.GetType() == typeof(float))
{
return 0.0;
}
}
catch (Exception e)
{
//handle exception
}
return value;
}
}
Aggregate(IValueExtractor, IAggregator, IKeyFilter)
Built upon MapReduce framework, processes distributed data records to return compiled and statistical results for analytical purposes. You can specify key filters with this as well.
Declaration
public virtual object Aggregate(IValueExtractor extractor, IAggregator aggregator, IKeyFilter keyFilter)
Parameters
Type | Name | Description |
---|---|---|
IValueExtractor | extractor | Implementation of IValueExtractor to extract the meaningful attributes from given objects |
IAggregator | aggregator | Returns a single result depending upon given extractor. |
IKeyFilter | keyFilter | Instance of IKeyFilter implementation. |
Returns
Type | Description |
---|---|
System.Object | Returns a single result depending upon given extractor. |
Examples
IAggregator 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. User can also implement custom aggregator, as well as aggregator for custom data types and also for custom functions like Mean, Median, Mode.
Cache _cache= NCache.InitializeCache("myCache");
product1 = new Product(3, "Tunnbr?d", "", 4, 2);
product2 = new Product(4, "Tunnbr?d", "", 5, 9);
_cache.Add("2202", product1);
_cache.Add("2203", product2);
AggregatorKeyFilter keyFilter= new AggregatorKeyFilter();
object result =_cache.Aggregate(new BasicTypeExtractor(), BuiltInAggregator.Count(),keyFilter);
// IValueExtractor Implementation
public class BasicTypeExtractor : IValueExtractor
{
public object Extract(object value)
{
try
{
if (value.GetType() == typeof(int))
{
return 0;
}
if (value.GetType() == typeof(float))
{
return 0.0;
}
}
catch (Exception e)
{
//handle exception
}
return value;
}
}
//implementation of IKeyFilter
public class AggregatorKeyFilter : IKeyFilter
{
public bool FilterKey(object key)
{
try
{
if (key.ToString().Contains("hungry"))
{
return true;
}
}
catch (Exception exp)
{
//handle exception
}
return false;
}
}
Aggregate(IValueExtractor, IAggregator, String, Hashtable)
Built upon MapReduce framework, processes distributed data records to return compiled and statistical results for analytical purposes. Queries and parameters can be specified with this.
Declaration
public virtual object Aggregate(IValueExtractor extractor, IAggregator aggregator, string query, Hashtable parameters)
Parameters
Type | Name | Description |
---|---|---|
IValueExtractor | extractor | Implementation of IValueExtractor to extract the meaningful attributes from given objects |
IAggregator | aggregator | Returns a single result depending upon given extractor. |
System.String | query | Simple sql like NCache query string |
System.Collections.Hashtable | parameters | NCache query string parameters that can be searched. |
Returns
Type | Description |
---|---|
System.Object | Returns a single result depending upon given extractor |
Examples
IAggregator 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. User can also implement custom aggregator, as well as aggregator for custom data types and also for custom functions like Mean, Median, Mode.
Cache _cache= NCache.InitializeCache("myCache");
product1 = new Product(3, "Tunnbr?d", "", 4, 2);
product2 = new Product(4, "Tunnbr?d", "", 5, 9);
_cache.Add("2202", product1);
_cache.Add("2203", product2);
Hashtable values = new Hashtable();
values.Add("ProductID", 3);
String query = "SELECT Product WHERE this.ProductID=?;
object result =_cache.Aggregate(new BasicTypeExtractor(), BuiltInAggregator.Count(),query,values);
// IValueExtractor Implementation
public class BasicTypeExtractor : IValueExtractor
{
public object Extract(object value)
{
try
{
if (value.GetType() == typeof(int))
{
return 0;
}
if (value.GetType() == typeof(float))
{
return 0.0;
}
}
catch (Exception e)
{
//handle exception
}
return value;
}
}
Aggregate(IValueExtractor, IAggregator, String, Hashtable, Int32)
Built upon MapReduce framework, processes distributed data records to return compiled and statistical results for analytical purposes. Queries, parameters and time out can be specified as well.
Declaration
public virtual object Aggregate(IValueExtractor extractor, IAggregator aggregator, string query, Hashtable parameters, int timeout)
Parameters
Type | Name | Description |
---|---|---|
IValueExtractor | extractor | Implementation of IValueExtractor to extract the meaningful attributes from given objects |
IAggregator | aggregator | Returns a single result depending upon given extractor. |
System.String | query | Simple sql like NCache query string |
System.Collections.Hashtable | parameters | NCache query string searchable parameters. |
System.Int32 | timeout | Time in millisecond in which if result is not returned, thread will be terminated and exception or null will be returned. |
Returns
Type | Description |
---|---|
System.Object | Returns a single result depending upon given extractor. |
Examples
IAggregator 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. User can also implement custom aggregator, as well as aggregator for custom data types and also for custom functions like Mean, Median, Mode.
Cache _cache= NCache.InitializeCache("myCache");
product1 = new Product(3, "Clothes", "", 4, 2);
product2 = new Product(4, "Shoes", "", 5, 9);
_cache.Add("2202", product1);
_cache.Add("2203", product2);
Hashtable values = new Hashtable();
values.Add("Category", "Clothes");
String query = "SELECT Product WHERE this.Category=?;
object result =_cache.Aggregate(new BasicTypeExtractor(), BuiltInAggregator.Count(),query,values, 50000);
// IValueExtractor Implementation
public class BasicTypeExtractor : IValueExtractor
{
public object Extract(object value)
{
try
{
if (value.GetType() == typeof(int))
{
return 0;
}
if (value.GetType() == typeof(float))
{
return 0.0;
}
}
catch (Exception e)
{
//handle exception
}
return value;
}
}
Aggregate(IValueExtractor, IAggregator, IKeyFilter, Int32)
Built upon MapReduce framework, processes distributed data records to return compiled and statistical results for analytical purposes. You can specify key filter as well as time out.
Declaration
public virtual object Aggregate(IValueExtractor extractor, IAggregator aggregator, IKeyFilter keyFilter, int timeout)
Parameters
Type | Name | Description |
---|---|---|
IValueExtractor | extractor | Implementation of IValueExtractor to extract the meaningful attributes from given objects |
IAggregator | aggregator | Returns a single result depending upon given extractor. |
IKeyFilter | keyFilter | Instance of IKeyFilter implementation. |
System.Int32 | timeout | Time in millisecond in which if result is not returned, thread will be terminated and exception or null will be given. |
Returns
Type | Description |
---|---|
System.Object | Returns a single result depending upon given extractor |
Examples
IAggregator 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. User can also implement custom aggregator, as well as aggregator for custom data types and also for custom functions like Mean, Median, Mode.
Cache _cache= NCache.InitializeCache("myCache");
product1 = new Product(3, "Tunnbr?d", "", 4, 2);
product2 = new Product(4, "Tunnbr?d", "", 5, 9);
_cache.Add("2202", product1);
_cache.Add("2203", product2);
AggregatorKeyFilter keyFilter= new AggregatorKeyFilter();
object result =_cache.Aggregate(new BasicTypeExtractor(), BuiltInAggregator.IntegerMax(),keyFilter,40000);
// IValueExtractor Implementation
public class BasicTypeExtractor : IValueExtractor
{
public object Extract(object value)
{
try
{
if (value.GetType() == typeof(int))
{
return 0;
}
if (value.GetType() == typeof(float))
{
return 0.0;
}
}
catch (Exception e)
{
//handle exception
}
return value;
}
}
//implementation of IKeyFilter
public class AggregatorKeyFilter : IKeyFilter
{
public bool FilterKey(object key)
{
try
{
if (key.ToString().Contains("hungry"))
{
return true;
}
}
catch (Exception exp)
{
//handle exception
}
return false;
}
}