資源簡介
MapReduce字數統計案例,希望大家交流,最好自己寫完后在對比交流,歡迎前來交流
代碼片段和文件信息
package?mytest;
import?java.io.IOException;
import?org.apache.hadoop.io.IntWritable;
import?org.apache.hadoop.io.LongWritable;
import?org.apache.hadoop.io.Text;
import?org.apache.hadoop.mapreduce.Mapper;
public?class?myMapper?extends?Mapper?{
@Override
protected?void?map(LongWritable?key?Text?value?Mapper.Context?context)
throws?IOException?InterruptedException?{
String[]?str?=?value.toString().split(“?“);
// for(String?ss:str)?{
// context.write(new?Text(ss)?new?IntWritable(1));
// }
Text?ss?=?new?Text();
ss.set(“loglevel::“+str[1]);
context.write(ss?new?IntWritable(1));
ss.clear();
ss.set(“logresource::“+str[2]);
context.write(ss?new?IntWritable(1));
}
}
- 上一篇:MbFix (恢復mbr de工具)
- 下一篇:PXA270DB開發板資料
評論
共有 條評論