WCMapper

package com.sxt.hbase;

import java.io.IOException;

import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;
import org.apache.hadoop.util.StringUtils;

public class WCMapper extends Mapper<LongWritable,Text,Text,IntWritable>{

	
	protected void map(LongWritable key, Text value, Context context)
			throws IOException, InterruptedException {
		String[] strs = StringUtils.split(value.toString(), ' ');
		for (String s:strs) {
			context.write(new Text(s), new IntWritable(1));
		}
	}
}

  

posted @ 2018-06-23 20:02  uuhh  阅读(158)  评论(0)    收藏  举报