Last active
February 16, 2021 08:54
-
-
Save ebrucucen/fa32fece01f93f165b142091dc02a4ac to your computer and use it in GitHub Desktop.
java example for mapreduce
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
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: ratemovie <in> <out>"); | |
System.exit(2); | |
} | |
Job job = new Job(conf, "rate movie"); | |
job.setJarByClass(MovieRating.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); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment