本文章只是个人在学习MapReduce的笔记
KeyValueTextInputFormat是FileInputFormat的一个实现类,每一行为一条记录,被分隔符分割为key,value。可以通过在驱动类中设置conf.set(KeyValueLineRecordReader.KEY_VALUE_SEPERATOR,"\t")设置分割符
案例:
Mapper类
package com.hadoop.KeyValueTextInputFormat;
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 KVTextMapper extends Mapper<Text,Text,Text, IntWritable> {
IntWritable v = new IntWritable(1);
@Override
protected void map(Text key, Text value, Contex