Changes between Version 8 and Version 9 of waue/2009/0715


Ignore:
Timestamp:
Jul 15, 2009, 5:31:16 PM (15 years ago)
Author:
waue
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • waue/2009/0715

    v8 v9  
    1717
    1818{{{
    19 public static class Map extends MapReduceBase implements Mapper<LongWritable, Text, Text, IntWritable> {
    20 public void map(LongWritable key, Text value, OutputCollector<Text, IntWritable> output, Reporter reporter) throws IOException {
    21 
    22 while (tokenizer.hasMoreTokens()) {
    23                 private final static IntWritable one = new IntWritable(1);
    24                 private Text word = new Text();
    25                 output.collect(word, one);
    26 
     19#!java
     2014.          public static class Map extends MapReduceBase implements Mapper<LongWritable, Text, Text, IntWritable> {
     2115.          private final static IntWritable one = new IntWritable(1);
     2216.          private Text word = new Text();
     2317.     
     2418.          public void map(LongWritable key, Text value, OutputCollector<Text, IntWritable> output, Reporter reporter) throws IOException {
     2519.            String line = value.toString();
     2620.            StringTokenizer tokenizer = new StringTokenizer(line);
     2721.            while (tokenizer.hasMoreTokens()) {
     2822.              word.set(tokenizer.nextToken());
     2923.              output.collect(word, one);
     3024.            }
     3125.          }
     3226.        }
     3327.     
     3428.        public static class Reduce extends MapReduceBase implements Reducer<Text, IntWritable, Text, IntWritable> {
     3529.          public void reduce(Text key, Iterator<IntWritable> values, OutputCollector<Text, IntWritable> output, Reporter reporter) throws IOException {
     3630.            int sum = 0;
     3731.            while (values.hasNext()) {
     3832.              sum += values.next().get();
     3933.            }
     4034.            output.collect(key, new IntWritable(sum));
     4135.          }
     4236.        }
    2743}}}
    28 
    29 {{{
    30 public static class Reduce extends MapReduceBase implements Reducer<Text, IntWritable, Text, IntWritable> {
    31 public void reduce(Text key, Iterator<IntWritable> values,OutputCollector<Text, IntWritable> output, Reporter reporter) throws IOException {
    32 int sum = 0;
    33 while (values.hasNext()) {
    34         sum += values.next().get();
    35 }
    36 output.collect(key, new IntWritable(sum));
    37 
    38 }}}