Advertisement
mouhsineelachbi

ObamaSpeech

Dec 9th, 2019
212
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.10 KB | None | 0 0
  1. package Topics;
  2.  
  3. import java.io.IOException;
  4.  
  5. import Topics.MyMapper;
  6. import Topics.MyReducer;
  7. //import mapreduce.WordCountJobClient;
  8.  
  9. import org.apache.hadoop.conf.Configuration;
  10. import org.apache.hadoop.fs.Path;
  11. import org.apache.hadoop.io.IntWritable;
  12. import org.apache.hadoop.io.Text;
  13. import org.apache.hadoop.mapreduce.Job;
  14. import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
  15. import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;
  16.  
  17. public class ObamaSpeech {
  18.     public static void main(String[] arg) throws IOException, ClassNotFoundException, InterruptedException{
  19.         Configuration conf = new Configuration();
  20.         Job job = Job.getInstance(conf, "word count");
  21.         job.setJarByClass(ObamaSpeech.class);
  22.         job.setMapperClass(MyMapper.class);
  23.         job.setCombinerClass(MyReducer.class);
  24.         job.setReducerClass(MyReducer.class);
  25.         job.setOutputKeyClass(Text.class);
  26.         job.setOutputValueClass(IntWritable.class);
  27.         FileInputFormat.addInputPath(job, new Path(arg[0]));
  28.         FileOutputFormat.setOutputPath(job, new Path(arg[1]));
  29.         System.exit(job.waitForCompletion(true) ? 0 : 1);
  30.     }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement