Reduce() публичный Метод

public Reduce ( Channel q, object reduce_arg, object current_result, RpcResult child_rpc ) : void
q Brunet.Concurrent.Channel
reduce_arg object
current_result object
child_rpc Brunet.Messaging.RpcResult
Результат void
Пример #1
0
        /**
         * @return true if we successfully started the next reduce
         */
        protected bool TryNextReduce(State new_s, State old_s, RpcResult v, bool cont)
        {
            if (new_s.Done)
            {
                SendResult(new_s.ReduceResult);
                return(false);
            }
            bool start_red = new_s.Reducing && (cont || (false == old_s.Reducing));

            if (LogEnabled)
            {
                ProtocolLog.Write(ProtocolLog.MapReduce,
                                  String.Format("MapReduce: {0}, TryNextReduce: {1}.",
                                                _node.Address, start_red));
            }
            if (start_red)
            {
                Channel r_chan = new Channel(1, v);
                r_chan.CloseEvent += this.ReduceHandler;
                object startval = new_s.ReduceResult == State.DEFAULT_OBJ ? null : new_s.ReduceResult;
                if (LogEnabled)
                {
                    ProtocolLog.Write(ProtocolLog.MapReduce,
                                      String.Format("MapReduce: {0} abt to Reduce({1},{2},{3})",
                                                    _node.Address, _mr_args.ReduceArg, startval, v));
                }
                try {
                    _mr_task.Reduce(r_chan, _mr_args.ReduceArg, startval, v);
                }
                catch (Exception x) {
                    //Reduce is where we do error handling, if that doesn't work, oh well:
                    if (LogEnabled)
                    {
                        ProtocolLog.Write(ProtocolLog.MapReduce,
                                          String.Format("MapReduce: {0}, reduce threw: {1}.", _node.Address, x));
                    }
                    SendResult(x);
                    return(false);
                }
            }
            return(start_red);
        }