DistributedParallelExtensionsForEachT, P, R Method (IQueryableT, DistributedParallelOptions, P, FuncR, FuncT, P, R, R, FuncR, R, R)

ScaleOut Software NamedCache API
Executes a foreach operation by replicating the localInit, body, and merge methods to hosts in the distributed StateServer store and executed concurrently and may run in parallel on any given host.

Namespace:  Soss.Client
Assembly:  soss_namedcache (in soss_namedcache.dll) Version:

public static R ForEach<T, P, R>(
	this IQueryable<T> source,
	DistributedParallelOptions options,
	P param,
	Func<R> localInit,
	Func<T, P, R, R> body,
	Func<R, R, R> merge


Type: System.LinqIQueryableT
An enumerable source of data stored in the StateServer
Type: Soss.ClientDistributedParallelOptions
DistributedParallelOptions values to use when executing this operation
Type: P
a user-defined parameter which may be passed to all body delegates
Type: SystemFuncR
a delegate which returns the initial state of the local data for each task
Type: SystemFuncT, P, R, R
the delegate that is invoked once per iteration
Type: SystemFuncR, R, R
the delegate that performs pairwise merging on the local states of each task

Type Parameters

the type of the data elements in source
the type of the parameter passed to the body delegates.
the type of the value returned from the localInit delegate that is passed to each body delegate and is subsequently merged via the merge delegate.

Return Value

Type: R
the final merged value after all local results and all per-StateServer host results have been merged

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type IQueryableT. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).

The body delegate is invoked once for each element in the source enumerable. It is provided with the following parameters: the current element, the user-defined parameter value param, some local loop state that may be shared amongst iteration that execute on the same task.

The localInit delegate is invoked once for each task that participates in the loop's execution (on each host) and returns the initial local state for each of those tasks. These initial states are passed to the first body invocations on each task. Then ever subsequent body invocation returns a possibly modified state value that is passed to the next body invocation.

Local state values from multiple tasks are passed in pairwise fashion to the merge delegate which merges the pair into a single value. Once all local state values from a given host have been merged, they're consolidated from across the distributed store by passing the per-host results in a pairwise fashion to merge delegates hosted on one or more of the StateServer hosts. When all localState values have been merged to a single value, it is returned as the result of the ForEach method.

The source parameter must be a QueryFilter instance initially returned from QueryObjectsT and possibly filtered via one or more Linq where clauses.

See Also


Other Resources