Exemple #1
0
        /// <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>
        /// <returns>Collection of job results for this execution.</returns>
        public Future <TReduceRes> Execute <TJobRes, TReduceRes>(IEnumerable <IComputeFunc <TJobRes> > clos,
                                                                 IComputeReducer <TJobRes, TReduceRes> rdc)
        {
            IgniteArgumentCheck.NotNull(clos, "clos");

            ICollection <IComputeJob> jobs = new List <IComputeJob>(GetCountOrZero(clos));

            foreach (var clo in clos)
            {
                jobs.Add(new ComputeOutFuncJob(clo.ToNonGeneric()));
            }

            return(ExecuteClosures0(new ComputeReducingClosureTask <object, TJobRes, TReduceRes>(rdc), null, jobs, false));
        }
Exemple #2
0
        /// <summary>
        /// Executes provided closure job on nodes within this grid projection. A new job is executed for
        /// every argument in the passed in collection. The number of actual job executions will be
        /// equal to size of the job arguments collection. The returned job results will be reduced
        /// into an individual result by provided reducer.
        /// </summary>
        /// <param name="clo">Job to run.</param>
        /// <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)
        {
            IgniteArgumentCheck.NotNull(clo, "clo");

            IgniteArgumentCheck.NotNull(clo, "clo");

            IgniteArgumentCheck.NotNull(clo, "clo");

            ICollection <IComputeJob> jobs = new List <IComputeJob>(GetCountOrZero(args));

            var func = clo.ToNonGeneric();

            foreach (T arg in args)
            {
                jobs.Add(new ComputeFuncJob(func, arg));
            }

            return(ExecuteClosures0(new ComputeReducingClosureTask <T, TR1, TR2>(rdc),
                                    null, jobs, false));
        }
Exemple #3
0
 /** <inheritDoc /> */
 public Task <TRes> ApplyAsync <TArg, TFuncRes, TRes>(IComputeFunc <TArg, TFuncRes> clo, IEnumerable <TArg> args,
                                                      IComputeReducer <TFuncRes, TRes> rdc, CancellationToken cancellationToken)
 {
     return(GetTaskIfAlreadyCancelled <TRes>(cancellationToken) ??
            _compute.Apply(clo, args, rdc).GetTask(cancellationToken));
 }
Exemple #4
0
 /** <inheritDoc /> */
 public Task <TRes> ApplyAsync <TArg, TFuncRes, TRes>(IComputeFunc <TArg, TFuncRes> clo, IEnumerable <TArg> args,
                                                      IComputeReducer <TFuncRes, TRes> rdc)
 {
     return(_compute.Apply(clo, args, rdc).Task);
 }
Exemple #5
0
 /** <inheritDoc /> */
 public TReduceRes Apply <TArg, TJobRes, TReduceRes>(IComputeFunc <TArg, TJobRes> clo,
                                                     IEnumerable <TArg> args, IComputeReducer <TJobRes, TReduceRes> rdc)
 {
     return(_compute.Apply(clo, args, rdc).Get());
 }
Exemple #6
0
 /** <inheritDoc /> */
 public TReduceRes Call <TJobRes, TReduceRes>(IEnumerable <IComputeFunc <TJobRes> > clos,
                                              IComputeReducer <TJobRes, TReduceRes> reducer)
 {
     return(_compute.Execute(clos, reducer).Get());
 }
Exemple #7
0
 /** <inheritDoc /> */
 public Task <TRes> CallAsync <TFuncRes, TRes>(IEnumerable <IComputeFunc <TFuncRes> > clos,
                                               IComputeReducer <TFuncRes, TRes> reducer, CancellationToken cancellationToken)
 {
     return(GetTaskIfAlreadyCancelled <TRes>(cancellationToken) ??
            _compute.Execute(clos, reducer).GetTask(cancellationToken));
 }
Exemple #8
0
 /** <inheritDoc /> */
 public Task <TRes> CallAsync <TFuncRes, TRes>(IEnumerable <IComputeFunc <TFuncRes> > clos,
                                               IComputeReducer <TFuncRes, TRes> reducer)
 {
     return(_compute.Execute(clos, reducer).Task);
 }
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="rdc">Reducer.</param>
 public ComputeReducingClosureTask(IComputeReducer <T, TR> rdc)
 {
     _rdc = rdc;
 }
Exemple #10
0
 /** <inheritDoc /> */
 public TR2 Apply <T, TR1, TR2>(IComputeFunc <T, TR1> clo, IEnumerable <T> args, IComputeReducer <TR1, TR2> rdc)
 {
     return(_compute.Apply(clo, args, rdc).Get());
 }
Exemple #11
0
 /** <inheritDoc /> */
 public TR2 Call <TR1, TR2>(IEnumerable <IComputeFunc <TR1> > clos, IComputeReducer <TR1, TR2> rdc)
 {
     return(_compute.Execute(clos, rdc).Get());
 }
Exemple #12
0
        /** <inheritDoc /> */
        public TR2 Apply <T, TR1, TR2>(IComputeFunc <T, TR1> clo, IEnumerable <T> args, IComputeReducer <TR1, TR2> rdc)
        {
            _curFut.Value = Compute.Apply(clo, args, rdc);

            return(default(TR2));
        }
Exemple #13
0
        /** <inheritDoc /> */
        public TR2 Call <TR1, TR2>(IEnumerable <IComputeFunc <TR1> > clos, IComputeReducer <TR1, TR2> rdc)
        {
            _curFut.Value = Compute.Execute(clos, rdc);

            return(default(TR2));
        }