
- map阶段的核心:把输入的数据经过切割,全部标记1。因此输出就是<单词,1>。
shuffle阶段核心:经过默认的排序分区分组,key相同的单词会作为一组数据构成新的kv对。
- reduce阶段核心:处理shuffle完的一组数据,该组数据就是该单词所有的键值对。对所有的1
开发环境
程序实现
//map过程//创建静态类继承Mapper给上输入输出形参public static class WordCountMap extends Mapper<LongWritable,Text,Text,LongWritable>{@Override //重写map方法protected void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException {//每一次获取一行数据String line = value.toString();//通过values获取一行数据context.write(new Text(line),new LongWritable(1));}}
