一:盘算数据平均值
在map中将名称作为key 数据为value写出去
/*
* 盘算平均成就
* 名字作为key 分数值为value写出去
*/
public class AverageMap extends Mapper<LongWritable, Text, Text, IntWritable> {
protected void map(
LongWritable key,
Text value,
org.apache.hadoop.mapreduce.Mapper<LongWritable, Text, Text, IntWritable>.Context context)
throws java.io.IOException, InterruptedException {
String line = value.toString();
if (line.trim().length() > 0) {
String[] str = line.split("\t");
if (str.length == 2) {
context.write(new Text(str[0]),
new IntWritable(Integer.valueOf(str[1])));
}
}
};
}/*
* 盘算平均成就