MAPREDUCE-5886. Merging change r1601704 from trunk to branch-2.

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-2@1601707 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Chris Nauroth 2014-06-10 17:52:27 +00:00
parent 8be4504d9a
commit 91c53d97bd
2 changed files with 10 additions and 4 deletions

View File

@ -62,6 +62,9 @@ Release 2.5.0 - UNRELEASED
MAPREDUCE-5899. Support incremental data copy in DistCp. (jing9) MAPREDUCE-5899. Support incremental data copy in DistCp. (jing9)
MAPREDUCE-5886. Allow wordcount example job to accept multiple input paths.
(cnauroth)
OPTIMIZATIONS OPTIMIZATIONS
BUG FIXES BUG FIXES

View File

@ -68,8 +68,8 @@ public class WordCount {
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {
Configuration conf = new Configuration(); Configuration conf = new Configuration();
String[] otherArgs = new GenericOptionsParser(conf, args).getRemainingArgs(); String[] otherArgs = new GenericOptionsParser(conf, args).getRemainingArgs();
if (otherArgs.length != 2) { if (otherArgs.length < 2) {
System.err.println("Usage: wordcount <in> <out>"); System.err.println("Usage: wordcount <in> [<in>...] <out>");
System.exit(2); System.exit(2);
} }
Job job = new Job(conf, "word count"); Job job = new Job(conf, "word count");
@ -79,8 +79,11 @@ public class WordCount {
job.setReducerClass(IntSumReducer.class); job.setReducerClass(IntSumReducer.class);
job.setOutputKeyClass(Text.class); job.setOutputKeyClass(Text.class);
job.setOutputValueClass(IntWritable.class); job.setOutputValueClass(IntWritable.class);
FileInputFormat.addInputPath(job, new Path(otherArgs[0])); for (int i = 0; i < otherArgs.length - 1; ++i) {
FileOutputFormat.setOutputPath(job, new Path(otherArgs[1])); FileInputFormat.addInputPath(job, new Path(otherArgs[i]));
}
FileOutputFormat.setOutputPath(job,
new Path(otherArgs[otherArgs.length - 1]));
System.exit(job.waitForCompletion(true) ? 0 : 1); System.exit(job.waitForCompletion(true) ? 0 : 1);
} }
} }