如何可以在实施例中改变代码在WordCount.java程序使得WordCounts的每个文件的输出是把单独的文件。也就是说,不是在该默认part-00000文件中包含一个wordcount所有文件。此外,输出文件的名称始终为part-00000或其他名称,我可以选择我想要的文件的输出文件名,如果是这样的话?
我想我必须以某种方式配置它,但是我已经搜索了这个,我找不到如何做到这一点?
public static void main(String[] args) throws Exception {
Configuration conf = new Configuration();
String[] otherArgs = new GenericOptionsParser(conf, args).getRemainingArgs();
if (otherArgs.length != 2) {
System.err.println("Usage: wordcount <in> <out>");
System.exit(2);
}
Job job = new Job(conf, "word count");
job.setJarByClass(WordCount.class);
job.setMapperClass(TokenizerMapper.class);
job.setCombinerClass(IntSumReducer.class);
job.setReducerClass(IntSumReducer.class);
job.setOutputKeyClass(Text.class);
job.setOutputValueClass(IntWritable.class);
FileInputFormat.addInputPath(job, new Path(otherArgs[0]));
FileOutputFormat.setOutputPath(job, new Path(otherArgs[1]));
System.exit(job.waitForCompletion(true) ? 0 : 1);
}
任何帮助表示赞赏, 特德
请显示您的多个文件输出代码。 – 2011-04-14 04:36:43