问题描述
解决方案
解决方案二:
Mapper后面需要写上输入类型和输出类型,就像这样:
public class MapperClass extends Mapper<Object, Text, Text, IntWritable>{
private Text result = new Text();
private IntWritable one = new IntWritable(1);
@Override
protected void map(Object key, Text value,Context context)
throws IOException, InterruptedException {
//获取值
String[] strs = value.toString().split(" ");
//提取出key ,value设置为1
for(String str:strs)
{
result.set(str);
context.write(result, one);
}
}
}
时间: 2024-10-29 13:03:47