【问题标题】:reducer not getting executed in hadoopreducer 没有在 hadoop 中执行
【发布时间】:2013-08-18 03:38:48
【问题描述】:

嗨,我对这个 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");

    }

这是我的简单 reducer 代码

@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 没有被打印出来。对此有什么帮助吗?

【问题讨论】:

    标签: hadoop mapreduce reduce


    【解决方案1】:

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

    【讨论】:

    • 嗨,我已经按照你说的方式进行了操作,我的减速器正在执行,现在我必须在另一个映射器中使用这个减速器的输出。我在减速器之后向链中添加了另一个映射器但是reducer的输出并没有进入下一个映射器,而是从文件中获取值。对此有什么建议吗?
    • 既然你原来的问题没有,我要求你提出一个新问题,说明你在使用 map-reduce-map 链以及你尝试过的代码时遇到了什么问题。如果您认为它解决了您的问题,请将此问题标记为已解决。谢谢!
    猜你喜欢
    • 2015-07-15
    • 2014-01-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-06-11
    相关资源
    最近更新 更多