0

嗨,我对这个 hadoop 非常陌生,我正在尝试执行一个简单的 mapreduce 作业链,但是在我的代码中,reducer 没有被执行。这是我写的简单代码

这是我的映射器代码

@Override
    public void map(LongWritable arg0, Text arg1,
            OutputCollector<Text, IntWritable> arg2, Reporter arg3)
            throws IOException {
        // TODO Auto-generated method stub
        System.out.println("in first mapper");

    }

这是我简单的减速器代码

@Override
public void reduce(Text arg0, Iterator<IntWritable> arg1,
        OutputCollector<Text, IntWritable> arg2, Reporter arg3)
        throws IOException {
    // TODO Auto-generated method stub
    System.out.println("in reducer");

}

这是运行工作的主类

JobConf jobConf = new JobConf(jobrunner.class);
jobConf.setJobName("Chaining");

FileInputFormat.setInputPaths(jobConf, new Path("hdfs://localhost:9000/employee_data.txt"));
FileOutputFormat.setOutputPath(jobConf,new Path("hdfs://localhost:9000/chain3.txt"));

JobConf conf1 = new JobConf(false);

ChainMapper.addMapper(jobConf,chainmap.class,LongWritable.class,Text.class,Text.class,IntWritable.class,true,conf1);

JobConf conf2 = new JobConf(false);

ChainReducer.setReducer(jobConf, chainreduce.class,Text.class,IntWritable.class,Text.class,IntWritable.class,true,conf2);

JobClient.runJob(jobConf);

不知道我哪里出错了。reducer 中的 sysout 没有被打印出来。对此有什么帮助吗?

4

1 回答 1

0

可能的原因:您没有从映射器输出任何内容以供减速器首先运行。尝试使用 outputCollector.collect(key, value);from mapper 为 reducer 实际运行编写一些东西。

于 2013-08-17T19:38:48.787 回答