Ejemplo n.º 1
0
        /// <summary>Configures all the chain elements for the task.</summary>
        /// <param name="jobConf">chain job's JobConf.</param>
        public virtual void Configure(JobConf jobConf)
        {
            string prefix = GetPrefix(isMap);

            chainJobConf = jobConf;
            SerializationFactory serializationFactory = new SerializationFactory(chainJobConf
                                                                                 );
            int index = jobConf.GetInt(prefix + ChainMapperSize, 0);

            for (int i = 0; i < index; i++)
            {
                Type    klass = jobConf.GetClass <Mapper>(prefix + ChainMapperClass + i, null);
                JobConf mConf = new JobConf(GetChainElementConf(jobConf, prefix + ChainMapperConfig
                                                                + i));
                Mapper mapper = ReflectionUtils.NewInstance(klass, mConf);
                mappers.AddItem(mapper);
                if (mConf.GetBoolean(MapperByValue, true))
                {
                    mappersKeySerialization.AddItem(serializationFactory.GetSerialization(mConf.GetClass
                                                                                              (MapperOutputKeyClass, null)));
                    mappersValueSerialization.AddItem(serializationFactory.GetSerialization(mConf.GetClass
                                                                                                (MapperOutputValueClass, null)));
                }
                else
                {
                    mappersKeySerialization.AddItem(null);
                    mappersValueSerialization.AddItem(null);
                }
            }
            Type klass_1 = jobConf.GetClass <Reducer>(prefix + ChainReducerClass, null);

            if (klass_1 != null)
            {
                JobConf rConf = new JobConf(GetChainElementConf(jobConf, prefix + ChainReducerConfig
                                                                ));
                reducer = ReflectionUtils.NewInstance(klass_1, rConf);
                if (rConf.GetBoolean(ReducerByValue, true))
                {
                    reducerKeySerialization = serializationFactory.GetSerialization(rConf.GetClass(ReducerOutputKeyClass
                                                                                                   , null));
                    reducerValueSerialization = serializationFactory.GetSerialization(rConf.GetClass(
                                                                                          ReducerOutputValueClass, null));
                }
                else
                {
                    reducerKeySerialization   = null;
                    reducerValueSerialization = null;
                }
            }
        }