Created
January 2, 2011 05:29
-
-
Save sujee/762314 to your computer and use it in GitHub Desktop.
TestMR.java : basic map reduce program that takes input path as an argument
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* http://sujee.net/tech/articles/amazon-emr-beyond-basics/ | |
* takes one argument for input path | |
*/ | |
public class TestMR extends Configured implements Tool | |
{ | |
public static void main(String[] args) throws Exception | |
{ | |
int res = ToolRunner.run(new Configuration(), new TestMR(), args); | |
System.exit(res); | |
} | |
@Override | |
public int run(String[] args) throws Exception | |
{ | |
if (args.length < 1) | |
{ | |
System.err.printf("Usage: %s [generic options] <input_paths>\n", getClass().getSimpleName()); | |
ToolRunner.printGenericCommandUsage(System.err); | |
return -1; | |
} | |
Configuration conf = getConf(); | |
Job job = new Job(conf, "TestMR"); | |
job.setJarByClass(TestMR.class); | |
job.setMapperClass(TestMapper.class); | |
job.setReducerClass(TestReducer.class); | |
job.setMapOutputKeyClass(Text.class); | |
job.setMapOutputValueClass(Text.class); | |
job.setOutputFormatClass(Text.class); | |
FileInputFormat.addInputPath(job, args[0]); | |
FileInputFormat.addOutputPath(job, args[1]); | |
return job.waitForCompletion(true) ? 0 : 1; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment