Hadoop 多重输出映射减少不起作用
我试图从reducer将(键和值)写入不同的文件,但我只得到一个键和值的输出文件Hadoop 多重输出映射减少不起作用,hadoop,mapreduce,Hadoop,Mapreduce,我试图从reducer将(键和值)写入不同的文件,但我只得到一个键和值的输出文件 public static class Reduce extends Reducer<Text,Text,Text,Text> { private MultipleOutputs <Text,Text>mos; @Override protected void setup(Context context) throws IOException, Interru
public static class Reduce
extends Reducer<Text,Text,Text,Text> {
private MultipleOutputs <Text,Text>mos;
@Override
protected void setup(Context context) throws IOException, InterruptedException {
super.setup(context);
}
public void reduce(Text key, Text values, Context context ) throws IOException, InterruptedException {
mos.write(key.toString(),values, key); }
@Override
protected void cleanup(Context context) throws IOException,
InterruptedException {
super.cleanup(context);
}
}// end Reducer
multipleoutput
类的write
方法有三个签名,如下所示
write(KEYOUT key, VALUEOUT value, String baseOutputPath)
Write key value to an output file name.
write(String namedOutput, K key, V value)
Write key and value to the namedOutput.
write(String namedOutput, K key, V value, String baseOutputPath)
Write key and value to baseOutputPath using the namedOutput
看起来您正在使用第二个参数,但更改了键和值参数。另外,如果传递整个值Iterable
,我不知道该方法的行为
作为建议,您可以使用第三个签名,这更简单,因为您不需要调用addNamedOutput
,只需写入任何baseOutputPath
例如:
mos.write(key, value, "express");
生成的输出文件的名称是什么?
mos.write(key, value, "express");