-
大小: 1KB文件類型: .gz金幣: 1下載: 0 次發(fā)布日期: 2021-06-05
- 語言: 其他
- 標(biāo)簽: Hadoop??MapReduce??字?jǐn)?shù)統(tǒng)計(jì)??案例??學(xué)習(xí)??
資源簡介
MapReduce字?jǐn)?shù)統(tǒng)計(jì)案例,希望大家交流,最好自己寫完后在對(duì)比交流,歡迎前來交流
代碼片段和文件信息
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(“l(fā)oglevel::“+str[1]);
context.write(ss?new?IntWritable(1));
ss.clear();
ss.set(“l(fā)ogresource::“+str[2]);
context.write(ss?new?IntWritable(1));
}
}
評(píng)論
共有 條評(píng)論