一.在IDEA下编写java程序实现hadoop的wordcount操作。
Mapper代码:
package MapReduce_wc;
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;
import java.util.Locale;
public class MRMapper extends Mapper<LongWritable,Text,Text,IntWritable> {
IntWritable ONE = new IntWritable(1);
@Override
protected void setup(Context context) throws IOException, InterruptedException {
System.out.println("-----------setup-----------");
}
@Override
protected void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException {
System.out.println("-----------map-------------------");
//获取内容并转为小写
final String line = value.toString().toLowerCase(Locale.ROOT);
//按照分隔符进行拆分
final String[] splits