Ejemplo n.º 1
0
 /// <summary>Implements a map-reduce operation.</summary>
 /// <typeparam name="TSource">Specifies the type of the source elements.</typeparam>
 /// <typeparam name="TMapped">Specifies the type of the mapped elements.</typeparam>
 /// <typeparam name="TKey">Specifies the type of the element keys.</typeparam>
 /// <typeparam name="TResult">Specifies the type of the results.</typeparam>
 /// <param name="source">The source elements.</param>
 /// <param name="map">A function used to get an enumerable of target data from a source element.</param>
 /// <param name="keySelector">A function used to get a key from target data.</param>
 /// <param name="reduce">A function used to reduce a group of elements to an enumerable of results.</param>
 /// <returns>The result elements of the reductions.</returns>
 public static ParallelQuery <TResult> MapReduce <TSource, TMapped, TKey, TResult>(
     this ParallelQuery <TSource> source,
     Func <TSource, IEnumerable <TMapped> > map,
     Func <TMapped, TKey> keySelector,
     Func <IGrouping <TKey, TMapped>, IEnumerable <TResult> > reduce) => source.
 SelectMany(map).
 GroupBy(keySelector).
 SelectMany(reduce);