daily pastebin goal
8%
SHARE
TWEET

Untitled

a guest Jan 18th, 2019 51 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package tp;
  2.  
  3. import org.apache.hadoop.conf.Configuration;
  4. import org.apache.hadoop.fs.Path;
  5. import org.apache.hadoop.io.IntWritable;
  6. import org.apache.hadoop.io.Text;
  7. import org.apache.hadoop.mapreduce.Job;
  8. import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
  9. import org.apache.hadoop.mapreduce.lib.input.TextInputFormat;
  10. import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;
  11. import org.apache.hadoop.mapreduce.lib.output.TextOutputFormat;
  12.  
  13. public class WordCount {
  14.     public static void main(String[] args) throws Exception {      
  15.         Configuration conf = new Configuration();
  16.         Job job = Job.getInstance(conf, "wordcount");
  17.         Path outputFolder = new Path(args[1]);
  18.         outputFolder.getFileSystem(conf).delete(outputFolder, true);
  19.         job.setOutputKeyClass(Text.class);
  20.         job.setOutputValueClass(IntWritable.class);
  21.         job.setMapperClass(MyMapper.class);
  22.         job.setReducerClass(MyReducer.class);
  23.         job.setJarByClass(WordCount.class);
  24.         job.setInputFormatClass(TextInputFormat.class);
  25.         job.setOutputFormatClass(TextOutputFormat.class);
  26.         FileInputFormat.addInputPath(job, new Path(args[0]));
  27.         FileOutputFormat.setOutputPath(job, new Path(args[1]));
  28.         job.waitForCompletion(true);
  29.     }
  30. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top