HpcLinqQueryable.Apply Method (IQueryable, Expression)
Applies the specified function to a set of records.
Namespace: Microsoft.Hpc.Linq
Assembly: Microsoft.Hpc.Linq (in Microsoft.Hpc.Linq.dll)
Usage
'Usage
Dim source As IQueryable(Of T1)
Dim applyFunc As Expression(Of Func(Of IEnumerable(Of T1), IEnumerable(Of T2)))
Dim returnValue As IQueryable(Of T2)
returnValue = HpcLinqQueryable.Apply(source, applyFunc)
Syntax
'Declaration
<ExtensionAttribute> _
Public Shared Function Apply(Of T1, T2) ( _
source As IQueryable(Of T1), _
applyFunc As Expression(Of Func(Of IEnumerable(Of T1), IEnumerable(Of T2))) _
) As IQueryable(Of T2)
[ExtensionAttribute]
public static IQueryable<T2> Apply<T1,T2> (
IQueryable<T1> source,
Expression<Func<IEnumerable<T1>,IEnumerable<T2>>> applyFunc
)
[ExtensionAttribute]
public:
generic<typename T1, typename T2>
static IQueryable<T2>^ Apply (
IQueryable<T1>^ source,
Expression<Func<IEnumerable<T1>^, IEnumerable<T2>^>^>^ applyFunc
)
J# supports the use of generic APIs, but not the declaration of new ones.
JScript does not support generic types or methods.
GenericParameters
- T1
The type of the records in the source parameter.
- T2
The return type of the function that you specify in the applyFunc parameter.
Parameters
- source
An System.Linq.IQueryable<T1> interface for the set of records that you want to process.
- applyFunc
An System.Linq.Expressions.Expression(Func(IEnumerable<T1>, IEnumerable<T2>)) object that specifies the function that you want to apply to the records.
Return Value
An IQueryable interface that represents the set of records that result from applying the specified function to the input set of records.
Exceptions
| Exception type | Condition |
|---|---|
| ArgumentNullException | The specified source parameter is a null reference (Nothing in Visual Basic). |
Remarks
To apply a function to pairwise combinations of records from two sets of records, use the Apply(Generic IQueryable,Generic IQueryable,Generic Expression,Generic IEnumerable,Generic IEnumerable) form of the method. To apply the function to an arbitrary number of record sets, use the Apply(Generic IQueryable,Generic IQueryable,Generic Expression,Generic IEnumerable) form of the function.
The function that you specify in the applyFunc parameter does not need to return the same number of records that the input set of records contains. If the number of records that the function returns is always the same as the number of records in the input set of records and the function applies independent operations to each records, use the Select method instead.
If the function that you specify in the applyFunc parameter is marked with the DistributiveOverConcat attribute, the function runs in a distributed manner once for each DSC file in the input. An enumerable object that contains all of the records in the DSC file that is being processed is passed to the function, and the enumerable objects that the calls to the function return become the distributed output of the Apply operation. If you run additional queries on the output, such as running the Select method, those queries run in a distributed manner as well, because the output is partitioned across multiple compute nodes.
If the function that you specify in the applyFunc parameter is not marked with the DistributiveOverConcat attribute, the function runs on the entire set of records without distributed processing. If the input records are distributed across multiple compute nodes in the HPC cluster, LINQ to HPC collects the records in a single enumerable object and applies to the function to these records on a single compute node. The output of the function is an enumerable object that becomes the result of the Apply operation. If you run additional queries on the output, such as running the Select method, those queries run on a single node, because the Apply operation created output on a single node.
The enumerable object that is passed to the function that the applyFunc parameter specifies is designed to be streamed. Therefore, you can call the GetEnumerator method on that object only once, and cannot call the Reset method to change the position of the enumerator.
In Visual Basic and C#, you can call this method as an instance method on any object of type IQueryable<TSource>. 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).
This method has at least one parameter of type Expression with a type argument that is one of the Func types. For these parameters, you can pass in a lambda expression and it compiles to an Expression. For the Apply(Generic IQueryable,Generic Expression,Generic IEnumerable) method, you should only use lambda expression in the form of x => function_name(x) or x => x.function_name(). When you specify a lambda expression with these forms, LINQ to HPC checks the attributes of function_name to determine if it is marked with the DistributiveOverConcat attribute. If you use a lambda expression of another form, such as one that includes compound expressions, LINQ to HPC ignores DistributiveOverConcat attributes for any methods that occur in subexpressions, which could result in unintended behavior.
None of the built-in operators for LINQ to HPC are treated as if they are marked with the DistributiveOverConcat attribute. If you use these operators in the function that you specify in the applyFunc parameter, LINQ to HPC collapses the input into a single enumerable object and performs the query on a single node.
For more information about this method, see "Unary Apply" in the LINQ to HPC and DSC Programmer's Guide.
Platform Note: This method was introduced in Windows HPC Server 2008 R2 with Service Pack 2 (SP2) and is not supported in previous versions.
Thread Safety
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Platforms
Development Platforms
Windows XP, Windows Vista, Windows 7, Windows 8, Windows Server 2003, Windows Server 2008, Windows Server 2008 R2, Windows Server 2012
Target Platforms
Windows XP, Windows Vista, Windows 7, Windows Server 2003, Windows Server 2003 R2, Windows Server 2008, Windows Server 2008 R2, with HPC Pack Client Utilities
See Also
Reference
HpcLinqQueryable Class
HpcLinqQueryable Members
Microsoft.Hpc.Linq Namespace
Select
Apply(Generic IQueryable,Generic IQueryable,Generic Expression,Generic IEnumerable,Generic IEnumerable)
Apply(Generic IQueryable,Generic IQueryable,Generic Expression,Generic IEnumerable)
Build Date:
2013-04-22