3.1.5 CombineTextInputFormat案例实操
示例:统计单词个数
- 准备工作
在hdfs的根目录下创建input文件夹,然后在里面放置4个大小分别为1.5M、35M、5.5M、6.5M的小文件作为输入数据
- 具体代码
public class WordCountMapper extends Mapper<LongWritable, Text, Text, IntWritable> {
private Text mapOutputKey = new Text();
private IntWritable mapOutputValue = new IntWritable();
@Override
protected void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException {
String linevalue = value.toString();
StringTokenizer st = new StringTokenizer(linevalue);
while (st.hasMoreTokens()