在给定的文本文件中统计输出每一个单词出现的总次数
- 输入数据
atguigu atguigu
ss ss
cls cls
jiao
banzhang
xue
hadoop
- 按照MapReduce编程规范,分别编写Mapper,Reducer,Driver
- 编写Mapper类
package MRS;
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 java.io.IOException;
public class WordCountMapper extends Mapper<LongWritable,Text, Text, IntWritable> {
Text k = new Text();
IntWritable v = new IntWritable(1);
@Override
protected void map(LongWritable key,Text value,Context context) throws IOException, InterruptedException {
//获取一行
String line = value.toString();
//切割
String[