package mrpro924;
import java.io.IOException;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.Mapper;
import org.apache.hadoop.mapreduce.Reducer;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;
public class WordCountMP {
//写一个内部类,继承Mapper 类
//<偏移量类型,一行内容的类型,输出key类型,输出value类型>
public static class MyMapper extends Mapper<LongWritable, Text, Text, IntWritable>{
//一行调用一次
@Override
protected void map(LongWritable key, Text value,
Mapper<LongWritable, Text, Text, IntWritable>.Context context)
throws IOException, InterruptedException {
//逐行读取,内容在value中
//Text对象转String用toString()
//String对象转Text用new
mapreduce入门案例wordcount
最新推荐文章于 2022-10-16 18:10:34 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)