【问题标题】:not able to access the reduce method in reduce class无法访问reduce类中的reduce方法
【发布时间】:2015-05-08 14:06:54
【问题描述】:
 public static class Reduce extends Reducer<Text, Text, Text, Text>
    {
        private Text txtReduceOutputKey = new Text("");
        private Text txtReduceOutputValue = new Text("");
    public void reduce(Text key, Iterator<Text> values, Context context) throws IOException, InterruptedException
    {
        //some code;
    }
}

它没有给出任何错误。我能够访问该类,因为我能够启动这些变量txtReduceOutputKeytxtReduceOutputValue。但reduce 方法在执行时被忽略。所以我无法运行上述方法中的代码//一些代码。我也在使用下面的包。

import org.apache.hadoop.mapreduce.Mapper;
import org.apache.hadoop.mapreduce.Reducer;
import org.apache.hadoop.mapreduce.Job;

知道如何解决这个问题吗?

【问题讨论】:

    标签: hadoop mapreduce reduce reducers


    【解决方案1】:

    请确保您已在驱动程序代码中设置了Reducer 类。 例如:-

    job.setReducerClass(Base_Reducer.class);
    

    【讨论】:

      【解决方案2】:

      出现这些问题的原因如下:

      1. 不覆盖reduce() 方法 - 最好使用override 进行注释
      2. 前面评论中提到,忘记在驱动代码中设置reducer

      【讨论】:

        【解决方案3】:

        这是因为Iterator。它应该替换为Iterable。 谢谢。

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 2014-09-11
          • 2021-12-26
          • 2020-07-08
          • 2021-01-13
          • 1970-01-01
          • 2018-05-09
          • 1970-01-01
          • 2022-08-16
          相关资源
          最近更新 更多