hadoop reducer中的java重写

e4eetjau  于 2021-06-03  发布在  Hadoop
关注(0)|答案(2)|浏览(319)

我是hadoop的初学者。我决定创建一个情绪分析程序。我有一个mapper类。Map器的输出是可长写的文本格式。输入减速器。因此我有一个减速机类

public class sentreducer extends Reducer<LongWritable,Text,LongWritable,Text>{
          @Override
            public void reduce(LongWritable key,Iterable<Text>value,Context context){
            }

编译器显示一个错误,说明无法重写该方法。为什么会这样?

pkmbmrz7

pkmbmrz71#

方法签名应为

public void reduce(LongWritable key, Iterator<Text> values,
        OutputCollector<LongWritable, Text> collector, Reporter reporter) throws IOException
wvmv3b1j

wvmv3b1j2#

我认为您必须在reduce方法中抛出ioexception和interruptedexception。

public class sentreducer extends Reducer<LongWritable,Text,LongWritable,Text>{
    @Override
    public void reduce(LongWritable key,Iterable<Text> value,Context context) throws IOException, InterruptedException {
    }
}

相关问题