Using MapReduce in Cache [Deprecated]
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.
Note
This feature is only available in the NCache Enterprise.
Prerequisites for Using MapReduce
- 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.
// Pre-condition: 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