Repository: ignite Updated Branches: refs/heads/ignite-1282 52534c33a -> 81feb9596
IGNITE-1664 .Net: Reviewed and fixed generic type arguments in the API. Project: http://git-wip-us.apache.org/repos/asf/ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/81feb959 Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/81feb959 Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/81feb959 Branch: refs/heads/ignite-1282 Commit: 81feb9596657c432efe404e6046a142b8f831df3 Parents: 52534c3 Author: Pavel Tupitsyn <[email protected]> Authored: Wed Oct 14 14:56:17 2015 +0300 Committer: vozerov-gridgain <[email protected]> Committed: Wed Oct 14 14:56:17 2015 +0300 ---------------------------------------------------------------------- .../Cache/CacheTestAsyncWrapper.cs | 10 +-- .../dotnet/Apache.Ignite.Core/Cache/ICache.cs | 14 ++-- .../Cache/ICacheEntryProcessor.cs | 8 +- .../Compute/ComputeTaskAdapter.cs | 16 ++-- .../Compute/ComputeTaskSplitAdapter.cs | 8 +- .../Apache.Ignite.Core/Compute/ICompute.cs | 82 ++++++++++---------- .../Apache.Ignite.Core/Compute/IComputeFunc.cs | 8 +- .../Apache.Ignite.Core/Compute/IComputeJob.cs | 4 +- .../Compute/IComputeJobResult.cs | 6 +- .../Compute/IComputeReducer.cs | 8 +- .../Apache.Ignite.Core/Compute/IComputeTask.cs | 24 +++--- .../Datastream/StreamTransformer.cs | 12 +-- .../Apache.Ignite.Core/Impl/Cache/CacheImpl.cs | 18 ++--- .../Impl/Cache/CacheProxyImpl.cs | 6 +- .../Apache.Ignite.Core/Impl/Compute/Compute.cs | 40 +++++----- .../Impl/Compute/ComputeAsync.cs | 61 ++++++++------- .../Impl/Compute/ComputeImpl.cs | 79 ++++++++++--------- 17 files changed, 209 insertions(+), 195 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ignite/blob/81feb959/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheTestAsyncWrapper.cs ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheTestAsyncWrapper.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheTestAsyncWrapper.cs index 52a856a..c4e8d7e 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheTestAsyncWrapper.cs +++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheTestAsyncWrapper.cs @@ -340,20 +340,20 @@ namespace Apache.Ignite.Core.Tests.Cache } /** <inheritDoc /> */ - public TR Invoke<TR, TA>(TK key, ICacheEntryProcessor<TK, TV, TA, TR> processor, TA arg) + public TRes Invoke<TArg, TRes>(TK key, ICacheEntryProcessor<TK, TV, TArg, TRes> processor, TArg arg) { _cache.Invoke(key, processor, arg); - return GetResult<TR>(); + return GetResult<TRes>(); } /** <inheritDoc /> */ - public IDictionary<TK, ICacheEntryProcessorResult<TR>> InvokeAll<TR, TA>(IEnumerable<TK> keys, - ICacheEntryProcessor<TK, TV, TA, TR> processor, TA arg) + public IDictionary<TK, ICacheEntryProcessorResult<TRes>> InvokeAll<TArg, TRes>(IEnumerable<TK> keys, + ICacheEntryProcessor<TK, TV, TArg, TRes> processor, TArg arg) { _cache.InvokeAll(keys, processor, arg); - return GetResult<IDictionary<TK, ICacheEntryProcessorResult<TR>>>(); + return GetResult<IDictionary<TK, ICacheEntryProcessorResult<TRes>>>(); } /** <inheritDoc /> */ http://git-wip-us.apache.org/repos/asf/ignite/blob/81feb959/modules/platforms/dotnet/Apache.Ignite.Core/Cache/ICache.cs ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Cache/ICache.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/ICache.cs index 097ab66..98ac254 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Core/Cache/ICache.cs +++ b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/ICache.cs @@ -451,15 +451,15 @@ namespace Apache.Ignite.Core.Cache /// If an entry does not exist for the specified key, an attempt is made to load it (if a loader is configured) /// or a surrogate entry, consisting of the key with a null value is used instead. /// </summary> - /// <typeparam name="TR">The type of the result.</typeparam> - /// <typeparam name="TA">The type of the argument.</typeparam> + /// <typeparam name="TArg">The type of the argument.</typeparam> + /// <typeparam name="TRes">The type of the result.</typeparam> /// <param name="key">The key.</param> /// <param name="processor">The processor.</param> /// <param name="arg">The argument.</param> /// <returns>Result of the processing.</returns> /// <exception cref="CacheEntryProcessorException">If an exception has occured during processing.</exception> [AsyncSupported] - TR Invoke<TR, TA>(TK key, ICacheEntryProcessor<TK, TV, TA, TR> processor, TA arg); + TRes Invoke<TArg, TRes>(TK key, ICacheEntryProcessor<TK, TV, TArg, TRes> processor, TArg arg); /// <summary> /// Invokes an <see cref="ICacheEntryProcessor{K, V, A, R}"/> against a set of keys. @@ -471,8 +471,8 @@ namespace Apache.Ignite.Core.Cache /// Furthermore there is no guarantee implementations will use the same processor instance /// to process each entry, as the case may be in a non-local cache topology. /// </summary> - /// <typeparam name="TR">The type of the result.</typeparam> - /// <typeparam name="TA">The type of the argument.</typeparam> + /// <typeparam name="TArg">The type of the argument.</typeparam> + /// <typeparam name="TRes">The type of the result.</typeparam> /// <param name="keys">The keys.</param> /// <param name="processor">The processor.</param> /// <param name="arg">The argument.</param> @@ -483,8 +483,8 @@ namespace Apache.Ignite.Core.Cache /// </returns> /// <exception cref="CacheEntryProcessorException">If an exception has occured during processing.</exception> [AsyncSupported] - IDictionary<TK, ICacheEntryProcessorResult<TR>> InvokeAll<TR, TA>(IEnumerable<TK> keys, - ICacheEntryProcessor<TK, TV, TA, TR> processor, TA arg); + IDictionary<TK, ICacheEntryProcessorResult<TRes>> InvokeAll<TArg, TRes>(IEnumerable<TK> keys, + ICacheEntryProcessor<TK, TV, TArg, TRes> processor, TArg arg); /// <summary> /// Creates an <see cref="ICacheLock"/> instance associated with passed key. http://git-wip-us.apache.org/repos/asf/ignite/blob/81feb959/modules/platforms/dotnet/Apache.Ignite.Core/Cache/ICacheEntryProcessor.cs ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Cache/ICacheEntryProcessor.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/ICacheEntryProcessor.cs index c8614c0..7a0fff1 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Core/Cache/ICacheEntryProcessor.cs +++ b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/ICacheEntryProcessor.cs @@ -30,9 +30,9 @@ namespace Apache.Ignite.Core.Cache /// </summary> /// <typeparam name="TK">Key type.</typeparam> /// <typeparam name="TV">Value type.</typeparam> - /// <typeparam name="TA">The type of the processor argument.</typeparam> - /// <typeparam name="TR">The type of the processor result.</typeparam> - public interface ICacheEntryProcessor<in TK, TV, in TA, out TR> + /// <typeparam name="TArg">The type of the processor argument.</typeparam> + /// <typeparam name="TRes">The type of the processor result.</typeparam> + public interface ICacheEntryProcessor<in TK, TV, in TArg, out TRes> { /// <summary> /// Process an entry. @@ -40,6 +40,6 @@ namespace Apache.Ignite.Core.Cache /// <param name="entry">The entry to process.</param> /// <param name="arg">The argument.</param> /// <returns>Processing result.</returns> - TR Process(IMutableCacheEntry<TK, TV> entry, TA arg); + TRes Process(IMutableCacheEntry<TK, TV> entry, TArg arg); } } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ignite/blob/81feb959/modules/platforms/dotnet/Apache.Ignite.Core/Compute/ComputeTaskAdapter.cs ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Compute/ComputeTaskAdapter.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Compute/ComputeTaskAdapter.cs index 67f7432..5965d2b 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Core/Compute/ComputeTaskAdapter.cs +++ b/modules/platforms/dotnet/Apache.Ignite.Core/Compute/ComputeTaskAdapter.cs @@ -23,9 +23,9 @@ namespace Apache.Ignite.Core.Compute using Apache.Ignite.Core.Common; /// <summary> - /// Convenience adapter for <see cref="IComputeTask{A,T,R}"/> interface + /// Convenience adapter for <see cref="IComputeTask{TArg,TJobRes,TTaskRes}"/> interface /// </summary> - public abstract class ComputeTaskAdapter<TA, T, TR> : IComputeTask<TA, T, TR> + public abstract class ComputeTaskAdapter<TArg, TJobRes, TTaskRes> : IComputeTask<TArg, TJobRes, TTaskRes> { /// <summary> /// Default implementation which will wait for all jobs to complete before @@ -42,7 +42,8 @@ namespace Apache.Ignite.Core.Compute /// <param name="res">Received remote Ignite executable result.</param> /// <param name="rcvd">All previously received results.</param> /// <returns>Result policy that dictates how to process further upcoming job results.</returns> - public virtual ComputeJobResultPolicy Result(IComputeJobResult<T> res, IList<IComputeJobResult<T>> rcvd) + public virtual ComputeJobResultPolicy Result(IComputeJobResult<TJobRes> res, + IList<IComputeJobResult<TJobRes>> rcvd) { Exception err = res.Exception(); @@ -52,8 +53,9 @@ namespace Apache.Ignite.Core.Compute err is ComputeJobFailoverException) return ComputeJobResultPolicy.Failover; - throw new IgniteException("Remote job threw user exception (override or implement IComputeTask.result(..) " + - "method if you would like to have automatic failover for this exception).", err); + throw new IgniteException("Remote job threw user exception (override or implement " + + "IComputeTask.result(..) method if you would like to have automatic failover for this exception).", + err); } return ComputeJobResultPolicy.Wait; @@ -73,7 +75,7 @@ namespace Apache.Ignite.Core.Compute /// Map of Ignite jobs assigned to subgrid node. If <c>null</c> or empty map is returned, /// exception will be thrown. /// </returns> - public abstract IDictionary<IComputeJob<T>, IClusterNode> Map(IList<IClusterNode> subgrid, TA arg); + public abstract IDictionary<IComputeJob<TJobRes>, IClusterNode> Map(IList<IClusterNode> subgrid, TArg arg); /// <summary> /// Reduces (or aggregates) results received so far into one compound result to be returned to @@ -88,6 +90,6 @@ namespace Apache.Ignite.Core.Compute /// <returns> /// Task result constructed from results of remote executions. /// </returns> - public abstract TR Reduce(IList<IComputeJobResult<T>> results); + public abstract TTaskRes Reduce(IList<IComputeJobResult<TJobRes>> results); } } http://git-wip-us.apache.org/repos/asf/ignite/blob/81feb959/modules/platforms/dotnet/Apache.Ignite.Core/Compute/ComputeTaskSplitAdapter.cs ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Compute/ComputeTaskSplitAdapter.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Compute/ComputeTaskSplitAdapter.cs index bf4685a..14651b1 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Core/Compute/ComputeTaskSplitAdapter.cs +++ b/modules/platforms/dotnet/Apache.Ignite.Core/Compute/ComputeTaskSplitAdapter.cs @@ -30,7 +30,7 @@ namespace Apache.Ignite.Core.Compute /// in most homogeneous environments where all nodes are equally suitable for executing grid /// job, see <see cref="Split"/> method for more details. /// </summary> - public abstract class ComputeTaskSplitAdapter<TA, T, TR> : ComputeTaskAdapter<TA, T, TR> + public abstract class ComputeTaskSplitAdapter<TArg, TJobRes, TTaskRes> : ComputeTaskAdapter<TArg, TJobRes, TTaskRes> { /** Random generator */ [ThreadStatic] @@ -49,7 +49,7 @@ namespace Apache.Ignite.Core.Compute /// <param name="gridSize">Number of available Ignite nodes. Note that returned number of jobs can be less, /// equal or greater than this grid size.</param> /// <param name="arg">Task execution argument. Can be <c>null</c>.</param> - protected abstract ICollection<IComputeJob<T>> Split(int gridSize, TA arg); + protected abstract ICollection<IComputeJob<TJobRes>> Split(int gridSize, TArg arg); /// <summary> /// This method is called to map or split Ignite task into multiple Ignite jobs. This is the @@ -66,7 +66,7 @@ namespace Apache.Ignite.Core.Compute /// exception will be thrown. /// </returns> /// <exception cref="IgniteException">Split returned no jobs.</exception> - override public IDictionary<IComputeJob<T>, IClusterNode> Map(IList<IClusterNode> subgrid, TA arg) + override public IDictionary<IComputeJob<TJobRes>, IClusterNode> Map(IList<IClusterNode> subgrid, TArg arg) { Debug.Assert(subgrid != null && subgrid.Count > 0); @@ -75,7 +75,7 @@ namespace Apache.Ignite.Core.Compute if (jobs == null || jobs.Count == 0) throw new IgniteException("Split returned no jobs."); - var map = new Dictionary<IComputeJob<T>, IClusterNode>(jobs.Count); + var map = new Dictionary<IComputeJob<TJobRes>, IClusterNode>(jobs.Count); if (_rnd == null) _rnd = new Random(); http://git-wip-us.apache.org/repos/asf/ignite/blob/81feb959/modules/platforms/dotnet/Apache.Ignite.Core/Compute/ICompute.cs ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Compute/ICompute.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Compute/ICompute.cs index c124f84..28471aa 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Core/Compute/ICompute.cs +++ b/modules/platforms/dotnet/Apache.Ignite.Core/Compute/ICompute.cs @@ -84,8 +84,8 @@ namespace Apache.Ignite.Core.Compute /// <param name="taskName">Java task name</param> /// <param name="taskArg">Optional argument of task execution, can be null.</param> /// <returns>Task result.</returns> - /// <typeparam name="T">Type of task result.</typeparam> - T ExecuteJavaTask<T>(string taskName, object taskArg); + /// <typeparam name="TRes">Type of task result.</typeparam> + TRes ExecuteJavaTask<TRes>(string taskName, object taskArg); /// <summary> /// Executes given task on the grid projection. For step-by-step explanation of task execution process @@ -94,11 +94,11 @@ namespace Apache.Ignite.Core.Compute /// <param name="task">Task to execute.</param> /// <param name="taskArg">Optional task argument.</param> /// <returns>Task result.</returns> - /// <typeparam name="TA">Argument type.</typeparam> - /// <typeparam name="T">Type of job result.</typeparam> - /// <typeparam name="TR">Type of reduce result.</typeparam> + /// <typeparam name="TArg">Argument type.</typeparam> + /// <typeparam name="TJobRes">Type of job result.</typeparam> + /// <typeparam name="TRes">Type of final task result.</typeparam> [AsyncSupported] - TR Execute<TA, T, TR>(IComputeTask<TA, T, TR> task, TA taskArg); + TRes Execute<TArg, TJobRes, TRes>(IComputeTask<TArg, TJobRes, TRes> task, TArg taskArg); /// <summary> /// Executes given task on the grid projection. For step-by-step explanation of task execution process @@ -106,10 +106,10 @@ namespace Apache.Ignite.Core.Compute /// </summary> /// <param name="task">Task to execute.</param> /// <returns>Task result.</returns> - /// <typeparam name="T">Type of job result.</typeparam> - /// <typeparam name="TR">Type of reduce result.</typeparam> + /// <typeparam name="TJobRes">Type of job result.</typeparam> + /// <typeparam name="TRes">Type of reduce result.</typeparam> [AsyncSupported] - TR Execute<T, TR>(IComputeTask<T, TR> task); + TRes Execute<TJobRes, TRes>(IComputeTask<TJobRes, TRes> task); /// <summary> /// Executes given task on the grid projection. For step-by-step explanation of task execution process @@ -118,11 +118,11 @@ namespace Apache.Ignite.Core.Compute /// <param name="taskType">Task type.</param> /// <param name="taskArg">Optional task argument.</param> /// <returns>Task result.</returns> - /// <typeparam name="TA">Argument type.</typeparam> - /// <typeparam name="T">Type of job result.</typeparam> - /// <typeparam name="TR">Type of reduce result.</typeparam> + /// <typeparam name="TArg">Argument type.</typeparam> + /// <typeparam name="TJobRes">Type of job result.</typeparam> + /// <typeparam name="TRes">Type of reduce result.</typeparam> [AsyncSupported] - TR Execute<TA, T, TR>(Type taskType, TA taskArg); + TRes Execute<TArg, TJobRes, TRes>(Type taskType, TArg taskArg); /// <summary> /// Executes given task on the grid projection. For step-by-step explanation of task execution process @@ -130,10 +130,10 @@ namespace Apache.Ignite.Core.Compute /// </summary> /// <param name="taskType">Task type.</param> /// <returns>Task result.</returns> - /// <typeparam name="T">Type of job result.</typeparam> - /// <typeparam name="TR">Type of reduce result.</typeparam> + /// <typeparam name="TJobRes">Type of job result.</typeparam> + /// <typeparam name="TRes">Type of reduce result.</typeparam> [AsyncSupported] - TR Execute<T, TR>(Type taskType); + TRes Execute<TJobRes, TRes>(Type taskType); /// <summary> /// Executes provided job on a node in this grid projection. The result of the @@ -141,9 +141,9 @@ namespace Apache.Ignite.Core.Compute /// </summary> /// <param name="clo">Job to execute.</param> /// <returns>Job result for this execution.</returns> - /// <typeparam name="TR">Type of job result.</typeparam> + /// <typeparam name="TRes">Type of job result.</typeparam> [AsyncSupported] - TR Call<TR>(IComputeFunc<TR> clo); + TRes Call<TRes>(IComputeFunc<TRes> clo); /// <summary> /// Executes given job on the node where data for provided affinity key is located @@ -153,29 +153,30 @@ namespace Apache.Ignite.Core.Compute /// <param name="affinityKey">Affinity key.</param> /// <param name="clo">Job to execute.</param> /// <returns>Job result for this execution.</returns> - /// <typeparam name="TR">Type of job result.</typeparam> + /// <typeparam name="TRes">Type of job result.</typeparam> [AsyncSupported] - TR AffinityCall<TR>(string cacheName, object affinityKey, IComputeFunc<TR> clo); + TRes AffinityCall<TRes>(string cacheName, object affinityKey, IComputeFunc<TRes> clo); /// <summary> /// Executes collection of jobs on nodes within this grid projection. /// </summary> /// <param name="clos">Collection of jobs to execute.</param> - /// <param name="rdc">Reducer to reduce all job results into one individual return value.</param> + /// <param name="reducer">Reducer to reduce all job results into one individual return value.</param> /// <returns>Reduced job result for this execution.</returns> - /// <typeparam name="TR1">Type of job result.</typeparam> - /// <typeparam name="TR2">Type of reduced result.</typeparam> + /// <typeparam name="TFuncRes">Type of function result.</typeparam> + /// <typeparam name="TRes">Type of result after reduce.</typeparam> [AsyncSupported] - TR2 Call<TR1, TR2>(IEnumerable<IComputeFunc<TR1>> clos, IComputeReducer<TR1, TR2> rdc); + TRes Call<TFuncRes, TRes>(IEnumerable<IComputeFunc<TFuncRes>> clos, + IComputeReducer<TFuncRes, TRes> reducer); /// <summary> /// Executes collection of jobs on nodes within this grid projection. /// </summary> /// <param name="clos">Collection of jobs to execute.</param> /// <returns>Collection of job results for this execution.</returns> - /// <typeparam name="TR">Type of job result.</typeparam> + /// <typeparam name="TRes">Type of job result.</typeparam> [AsyncSupported] - ICollection<TR> Call<TR>(IEnumerable<IComputeFunc<TR>> clos); + ICollection<TRes> Call<TRes>(IEnumerable<IComputeFunc<TRes>> clos); /// <summary> /// Broadcasts given job to all nodes in grid projection. Every participating node will return a job result. @@ -183,7 +184,7 @@ namespace Apache.Ignite.Core.Compute /// <param name="clo">Job to broadcast to all projection nodes.</param> /// <returns>Collection of results for this execution.</returns> [AsyncSupported] - ICollection<TR> Broadcast<TR>(IComputeFunc<TR> clo); + ICollection<TRes> Broadcast<TRes>(IComputeFunc<TRes> clo); /// <summary> /// Broadcasts given closure job with passed in argument to all nodes in grid projection. @@ -192,10 +193,10 @@ namespace Apache.Ignite.Core.Compute /// <param name="clo">Job to broadcast to all projection nodes.</param> /// <param name="arg">Job closure argument.</param> /// <returns>Collection of results for this execution.</returns> - /// <typeparam name="T">Type of argument.</typeparam> - /// <typeparam name="TR">Type of job result.</typeparam> + /// <typeparam name="TArg">Type of argument.</typeparam> + /// <typeparam name="TRes">Type of job result.</typeparam> [AsyncSupported] - ICollection<TR> Broadcast<T, TR>(IComputeFunc<T, TR> clo, T arg); + ICollection<TRes> Broadcast<TArg, TRes>(IComputeFunc<TArg, TRes> clo, TArg arg); /// <summary> /// Broadcasts given job to all nodes in grid projection. @@ -234,10 +235,10 @@ namespace Apache.Ignite.Core.Compute /// <param name="clo">Job to run.</param> /// <param name="arg">Job argument.</param> /// <returns>Job result for this execution.</returns> - /// <typeparam name="T">Type of argument.</typeparam> - /// <typeparam name="TR">Type of job result.</typeparam> + /// <typeparam name="TArg">Type of argument.</typeparam> + /// <typeparam name="TRes">Type of job result.</typeparam> [AsyncSupported] - TR Apply<T, TR>(IComputeFunc<T, TR> clo, T arg); + TRes Apply<TArg, TRes>(IComputeFunc<TArg, TRes> clo, TArg arg); /// <summary> /// Executes provided closure job on nodes within this grid projection. A new job is executed for @@ -247,10 +248,10 @@ namespace Apache.Ignite.Core.Compute /// <param name="clo">Job to run.</param> /// <param name="args">Job arguments.</param> /// <returns>Сollection of job results.</returns> - /// <typeparam name="T">Type of argument.</typeparam> - /// <typeparam name="TR">Type of job result.</typeparam> + /// <typeparam name="TArg">Type of argument.</typeparam> + /// <typeparam name="TRes">Type of job result.</typeparam> [AsyncSupported] - ICollection<TR> Apply<T, TR>(IComputeFunc<T, TR> clo, IEnumerable<T> args); + ICollection<TRes> Apply<TArg, TRes>(IComputeFunc<TArg, TRes> clo, IEnumerable<TArg> args); /// <summary> /// Executes provided closure job on nodes within this grid projection. A new job is executed for @@ -262,10 +263,11 @@ namespace Apache.Ignite.Core.Compute /// <param name="args">Job arguments.</param> /// <param name="rdc">Reducer to reduce all job results into one individual return value.</param> /// <returns>Reduced job result for this execution.</returns> - /// <typeparam name="T">Type of argument.</typeparam> - /// <typeparam name="TR1">Type of job result.</typeparam> - /// <typeparam name="TR2">Type of reduced result.</typeparam> + /// <typeparam name="TArg">Type of argument.</typeparam> + /// <typeparam name="TFuncRes">Type of function result.</typeparam> + /// <typeparam name="TRes">Type of result after reduce.</typeparam> [AsyncSupported] - TR2 Apply<T, TR1, TR2>(IComputeFunc<T, TR1> clo, IEnumerable<T> args, IComputeReducer<TR1, TR2> rdc); + TRes Apply<TArg, TFuncRes, TRes>(IComputeFunc<TArg, TFuncRes> clo, IEnumerable<TArg> args, + IComputeReducer<TFuncRes, TRes> rdc); } } http://git-wip-us.apache.org/repos/asf/ignite/blob/81feb959/modules/platforms/dotnet/Apache.Ignite.Core/Compute/IComputeFunc.cs ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Compute/IComputeFunc.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Compute/IComputeFunc.cs index 4a43f11..9c6cdf7 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Core/Compute/IComputeFunc.cs +++ b/modules/platforms/dotnet/Apache.Ignite.Core/Compute/IComputeFunc.cs @@ -20,26 +20,26 @@ namespace Apache.Ignite.Core.Compute /// <summary> /// Defines function having a single argument. /// </summary> - public interface IComputeFunc<in T, out TR> + public interface IComputeFunc<in TArg, out TRes> { /// <summary> /// Invoke function. /// </summary> /// <param name="arg">Argument.</param> /// <returns>Result.</returns> - TR Invoke(T arg); + TRes Invoke(TArg arg); } /// <summary> /// Defines function having no arguments. /// </summary> - public interface IComputeFunc<out T> + public interface IComputeFunc<out TRes> { /// <summary> /// Invoke function. /// </summary> /// <returns>Result.</returns> - T Invoke(); + TRes Invoke(); } /// <summary> http://git-wip-us.apache.org/repos/asf/ignite/blob/81feb959/modules/platforms/dotnet/Apache.Ignite.Core/Compute/IComputeJob.cs ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Compute/IComputeJob.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Compute/IComputeJob.cs index a755bac..684ff95 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Core/Compute/IComputeJob.cs +++ b/modules/platforms/dotnet/Apache.Ignite.Core/Compute/IComputeJob.cs @@ -35,7 +35,7 @@ namespace Apache.Ignite.Core.Compute /// Ignite job implementation can be injected with <see cref="IIgnite"/> using /// <see cref="InstanceResourceAttribute"/> attribute. /// </summary> - public interface IComputeJob<out T> + public interface IComputeJob<out TRes> { /// <summary> /// Executes this job. @@ -44,7 +44,7 @@ namespace Apache.Ignite.Core.Compute /// in <see cref="IComputeJobResult{T}"/> object passed into /// <see cref="IComputeTask{A,T,R}.Result(IComputeJobResult{T}, IList{IComputeJobResult{T}})"/> /// on caller node.</returns> - T Execute(); + TRes Execute(); /// <summary> /// This method is called when system detects that completion of this http://git-wip-us.apache.org/repos/asf/ignite/blob/81feb959/modules/platforms/dotnet/Apache.Ignite.Core/Compute/IComputeJobResult.cs ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Compute/IComputeJobResult.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Compute/IComputeJobResult.cs index 5891fd7..6369eb5 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Core/Compute/IComputeJobResult.cs +++ b/modules/platforms/dotnet/Apache.Ignite.Core/Compute/IComputeJobResult.cs @@ -25,7 +25,7 @@ namespace Apache.Ignite.Core.Compute /// <see cref="IComputeTask{A,T,R}.Result(IComputeJobResult{T}, IList{IComputeJobResult{T}})"/> /// method. /// </summary> - public interface IComputeJobResult<out T> + public interface IComputeJobResult<out TRes> { /// <summary> /// Gets data returned by remote job if it didn't fail. This data is the @@ -39,13 +39,13 @@ namespace Apache.Ignite.Core.Compute /// /// </summary> /// <returns>Data returned by job.</returns> - T Data(); + TRes Data(); /// <summary> /// Gets local instance of remote job produced this result. /// </summary> /// <returns></returns> - IComputeJob<T> Job(); + IComputeJob<TRes> Job(); /// <summary> /// Gets exception produced by execution of remote job, or <c>null</c> if no http://git-wip-us.apache.org/repos/asf/ignite/blob/81feb959/modules/platforms/dotnet/Apache.Ignite.Core/Compute/IComputeReducer.cs ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Compute/IComputeReducer.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Compute/IComputeReducer.cs index 46dcbd9..c2e6087 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Core/Compute/IComputeReducer.cs +++ b/modules/platforms/dotnet/Apache.Ignite.Core/Compute/IComputeReducer.cs @@ -20,7 +20,9 @@ namespace Apache.Ignite.Core.Compute /// <summary> /// Compute reducer which is capable of result collecting and reducing. /// </summary> - public interface IComputeReducer<in TR1, out TR2> + /// <typeparam name="TRes">Type of results passed for reducing.</typeparam> + /// <typeparam name="TReduceRes">Type of reduced result.</typeparam> + public interface IComputeReducer<in TRes, out TReduceRes> { /// <summary> /// Collect closure execution result. @@ -28,12 +30,12 @@ namespace Apache.Ignite.Core.Compute /// <param name="res">Result.</param> /// <returns><c>True</c> to continue collecting results until all closures are finished, /// <c>false</c> to start reducing.</returns> - bool Collect(TR1 res); + bool Collect(TRes res); /// <summary> /// Reduce closure execution results collected earlier. /// </summary> /// <returns>Reduce result.</returns> - TR2 Reduce(); + TReduceRes Reduce(); } } http://git-wip-us.apache.org/repos/asf/ignite/blob/81feb959/modules/platforms/dotnet/Apache.Ignite.Core/Compute/IComputeTask.cs ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Compute/IComputeTask.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Compute/IComputeTask.cs index 21b6c48..d3d7ccf 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Core/Compute/IComputeTask.cs +++ b/modules/platforms/dotnet/Apache.Ignite.Core/Compute/IComputeTask.cs @@ -33,7 +33,7 @@ namespace Apache.Ignite.Core.Compute /// <description>Inject annotated resources into task instance.</description> /// </item> /// <item> - /// <description>Apply <see cref="IComputeTask{A,T,R}.Map(IList{IClusterNode}, TA)"/>. + /// <description>Apply <see cref="IComputeTask{A,T,R}.Map(IList{IClusterNode}, TArg)"/>. /// This method is responsible for splitting business logic into multiple jobs /// (units of execution) and mapping them to Ignite nodes.</description> /// </item> @@ -42,7 +42,7 @@ namespace Apache.Ignite.Core.Compute /// </item> /// <item> /// <description>Once job execution results become available method - /// <see cref="IComputeTask{A,T,R}.Result(IComputeJobResult{T}, IList{IComputeJobResult{T}})"/> + /// <see cref="IComputeTask{A,T,R}.Result(IComputeJobResult{TJobRes}, IList{IComputeJobResult{TJobRes}})"/> /// will be called for ech received job result. The policy returned by this method will /// determine the way task reacts to every job result. /// <para /> @@ -66,19 +66,19 @@ namespace Apache.Ignite.Core.Compute /// </item> /// <item> /// <description>Once all results are received or - /// <see cref="IComputeTask{A,T,R}.Result(IComputeJobResult{T}, IList{IComputeJobResult{T}})"/> + /// <see cref="IComputeTask{A,T,R}.Result(IComputeJobResult{TJobRes}, IList{IComputeJobResult{TJobRes}})"/> /// method returned <see cref="ComputeJobResultPolicy.Reduce"/> policy, method - /// <see cref="IComputeTask{A,T,R}.Reduce(IList{IComputeJobResult{T}})"/> + /// <see cref="IComputeTask{A,T,R}.Reduce(IList{IComputeJobResult{TJobRes}})"/> /// is called to aggregate received results into one final result. Once this method is finished the /// execution of the Ignite task is complete. This result will be returned to the user through future. /// </description> /// </item> /// </list> /// </summary> - /// <typeparam name="TA">Argument type.</typeparam> - /// <typeparam name="T">Type of job result.</typeparam> - /// <typeparam name="TR">Type of reduce result.</typeparam> - public interface IComputeTask<in TA, T, out TR> + /// <typeparam name="TArg">Argument type.</typeparam> + /// <typeparam name="TJobRes">Type of job result.</typeparam> + /// <typeparam name="TRes">Type of final task result after reduce.</typeparam> + public interface IComputeTask<in TArg, TJobRes, out TRes> { /// <summary> /// This method is called to map or split Ignite task into multiple Ignite jobs. This is the @@ -92,7 +92,7 @@ namespace Apache.Ignite.Core.Compute /// as the one passed into <c>ICompute.Execute()</c> methods.</param> /// <returns>Map of Ignite jobs assigned to subgrid node. If <c>null</c> or empty map is returned, /// exception will be thrown.</returns> - IDictionary<IComputeJob<T>, IClusterNode> Map(IList<IClusterNode> subgrid, TA arg); + IDictionary<IComputeJob<TJobRes>, IClusterNode> Map(IList<IClusterNode> subgrid, TArg arg); /// <summary> /// Asynchronous callback invoked every time a result from remote execution is @@ -105,7 +105,7 @@ namespace Apache.Ignite.Core.Compute /// <param name="rcvd">All previously received results. Note that if task class has /// <see cref="ComputeTaskNoResultCacheAttribute"/> attribute, then this list will be empty.</param> /// <returns>Result policy that dictates how to process further upcoming job results.</returns> - ComputeJobResultPolicy Result(IComputeJobResult<T> res, IList<IComputeJobResult<T>> rcvd); + ComputeJobResultPolicy Result(IComputeJobResult<TJobRes> res, IList<IComputeJobResult<TJobRes>> rcvd); /// <summary> /// Reduces (or aggregates) results received so far into one compound result to be returned to @@ -118,14 +118,14 @@ namespace Apache.Ignite.Core.Compute /// <param name="results">Received job results. Note that if task class has /// <see cref="ComputeTaskNoResultCacheAttribute"/> attribute, then this list will be empty.</param> /// <returns>Task result constructed from results of remote executions.</returns> - TR Reduce(IList<IComputeJobResult<T>> results); + TRes Reduce(IList<IComputeJobResult<TJobRes>> results); } /// <summary> /// IComputeTask without an argument. /// </summary> [SuppressMessage("Microsoft.Design", "CA1040:AvoidEmptyInterfaces")] - public interface IComputeTask<T, out TR> : IComputeTask<object, T, TR> + public interface IComputeTask<TJobRes, out TReduceRes> : IComputeTask<object, TJobRes, TReduceRes> { // No-op. } http://git-wip-us.apache.org/repos/asf/ignite/blob/81feb959/modules/platforms/dotnet/Apache.Ignite.Core/Datastream/StreamTransformer.cs ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Datastream/StreamTransformer.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Datastream/StreamTransformer.cs index 0398342..d8b4620 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Core/Datastream/StreamTransformer.cs +++ b/modules/platforms/dotnet/Apache.Ignite.Core/Datastream/StreamTransformer.cs @@ -30,19 +30,19 @@ namespace Apache.Ignite.Core.Datastream /// </summary> /// <typeparam name="TK">Key type.</typeparam> /// <typeparam name="TV">Value type.</typeparam> - /// <typeparam name="TA">The type of the processor argument.</typeparam> - /// <typeparam name="TR">The type of the processor result.</typeparam> - public sealed class StreamTransformer<TK, TV, TA, TR> : IStreamReceiver<TK, TV>, + /// <typeparam name="TArg">The type of the processor argument.</typeparam> + /// <typeparam name="TRes">The type of the processor result.</typeparam> + public sealed class StreamTransformer<TK, TV, TArg, TRes> : IStreamReceiver<TK, TV>, IPortableWriteAware { /** Entry processor. */ - private readonly ICacheEntryProcessor<TK, TV, TA, TR> _proc; + private readonly ICacheEntryProcessor<TK, TV, TArg, TRes> _proc; /// <summary> /// Initializes a new instance of the <see cref="StreamTransformer{K, V, A, R}"/> class. /// </summary> /// <param name="proc">Entry processor.</param> - public StreamTransformer(ICacheEntryProcessor<TK, TV, TA, TR> proc) + public StreamTransformer(ICacheEntryProcessor<TK, TV, TArg, TRes> proc) { IgniteArgumentCheck.NotNull(proc, "proc"); @@ -57,7 +57,7 @@ namespace Apache.Ignite.Core.Datastream foreach (var entry in entries) keys.Add(entry.Key); - cache.InvokeAll(keys, _proc, default(TA)); + cache.InvokeAll(keys, _proc, default(TArg)); } /** <inheritdoc /> */ http://git-wip-us.apache.org/repos/asf/ignite/blob/81feb959/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheImpl.cs ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheImpl.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheImpl.cs index 27c53ad..dcecc52 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheImpl.cs +++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheImpl.cs @@ -520,33 +520,33 @@ namespace Apache.Ignite.Core.Impl.Cache } /** <inheritdoc /> */ - public TR Invoke<TR, TA>(TK key, ICacheEntryProcessor<TK, TV, TA, TR> processor, TA arg) + public TRes Invoke<TArg, TRes>(TK key, ICacheEntryProcessor<TK, TV, TArg, TRes> processor, TArg arg) { IgniteArgumentCheck.NotNull(key, "key"); IgniteArgumentCheck.NotNull(processor, "processor"); var holder = new CacheEntryProcessorHolder(processor, arg, - (e, a) => processor.Process((IMutableCacheEntry<TK, TV>)e, (TA)a), typeof(TK), typeof(TV)); + (e, a) => processor.Process((IMutableCacheEntry<TK, TV>)e, (TArg)a), typeof(TK), typeof(TV)); return DoOutInOp((int)CacheOp.Invoke, writer => { writer.Write(key); writer.Write(holder); }, - input => GetResultOrThrow<TR>(Unmarshal<object>(input))); + input => GetResultOrThrow<TRes>(Unmarshal<object>(input))); } /** <inheritdoc /> */ - public IDictionary<TK, ICacheEntryProcessorResult<TR>> InvokeAll<TR, TA>(IEnumerable<TK> keys, - ICacheEntryProcessor<TK, TV, TA, TR> processor, TA arg) + public IDictionary<TK, ICacheEntryProcessorResult<TRes>> InvokeAll<TArg, TRes>(IEnumerable<TK> keys, + ICacheEntryProcessor<TK, TV, TArg, TRes> processor, TArg arg) { IgniteArgumentCheck.NotNull(keys, "keys"); IgniteArgumentCheck.NotNull(processor, "processor"); var holder = new CacheEntryProcessorHolder(processor, arg, - (e, a) => processor.Process((IMutableCacheEntry<TK, TV>)e, (TA)a), typeof(TK), typeof(TV)); + (e, a) => processor.Process((IMutableCacheEntry<TK, TV>)e, (TArg)a), typeof(TK), typeof(TV)); return DoOutInOp((int)CacheOp.InvokeAll, writer => { @@ -556,10 +556,10 @@ namespace Apache.Ignite.Core.Impl.Cache input => { if (IsAsync) - _invokeAllConverter.Value = (Func<PortableReaderImpl, IDictionary<TK, ICacheEntryProcessorResult<TR>>>) - (reader => ReadInvokeAllResults<TR>(reader.Stream)); + _invokeAllConverter.Value = (Func<PortableReaderImpl, IDictionary<TK, ICacheEntryProcessorResult<TRes>>>) + (reader => ReadInvokeAllResults<TRes>(reader.Stream)); - return ReadInvokeAllResults<TR>(input); + return ReadInvokeAllResults<TRes>(input); }); } http://git-wip-us.apache.org/repos/asf/ignite/blob/81feb959/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheProxyImpl.cs ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheProxyImpl.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheProxyImpl.cs index bfd7866..0f868d8 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheProxyImpl.cs +++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheProxyImpl.cs @@ -421,7 +421,7 @@ namespace Apache.Ignite.Core.Impl.Cache } /** <inheritDoc /> */ - public TR Invoke<TR, TA>(TK key, ICacheEntryProcessor<TK, TV, TA, TR> processor, TA arg) + public TRes Invoke<TArg, TRes>(TK key, ICacheEntryProcessor<TK, TV, TArg, TRes> processor, TArg arg) { var result = _cache.Invoke(key, processor, arg); @@ -431,8 +431,8 @@ namespace Apache.Ignite.Core.Impl.Cache } /** <inheritDoc /> */ - public IDictionary<TK, ICacheEntryProcessorResult<TR>> InvokeAll<TR, TA>(IEnumerable<TK> keys, - ICacheEntryProcessor<TK, TV, TA, TR> processor, TA arg) + public IDictionary<TK, ICacheEntryProcessorResult<TRes>> InvokeAll<TArg, TRes>(IEnumerable<TK> keys, + ICacheEntryProcessor<TK, TV, TArg, TRes> processor, TArg arg) { var result = _cache.InvokeAll(keys, processor, arg); http://git-wip-us.apache.org/repos/asf/ignite/blob/81feb959/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/Compute.cs ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/Compute.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/Compute.cs index 7efabd1..d7fc59f 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/Compute.cs +++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/Compute.cs @@ -98,72 +98,73 @@ namespace Apache.Ignite.Core.Impl.Compute } /** <inheritDoc /> */ - public T ExecuteJavaTask<T>(string taskName, object taskArg) + public TReduceRes ExecuteJavaTask<TReduceRes>(string taskName, object taskArg) { - return _compute.ExecuteJavaTask<T>(taskName, taskArg); + return _compute.ExecuteJavaTask<TReduceRes>(taskName, taskArg); } /** <inheritDoc /> */ - public TR Execute<TA, T, TR>(IComputeTask<TA, T, TR> task, TA taskArg) + public TReduceRes Execute<TArg, TJobRes, TReduceRes>(IComputeTask<TArg, TJobRes, TReduceRes> task, TArg taskArg) { return _compute.Execute(task, taskArg).Get(); } /** <inheritDoc /> */ - public TR Execute<T, TR>(IComputeTask<T, TR> task) + public TJobRes Execute<TArg, TJobRes>(IComputeTask<TArg, TJobRes> task) { return _compute.Execute(task, null).Get(); } /** <inheritDoc /> */ - public TR Execute<TA, T, TR>(Type taskType, TA taskArg) + public TReduceRes Execute<TArg, TJobRes, TReduceRes>(Type taskType, TArg taskArg) { - return _compute.Execute<TA, T, TR>(taskType, taskArg).Get(); + return _compute.Execute<TArg, TJobRes, TReduceRes>(taskType, taskArg).Get(); } - public TR Execute<T, TR>(Type taskType) + public TReduceRes Execute<TArg, TReduceRes>(Type taskType) { - return _compute.Execute<object, T, TR>(taskType, null).Get(); + return _compute.Execute<object, TArg, TReduceRes>(taskType, null).Get(); } /** <inheritDoc /> */ - public TR Call<TR>(IComputeFunc<TR> clo) + public TJobRes Call<TJobRes>(IComputeFunc<TJobRes> clo) { return _compute.Execute(clo).Get(); } /** <inheritDoc /> */ - public TR AffinityCall<TR>(string cacheName, object affinityKey, IComputeFunc<TR> clo) + public TJobRes AffinityCall<TJobRes>(string cacheName, object affinityKey, IComputeFunc<TJobRes> clo) { return _compute.AffinityCall(cacheName, affinityKey, clo).Get(); } /** <inheritDoc /> */ - public TR Call<TR>(Func<TR> func) + public TJobRes Call<TJobRes>(Func<TJobRes> func) { return _compute.Execute(func).Get(); } /** <inheritDoc /> */ - public ICollection<TR> Call<TR>(IEnumerable<IComputeFunc<TR>> clos) + public ICollection<TJobRes> Call<TJobRes>(IEnumerable<IComputeFunc<TJobRes>> clos) { return _compute.Execute(clos).Get(); } /** <inheritDoc /> */ - public TR2 Call<TR1, TR2>(IEnumerable<IComputeFunc<TR1>> clos, IComputeReducer<TR1, TR2> rdc) + public TReduceRes Call<TJobRes, TReduceRes>(IEnumerable<IComputeFunc<TJobRes>> clos, + IComputeReducer<TJobRes, TReduceRes> reducer) { - return _compute.Execute(clos, rdc).Get(); + return _compute.Execute(clos, reducer).Get(); } /** <inheritDoc /> */ - public ICollection<TR> Broadcast<TR>(IComputeFunc<TR> clo) + public ICollection<TJobRes> Broadcast<TJobRes>(IComputeFunc<TJobRes> clo) { return _compute.Broadcast(clo).Get(); } /** <inheritDoc /> */ - public ICollection<TR> Broadcast<T, TR>(IComputeFunc<T, TR> clo, T arg) + public ICollection<TJobRes> Broadcast<T, TJobRes>(IComputeFunc<T, TJobRes> clo, T arg) { return _compute.Broadcast(clo, arg).Get(); } @@ -193,19 +194,20 @@ namespace Apache.Ignite.Core.Impl.Compute } /** <inheritDoc /> */ - public TR Apply<T, TR>(IComputeFunc<T, TR> clo, T arg) + public TJobRes Apply<TArg, TJobRes>(IComputeFunc<TArg, TJobRes> clo, TArg arg) { return _compute.Apply(clo, arg).Get(); } /** <inheritDoc /> */ - public ICollection<TR> Apply<T, TR>(IComputeFunc<T, TR> clo, IEnumerable<T> args) + public ICollection<TJobRes> Apply<TArg, TJobRes>(IComputeFunc<TArg, TJobRes> clo, IEnumerable<TArg> args) { return _compute.Apply(clo, args).Get(); } /** <inheritDoc /> */ - public TR2 Apply<T, TR1, TR2>(IComputeFunc<T, TR1> clo, IEnumerable<T> args, IComputeReducer<TR1, TR2> rdc) + public TReduceRes Apply<TArg, TJobRes, TReduceRes>(IComputeFunc<TArg, TJobRes> clo, + IEnumerable<TArg> args, IComputeReducer<TJobRes, TReduceRes> rdc) { return _compute.Apply(clo, args, rdc).Get(); } http://git-wip-us.apache.org/repos/asf/ignite/blob/81feb959/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeAsync.cs ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeAsync.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeAsync.cs index 26c9bf4..89c5b83 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeAsync.cs +++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeAsync.cs @@ -117,71 +117,71 @@ namespace Apache.Ignite.Core.Impl.Compute } /** <inheritDoc /> */ - public T ExecuteJavaTask<T>(string taskName, object taskArg) + public TReduceRes ExecuteJavaTask<TReduceRes>(string taskName, object taskArg) { - _curFut.Value = Compute.ExecuteJavaTaskAsync<T>(taskName, taskArg); + _curFut.Value = Compute.ExecuteJavaTaskAsync<TReduceRes>(taskName, taskArg); - return default(T); + return default(TReduceRes); } /** <inheritDoc /> */ - public TR Execute<TA, T, TR>(IComputeTask<TA, T, TR> task, TA taskArg) + public TReduceRes Execute<TArg, TJobRes, TReduceRes>(IComputeTask<TArg, TJobRes, TReduceRes> task, TArg taskArg) { _curFut.Value = Compute.Execute(task, taskArg); - return default(TR); + return default(TReduceRes); } /** <inheritDoc /> */ - public TR Execute<T, TR>(IComputeTask<T, TR> task) + public TReduceRes Execute<TJobRes, TReduceRes>(IComputeTask<TJobRes, TReduceRes> task) { _curFut.Value = Compute.Execute(task, null); - return default(TR); + return default(TReduceRes); } /** <inheritDoc /> */ - public TR Execute<TA, T, TR>(Type taskType, TA taskArg) + public TReduceRes Execute<TArg, TJobRes, TReduceRes>(Type taskType, TArg taskArg) { - _curFut.Value = Compute.Execute<TA, T, TR>(taskType, taskArg); + _curFut.Value = Compute.Execute<TArg, TJobRes, TReduceRes>(taskType, taskArg); - return default(TR); + return default(TReduceRes); } /** <inheritDoc /> */ - public TR Execute<T, TR>(Type taskType) + public TReduceRes Execute<TJobRes, TReduceRes>(Type taskType) { - _curFut.Value = Compute.Execute<object, T, TR>(taskType, null); + _curFut.Value = Compute.Execute<object, TJobRes, TReduceRes>(taskType, null); - return default(TR); + return default(TReduceRes); } /** <inheritDoc /> */ - public TR Call<TR>(IComputeFunc<TR> clo) + public TJobRes Call<TJobRes>(IComputeFunc<TJobRes> clo) { _curFut.Value = Compute.Execute(clo); - return default(TR); + return default(TJobRes); } /** <inheritDoc /> */ - public TR AffinityCall<TR>(string cacheName, object affinityKey, IComputeFunc<TR> clo) + public TJobRes AffinityCall<TJobRes>(string cacheName, object affinityKey, IComputeFunc<TJobRes> clo) { Compute.AffinityCall(cacheName, affinityKey, clo); - return default(TR); + return default(TJobRes); } /** <inheritDoc /> */ - public TR Call<TR>(Func<TR> func) + public TJobRes Call<TJobRes>(Func<TJobRes> func) { _curFut.Value = Compute.Execute(func); - return default(TR); + return default(TJobRes); } /** <inheritDoc /> */ - public ICollection<TR> Call<TR>(IEnumerable<IComputeFunc<TR>> clos) + public ICollection<TJobRes> Call<TJobRes>(IEnumerable<IComputeFunc<TJobRes>> clos) { _curFut.Value = Compute.Execute(clos); @@ -189,15 +189,15 @@ namespace Apache.Ignite.Core.Impl.Compute } /** <inheritDoc /> */ - public TR2 Call<TR1, TR2>(IEnumerable<IComputeFunc<TR1>> clos, IComputeReducer<TR1, TR2> rdc) + public TReduceRes Call<TJobRes, TReduceRes>(IEnumerable<IComputeFunc<TJobRes>> clos, IComputeReducer<TJobRes, TReduceRes> reducer) { - _curFut.Value = Compute.Execute(clos, rdc); + _curFut.Value = Compute.Execute(clos, reducer); - return default(TR2); + return default(TReduceRes); } /** <inheritDoc /> */ - public ICollection<TR> Broadcast<TR>(IComputeFunc<TR> clo) + public ICollection<TJobRes> Broadcast<TJobRes>(IComputeFunc<TJobRes> clo) { _curFut.Value = Compute.Broadcast(clo); @@ -205,7 +205,7 @@ namespace Apache.Ignite.Core.Impl.Compute } /** <inheritDoc /> */ - public ICollection<TR> Broadcast<T, TR>(IComputeFunc<T, TR> clo, T arg) + public ICollection<TJobRes> Broadcast<TArg, TJobRes>(IComputeFunc<TArg, TJobRes> clo, TArg arg) { _curFut.Value = Compute.Broadcast(clo, arg); @@ -237,15 +237,15 @@ namespace Apache.Ignite.Core.Impl.Compute } /** <inheritDoc /> */ - public TR Apply<T, TR>(IComputeFunc<T, TR> clo, T arg) + public TJobRes Apply<TArg, TJobRes>(IComputeFunc<TArg, TJobRes> clo, TArg arg) { _curFut.Value = Compute.Apply(clo, arg); - return default(TR); + return default(TJobRes); } /** <inheritDoc /> */ - public ICollection<TR> Apply<T, TR>(IComputeFunc<T, TR> clo, IEnumerable<T> args) + public ICollection<TJobRes> Apply<TArg, TJobRes>(IComputeFunc<TArg, TJobRes> clo, IEnumerable<TArg> args) { _curFut.Value = Compute.Apply(clo, args); @@ -253,11 +253,12 @@ namespace Apache.Ignite.Core.Impl.Compute } /** <inheritDoc /> */ - public TR2 Apply<T, TR1, TR2>(IComputeFunc<T, TR1> clo, IEnumerable<T> args, IComputeReducer<TR1, TR2> rdc) + public TReduceRes Apply<TArg, TJobRes, TReduceRes>(IComputeFunc<TArg, TJobRes> clo, + IEnumerable<TArg> args, IComputeReducer<TJobRes, TReduceRes> rdc) { _curFut.Value = Compute.Apply(clo, args, rdc); - return default(TR2); + return default(TReduceRes); } } } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ignite/blob/81feb959/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeImpl.cs ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeImpl.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeImpl.cs index f0ff968..abd54da 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeImpl.cs +++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeImpl.cs @@ -124,7 +124,7 @@ namespace Apache.Ignite.Core.Impl.Compute /// Executes given Java task on the grid projection. If task for given name has not been deployed yet, /// then 'taskName' will be used as task class name to auto-deploy the task. /// </summary> - public T ExecuteJavaTask<T>(string taskName, object taskArg) + public TReduceRes ExecuteJavaTask<TReduceRes>(string taskName, object taskArg) { IgniteArgumentCheck.NotNullOrEmpty(taskName, "taskName"); @@ -132,7 +132,7 @@ namespace Apache.Ignite.Core.Impl.Compute try { - T res = DoOutInOp<T>(OpExec, writer => + TReduceRes res = DoOutInOp<TReduceRes>(OpExec, writer => { WriteTask(writer, taskName, taskArg, nodes); }); @@ -150,7 +150,7 @@ namespace Apache.Ignite.Core.Impl.Compute /// If task for given name has not been deployed yet, /// then 'taskName' will be used as task class name to auto-deploy the task. /// </summary> - public IFuture<T> ExecuteJavaTaskAsync<T>(string taskName, object taskArg) + public IFuture<TReduceRes> ExecuteJavaTaskAsync<TReduceRes>(string taskName, object taskArg) { IgniteArgumentCheck.NotNullOrEmpty(taskName, "taskName"); @@ -158,14 +158,14 @@ namespace Apache.Ignite.Core.Impl.Compute try { - IFuture<T> fut = null; + IFuture<TReduceRes> fut = null; DoOutInOp(OpExecAsync, writer => { WriteTask(writer, taskName, taskArg, nodes); }, input => { - fut = GetFuture<T>((futId, futTyp) => UU.TargetListenFuture(Target, futId, futTyp), _keepPortable.Value); + fut = GetFuture<TReduceRes>((futId, futTyp) => UU.TargetListenFuture(Target, futId, futTyp), _keepPortable.Value); }); return fut; @@ -183,11 +183,12 @@ namespace Apache.Ignite.Core.Impl.Compute /// <param name="task">Task to execute.</param> /// <param name="taskArg">Optional task argument.</param> /// <returns>Task result.</returns> - public IFuture<TR> Execute<TA, T, TR>(IComputeTask<TA, T, TR> task, TA taskArg) + public IFuture<TReduceRes> Execute<TArg, TJobRes, TReduceRes>(IComputeTask<TArg, TJobRes, TReduceRes> task, + TArg taskArg) { IgniteArgumentCheck.NotNull(task, "task"); - var holder = new ComputeTaskHolder<TA, T, TR>((Ignite) _prj.Ignite, this, task, taskArg); + var holder = new ComputeTaskHolder<TArg, TJobRes, TReduceRes>((Ignite) _prj.Ignite, this, task, taskArg); long ptr = Marshaller.Ignite.HandleRegistry.Allocate(holder); @@ -203,13 +204,13 @@ namespace Apache.Ignite.Core.Impl.Compute /// <param name="taskType">Task type.</param> /// <param name="taskArg">Optional task argument.</param> /// <returns>Task result.</returns> - public IFuture<TR> Execute<TA, T, TR>(Type taskType, TA taskArg) + public IFuture<TReduceRes> Execute<TArg, TJobRes, TReduceRes>(Type taskType, TArg taskArg) { IgniteArgumentCheck.NotNull(taskType, "taskType"); object task = FormatterServices.GetUninitializedObject(taskType); - var task0 = task as IComputeTask<TA, T, TR>; + var task0 = task as IComputeTask<TArg, TJobRes, TReduceRes>; if (task0 == null) throw new IgniteException("Task type doesn't implement IComputeTask: " + taskType.Name); @@ -223,11 +224,11 @@ namespace Apache.Ignite.Core.Impl.Compute /// </summary> /// <param name="clo">Job to execute.</param> /// <returns>Job result for this execution.</returns> - public IFuture<TR> Execute<TR>(IComputeFunc<TR> clo) + public IFuture<TJobRes> Execute<TJobRes>(IComputeFunc<TJobRes> clo) { IgniteArgumentCheck.NotNull(clo, "clo"); - return ExecuteClosures0(new ComputeSingleClosureTask<object, TR, TR>(), + return ExecuteClosures0(new ComputeSingleClosureTask<object, TJobRes, TJobRes>(), new ComputeOutFuncJob(clo.ToNonGeneric()), null, false); } @@ -237,13 +238,13 @@ namespace Apache.Ignite.Core.Impl.Compute /// </summary> /// <param name="func">Func to execute.</param> /// <returns>Job result for this execution.</returns> - public IFuture<TR> Execute<TR>(Func<TR> func) + public IFuture<TJobRes> Execute<TJobRes>(Func<TJobRes> func) { IgniteArgumentCheck.NotNull(func, "func"); var wrappedFunc = new ComputeOutFuncWrapper(func, () => func()); - return ExecuteClosures0(new ComputeSingleClosureTask<object, TR, TR>(), + return ExecuteClosures0(new ComputeSingleClosureTask<object, TJobRes, TJobRes>(), new ComputeOutFuncJob(wrappedFunc), null, false); } @@ -252,16 +253,16 @@ namespace Apache.Ignite.Core.Impl.Compute /// </summary> /// <param name="clos">Collection of jobs to execute.</param> /// <returns>Collection of job results for this execution.</returns> - public IFuture<ICollection<TR>> Execute<TR>(IEnumerable<IComputeFunc<TR>> clos) + public IFuture<ICollection<TJobRes>> Execute<TJobRes>(IEnumerable<IComputeFunc<TJobRes>> clos) { IgniteArgumentCheck.NotNull(clos, "clos"); ICollection<IComputeJob> jobs = new List<IComputeJob>(GetCountOrZero(clos)); - foreach (IComputeFunc<TR> clo in clos) + foreach (IComputeFunc<TJobRes> clo in clos) jobs.Add(new ComputeOutFuncJob(clo.ToNonGeneric())); - return ExecuteClosures0(new ComputeMultiClosureTask<object, TR, ICollection<TR>>(jobs.Count), + return ExecuteClosures0(new ComputeMultiClosureTask<object, TJobRes, ICollection<TJobRes>>(jobs.Count), null, jobs, false); } @@ -271,7 +272,8 @@ namespace Apache.Ignite.Core.Impl.Compute /// <param name="clos">Collection of jobs to execute.</param> /// <param name="rdc">Reducer to reduce all job results into one individual return value.</param> /// <returns>Collection of job results for this execution.</returns> - public IFuture<TR2> Execute<TR1, TR2>(IEnumerable<IComputeFunc<TR1>> clos, IComputeReducer<TR1, TR2> rdc) + public IFuture<TReduceRes> Execute<TJobRes, TReduceRes>(IEnumerable<IComputeFunc<TJobRes>> clos, + IComputeReducer<TJobRes, TReduceRes> rdc) { IgniteArgumentCheck.NotNull(clos, "clos"); @@ -280,7 +282,7 @@ namespace Apache.Ignite.Core.Impl.Compute foreach (var clo in clos) jobs.Add(new ComputeOutFuncJob(clo.ToNonGeneric())); - return ExecuteClosures0(new ComputeReducingClosureTask<object, TR1, TR2>(rdc), null, jobs, false); + return ExecuteClosures0(new ComputeReducingClosureTask<object, TJobRes, TReduceRes>(rdc), null, jobs, false); } /// <summary> @@ -288,11 +290,11 @@ namespace Apache.Ignite.Core.Impl.Compute /// </summary> /// <param name="clo">Job to broadcast to all projection nodes.</param> /// <returns>Collection of results for this execution.</returns> - public IFuture<ICollection<TR>> Broadcast<TR>(IComputeFunc<TR> clo) + public IFuture<ICollection<TJobRes>> Broadcast<TJobRes>(IComputeFunc<TJobRes> clo) { IgniteArgumentCheck.NotNull(clo, "clo"); - return ExecuteClosures0(new ComputeMultiClosureTask<object, TR, ICollection<TR>>(1), + return ExecuteClosures0(new ComputeMultiClosureTask<object, TJobRes, ICollection<TJobRes>>(1), new ComputeOutFuncJob(clo.ToNonGeneric()), null, true); } @@ -303,11 +305,11 @@ namespace Apache.Ignite.Core.Impl.Compute /// <param name="clo">Job to broadcast to all projection nodes.</param> /// <param name="arg">Job closure argument.</param> /// <returns>Collection of results for this execution.</returns> - public IFuture<ICollection<TR>> Broadcast<T, TR>(IComputeFunc<T, TR> clo, T arg) + public IFuture<ICollection<TJobRes>> Broadcast<TArg, TJobRes>(IComputeFunc<TArg, TJobRes> clo, TArg arg) { IgniteArgumentCheck.NotNull(clo, "clo"); - return ExecuteClosures0(new ComputeMultiClosureTask<object, TR, ICollection<TR>>(1), + return ExecuteClosures0(new ComputeMultiClosureTask<object, TJobRes, ICollection<TJobRes>>(1), new ComputeFuncJob(clo.ToNonGeneric(), arg), null, true); } @@ -367,11 +369,11 @@ namespace Apache.Ignite.Core.Impl.Compute /// <param name="clo">Job to run.</param> /// <param name="arg">Job argument.</param> /// <returns>Job result for this execution.</returns> - public IFuture<TR> Apply<T, TR>(IComputeFunc<T, TR> clo, T arg) + public IFuture<TJobRes> Apply<TArg, TJobRes>(IComputeFunc<TArg, TJobRes> clo, TArg arg) { IgniteArgumentCheck.NotNull(clo, "clo"); - return ExecuteClosures0(new ComputeSingleClosureTask<T, TR, TR>(), + return ExecuteClosures0(new ComputeSingleClosureTask<TArg, TJobRes, TJobRes>(), new ComputeFuncJob(clo.ToNonGeneric(), arg), null, false); } @@ -383,7 +385,8 @@ namespace Apache.Ignite.Core.Impl.Compute /// <param name="clo">Job to run.</param> /// <param name="args">Job arguments.</param> /// <returns>Collection of job results.</returns> - public IFuture<ICollection<TR>> Apply<T, TR>(IComputeFunc<T, TR> clo, IEnumerable<T> args) + public IFuture<ICollection<TJobRes>> Apply<TArg, TJobRes>(IComputeFunc<TArg, TJobRes> clo, + IEnumerable<TArg> args) { IgniteArgumentCheck.NotNull(clo, "clo"); @@ -393,10 +396,10 @@ namespace Apache.Ignite.Core.Impl.Compute var func = clo.ToNonGeneric(); - foreach (T arg in args) + foreach (TArg arg in args) jobs.Add(new ComputeFuncJob(func, arg)); - return ExecuteClosures0(new ComputeMultiClosureTask<T, TR, ICollection<TR>>(jobs.Count), + return ExecuteClosures0(new ComputeMultiClosureTask<TArg, TJobRes, ICollection<TJobRes>>(jobs.Count), null, jobs, false); } @@ -410,8 +413,8 @@ namespace Apache.Ignite.Core.Impl.Compute /// <param name="args">Job arguments.</param> /// <param name="rdc">Reducer to reduce all job results into one individual return value.</param> /// <returns>Reduced job result for this execution.</returns> - public IFuture<TR2> Apply<T, TR1, TR2>(IComputeFunc<T, TR1> clo, IEnumerable<T> args, - IComputeReducer<TR1, TR2> rdc) + public IFuture<TReduceRes> Apply<TArg, TJobRes, TReduceRes>(IComputeFunc<TArg, TJobRes> clo, + IEnumerable<TArg> args, IComputeReducer<TJobRes, TReduceRes> rdc) { IgniteArgumentCheck.NotNull(clo, "clo"); @@ -423,10 +426,10 @@ namespace Apache.Ignite.Core.Impl.Compute var func = clo.ToNonGeneric(); - foreach (T arg in args) + foreach (TArg arg in args) jobs.Add(new ComputeFuncJob(func, arg)); - return ExecuteClosures0(new ComputeReducingClosureTask<T, TR1, TR2>(rdc), + return ExecuteClosures0(new ComputeReducingClosureTask<TArg, TJobRes, TReduceRes>(rdc), null, jobs, false); } @@ -454,12 +457,12 @@ namespace Apache.Ignite.Core.Impl.Compute /// <param name="affinityKey">Affinity key.</param> /// <param name="clo">Job to execute.</param> /// <returns>Job result for this execution.</returns> - /// <typeparam name="TR">Type of job result.</typeparam> - public IFuture<TR> AffinityCall<TR>(string cacheName, object affinityKey, IComputeFunc<TR> clo) + /// <typeparam name="TJobRes">Type of job result.</typeparam> + public IFuture<TJobRes> AffinityCall<TJobRes>(string cacheName, object affinityKey, IComputeFunc<TJobRes> clo) { IgniteArgumentCheck.NotNull(clo, "clo"); - return ExecuteClosures0(new ComputeSingleClosureTask<object, TR, TR>(), + return ExecuteClosures0(new ComputeSingleClosureTask<object, TJobRes, TJobRes>(), new ComputeOutFuncJob(clo.ToNonGeneric()), opId: OpAffinity, writeAction: w => WriteAffinity(w, cacheName, affinityKey)); } @@ -480,7 +483,8 @@ namespace Apache.Ignite.Core.Impl.Compute /// <param name="jobs">Jobs.</param> /// <param name="broadcast">Broadcast flag.</param> /// <returns>Future.</returns> - private IFuture<TR> ExecuteClosures0<TA, T, TR>(IComputeTask<TA, T, TR> task, IComputeJob job, + private IFuture<TReduceRes> ExecuteClosures0<TArg, TJobRes, TReduceRes>( + IComputeTask<TArg, TJobRes, TReduceRes> task, IComputeJob job, ICollection<IComputeJob> jobs, bool broadcast) { return ExecuteClosures0(task, job, jobs, broadcast ? OpBroadcast : OpUnicast, @@ -499,13 +503,14 @@ namespace Apache.Ignite.Core.Impl.Compute /// <returns>Future.</returns> [SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes", Justification = "User code can throw any exception")] - private IFuture<TR> ExecuteClosures0<TA, T, TR>(IComputeTask<TA, T, TR> task, IComputeJob job = null, + private IFuture<TReduceRes> ExecuteClosures0<TArg, TJobRes, TReduceRes>( + IComputeTask<TArg, TJobRes, TReduceRes> task, IComputeJob job = null, IEnumerable<IComputeJob> jobs = null, int opId = OpUnicast, int jobsCount = 0, Action<PortableWriterImpl> writeAction = null) { Debug.Assert(job != null || jobs != null); - var holder = new ComputeTaskHolder<TA, T, TR>((Ignite) _prj.Ignite, this, task, default(TA)); + var holder = new ComputeTaskHolder<TArg, TJobRes, TReduceRes>((Ignite) _prj.Ignite, this, task, default(TArg)); var taskHandle = Marshaller.Ignite.HandleRegistry.Allocate(holder);
