Пример #1
0
        // Run the reducer directly.
        /// <exception cref="System.IO.IOException"/>
        /// <exception cref="System.Exception"/>
        internal virtual void RunReducer <Keyin, Valuein, Keyout, Valueout>(TaskInputOutputContext
                                                                            <KEYIN, VALUEIN, KEYOUT, VALUEOUT> context)
        {
            RecordWriter <KEYOUT, VALUEOUT> rw = new Chain.ChainRecordWriter <KEYOUT, VALUEOUT>
                                                     (context);

            Reducer.Context reducerContext = CreateReduceContext(rw, (ReduceContext)context,
                                                                 rConf);
            reducer.Run(reducerContext);
            rw.Close(context);
        }
Пример #2
0
        /// <exception cref="System.IO.IOException"/>
        /// <exception cref="System.Exception"/>
        internal virtual void RunMapper(TaskInputOutputContext context, int index)
        {
            Mapper       mapper = mappers[index];
            RecordReader rr     = new Chain.ChainRecordReader(context);
            RecordWriter rw     = new Chain.ChainRecordWriter(context);

            Mapper.Context mapperContext = CreateMapContext(rr, rw, context, GetConf(index));
            mapper.Run(mapperContext);
            rr.Close();
            rw.Close(context);
        }
Пример #3
0
        /// <summary>
        /// Add mapper(the last mapper) that reads input from
        /// queue and writes output to the output context
        /// </summary>
        /// <exception cref="System.IO.IOException"/>
        /// <exception cref="System.Exception"/>
        internal virtual void AddMapper(Chain.ChainBlockingQueue <Chain.KeyValuePair <object
                                                                                      , object> > input, TaskInputOutputContext outputContext, int index)
        {
            Configuration conf       = GetConf(index);
            Type          keyClass   = conf.GetClass(MapperInputKeyClass, typeof(object));
            Type          valueClass = conf.GetClass(MapperInputValueClass, typeof(object));
            RecordReader  rr         = new Chain.ChainRecordReader(keyClass, valueClass, input, conf);
            RecordWriter  rw         = new Chain.ChainRecordWriter(outputContext);

            Chain.MapRunner runner = new Chain.MapRunner(this, mappers[index], CreateMapContext
                                                             (rr, rw, outputContext, GetConf(index)), rr, rw);
            threads.AddItem(runner);
        }
Пример #4
0
        /// <summary>Add reducer that reads from context and writes to a queue</summary>
        /// <exception cref="System.IO.IOException"/>
        /// <exception cref="System.Exception"/>
        internal virtual void AddReducer(TaskInputOutputContext inputContext, Chain.ChainBlockingQueue
                                         <Chain.KeyValuePair <object, object> > outputQueue)
        {
            Type         keyOutClass   = rConf.GetClass(ReducerOutputKeyClass, typeof(object));
            Type         valueOutClass = rConf.GetClass(ReducerOutputValueClass, typeof(object));
            RecordWriter rw            = new Chain.ChainRecordWriter(keyOutClass, valueOutClass, outputQueue
                                                                     , rConf);

            Reducer.Context reducerContext = CreateReduceContext(rw, (ReduceContext)inputContext
                                                                 , rConf);
            Chain.ReduceRunner runner = new Chain.ReduceRunner(this, reducerContext, reducer,
                                                               rw);
            threads.AddItem(runner);
        }