0
我試圖從reducer寫入不同的文件(鍵和值),但我只有一個鍵和值的輸出文件。MultipleOutputs map reduce不起作用
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
//驅動程序:它包含多個切口
job.setMapperClass(Map.class);
job.setReducerClass(Reduce.class);
job.setCombinerClass(Reduce.class);
job.setInputFormatClass(TextInputFormat.class);
job.setOutputFormatClass(TextOutputFormat.class);
// set output key type
job.setOutputKeyClass(Text.class);
// set output value type
job.setOutputValueClass(Text.class);
//set the HDFS path of the input data
FileInputFormat.addInputPath(job, new Path(otherArgs[0]));
// set the HDFS path for the output
FileOutputFormat.setOutputPath(job, new Path(otherArgs[1]));
//multiple output files
MultipleOutputs.addNamedOutput(job, "express", TextOutputFormat.class, Text.class, Text.class);
什麼是生成的輸出文件的名稱? –