Implementing Map/Reduce with PLINQ
This recipe will describe how to implement the Map/Reduce pattern while using PLINQ.
Getting ready
To begin with this recipe, you will need a running Visual Studio 2012. There are no other prerequisites. The source code for this recipe can be found at 7644_Code\Chapter10\Recipe4
.
How to do it...
To understand how to implement Map/Reduce with PLINQ, perform the following steps:
- Start Visual Studio 2012. Create a new C# Console Application project.
- In the
Program.cs
file, add the followingusing
directives:using System; using System.Collections.Generic; using System.IO; using System.Linq;
- Add the following code snippet below the
Main
method:private static readonly char[] delimiters =Enumerable.Range(0, 256).Select(i => (char)i).Where(c =>!char.IsLetterOrDigit(c)).ToArray(); private const string textToParse = @" Call me Ishmael. Some years ago - never mind how long precisely - having little or no money in my purse, and nothing particular to interest...