文档介绍:-
. z
实验报告
〔2021 / 2021 学年第二学期〕
课程名称
云计算
实验名称
基于Hado
import ;
import *tInputFormat;
import ileOutputFormat;
import *tOutputFormat;
import ;
 public class Score {
 public static class Map e*tends
 Mapper<LongWritable, Te*t, Te*t, IntWritable> {
 // 实现map函数
 public void map(LongWritable key, Te*t value, Conte*t conte*t)
 throws IOE*ception, InterruptedE*ception {
 // 将输入的纯文本文件的数据转化成String
String line = ();
 // 将输入的数据首先按行进展分割
StringTokenizer tokenizerArticle = new StringTokenizer(line, "\n");
 // 分别对每一行进展处理
-
. z
 while (()) {
 // 每行按空格划分
StringTokenizertokenizerLine= newStringTokenizer(*tToken());
String strName = *tToken();// 学生局部
String strScore = *tToken();// 成绩局部
Te*t name = new Te*t(strName);
int scoreInt = (strScore);// 输出和成绩
conte*(name, new IntWritable(scoreInt)); }
}
}
 public static class Reduce e*tends
Reducer<Te*t, IntWritable, Te*t, IntWritable> {
// 实现reduce函数
 public void reduce(Te*t key, Iterable<IntWritable> va