• Home
  • Features
  • Lifetsyle
    • Category
    • Category
    • Category
  • Travel
  • Shop
  • Download
facebook twitter instagram pinterest Bloglovin

USA Breaking News

package wc; import java.io.IOException; import java.util.*; import org.apache.hadoop.conf.*; import org.apache.hadoop.fs.*; import org.apache.hadoop.conf.*; import org.apache.hadoop.io.*; import org.apache.hadoop.mapreduce.*; import org.apache.hadoop.mapreduce.lib.input.*; import org.apache.hadoop.mapreduce.lib.output.*; import org.apache.hadoop.util.*; public class WordCount extends Configured implements Tool { public static void main(String args[]) throws Exception { int res = ToolRunner.run(new WordCount(), args); System.exit(res); } public int run(String[] args) throws Exception { Path inputPath = new Path(args[0]); Path outputPath = new Path(args[1]); Configuration conf = getConf(); Job job = new Job(conf, this.getClass().toString()); FileInputFormat.setInputPaths(job, inputPath); FileOutputFormat.setOutputPath(job, outputPath); job.setJobName("WordCount"); job.setJarByClass(WordCount.class); job.setInputFormatClass(TextInputFormat.class); job.setOutputFormatClass(TextOutputFormat.class); job.setMapOutputKeyClass(Text.class); job.setMapOutputValueClass(IntWritable.class); job.setOutputKeyClass(Text.class); job.setOutputValueClass(IntWritable.class); job.setMapperClass(Map.class); job.setCombinerClass(Reduce.class); job.setReducerClass(Reduce.class); return job.waitForCompletion(true) ? 0 : 1; } public static class Map extends Mapper { private final static IntWritable one = new IntWritable(1); private Text word = new Text(); @Override public void map(LongWritable key, Text value, Mapper.Context context) throws IOException, InterruptedException { String line = value.toString(); StringTokenizer tokenizer = new StringTokenizer(line); while (tokenizer.hasMoreTokens()) { word.set(tokenizer.nextToken()); context.write(word, one); } } } public static class Reduce extends Reducer { @Override public void reduce(Text key, Iterable values, Context context) throws IOException, InterruptedException { int sum = 0; for (IntWritable value : values) { sum += value.get(); } context.write(key, new IntWritable(sum)); } } }
Share
Tweet
Pin
Share
No comments
Sat Sep 14
Typhoon with Radiation City
The Hi-Dive
7 S. Broadway
Denver, CO 80209
9:30 PM

$13.00
Tickets
Share
Tweet
Pin
Share
No comments
Newer Posts
Older Posts

About me

About Me

Months had too ham cousin remove far spirit. She procuring the why performed continual improving.

Read More

Follow Us

  • facebook
  • twitter
  • instagram
  • pinterest
  • bloglovin
  • etsy

recent posts

Sponsor

Get this Recent Comments Widget

Facebook

Blog Archive

  • ▼  2017 (3)
    • ▼  December (2)
      • package wc; import java.io.IOException; import ja...
      • Sat Sep 14 Typhoon with Radiation City The Hi-...
    • ►  November (1)

Press

More Top Stories - Google News

Loading...

Created with by ThemeXpose | Distributed By Gooyaabi Templates