2 | | public void map(LongWritable key, Text value, |
3 | | OutputCollector<Text, IntWritable> output, Reporter reporter) |
4 | | throws IOException { |
5 | | String line = (caseSensitive) ? value.toString() : value.toString() |
6 | | .toLowerCase(); |
| 2 | public static class Map extends MapReduceBase implements Mapper<LongWritable, Text, Text, IntWritable> { |
| 3 | public void map(LongWritable key, Text value, OutputCollector<Text, IntWritable> output, Reporter reporter) throws IOException { |
19 | | if ((++numRecords % 100) == 0) { |
20 | | reporter.setStatus("Finished processing " + numRecords |
21 | | + " records " + "from the input file: " + inputFile); |
22 | | } |
23 | | } |
24 | | } |
| 12 | {{{ |
| 13 | public static class Reduce extends MapReduceBase implements Reducer<Text, IntWritable, Text, IntWritable> { |
| 14 | public void reduce(Text key, Iterator<IntWritable> values,OutputCollector<Text, IntWritable> output, Reporter reporter) throws IOException { |
| 15 | int sum = 0; |
| 16 | while (values.hasNext()) { |
| 17 | sum += values.next().get(); |
| 18 | } |
| 19 | output.collect(key, new IntWritable(sum)); |
26 | | public static class Reduce extends MapReduceBase implements |
27 | | Reducer<Text, IntWritable, Text, IntWritable> { |
28 | | public void reduce(Text key, Iterator<IntWritable> values, |
29 | | OutputCollector<Text, IntWritable> output, Reporter reporter) |
30 | | throws IOException { |
31 | | int sum = 0; |
32 | | while (values.hasNext()) { |
33 | | sum += values.next().get(); |
34 | | } |
35 | | output.collect(key, new IntWritable(sum)); |
36 | | } |
37 | | } |