How to Implement and Execute MapReduce Tasks [Deprecated]
NCache enables you to utilize MapReduce for distributed data processing, allowing the execution of complex analytical tasks on the cache server. By moving the computation to where the data resides, NCache MapReduce minimizes network latency and improves performance for large-scale data aggregation. While this specific API is [Deprecated] in newer versions, it remains a critical framework for parallel task execution and massive data reduction in existing NCache 5.3 SP4 deployments.To use the MapReduce, initialize the MapReduce Task. Set the Mapper, Combiner, and the Reducer factory to the task and then execute the task on the cache.
Prerequisites
- To learn about the standard prerequisites required to work with all NCache server-side features, please refer to the given page Server-Side API Prerequisites.
- For API details, refer to: ICache, MapReduceTask, Combiner, Mapper, Reducer, ITrackableTask, GetResult, ITaskResult, IExecutionService, ExecuteTask, GetEnumerator.
The following example shows the sample usage of the MapReduce.
// Precondition: Cache is already connected
// Initialize MapReduce Task
MapReduceTask task = new MapReduceTask();
// Set Mapper, Combiner factory and Reducer factory
task.Mapper = new ProductCountMapper();
task.Combiner = new ProductCountCombinerFactory();
task.Reducer = new ProductCountReducerFactory();
// Execute task on cache
ITrackableTask wordCount = cache.ExecutionService.ExecuteTask(task, new ProductCountKeyFilter());
// Get result
ITaskResult result = wordCount.GetResult();
IDictionaryEnumerator enumResult = result.GetEnumerator();
while (enumResult.MoveNext())
{
// Perform operations
}
Note
To ensure the operation is fail-safe, it is recommended to handle any potential exceptions within your application, as explained in Handling Failures.
Warning
This feature is only supported till 5.3 SP4.
See Also
Sample Implementation of MapReduce
Aggregator
Entry Processor
Configure MapReduce