Advertisement
Guest User

Untitled

a guest
May 29th, 2015
222
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  1. import java.io.IOException;
  2. import org.apache.hadoop.io.IntWritable;
  3. import org.apache.hadoop.io.LongWritable;
  4. import org.apache.hadoop.io.Text;
  5. import org.apache.hadoop.mapreduce.Mapper;
  6.  
  7. public class WordCountMapper extends Mapper<LongWritable, Text, Text, IntWritable> {
  8.  
  9. @Override
  10. public void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException {
  11.  
  12. String line = value.toString();
  13.  
  14. for (String word : line.split("\\W+")) {
  15. if (word.length() > 0) {
  16. context.write(new Text(word), new IntWritable(1));
  17. }
  18. }
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement