Mapper
Java
code posted
by
Me
created at 12 Jun 22:20
Edit
|
Back
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
public class WordCount { public static class Map extends MapReduceBase implements Mapper<LongWritable, Text, Text, IntWritable> { private final static IntWritable one = new IntWritable(1); private Text word = new Text(); public void map(LongWritable key, Text value, OutputCollector<Text, IntWritable> output, Reporter reporter) throws IOException { String line = value.toString(); StringTokenizer tokenizer = new StringTokenizer(line); while (tokenizer.hasMoreTokens()) { word.set(tokenizer.nextToken()); output.collect(word, one); } } } } |
705 Bytes in 3 ms with coderay