values, Context context) throws IOException, InterruptedException {
if (time == 0) {
(new Text("grand_child"), new Text("grand_parent"));
time++;
}
int grand_child_num = 0;
String grand_child[] = new String[10];
int grand_parent_num = 0;
String grand_parent[] = new String[10];
Iterator ite = ();
while ()) {
String record = ().toString();
int len = ();
int i = 2;
if (len == 0)
continue;
char relation_type = (0);
String child_name = new String();
String parent_name = new String();
while (i) != '+') {
child_name = child_name + (i);
i++;
}
i = i + 1;
while (i < len) {
parent_name = parent_name + (i);
i++;
}
if (relation_type == '1') {
grand_child[grand_child_num] = child_name;
grand_child_num++;
} else {
grand_parent[grand_parent_num] = parent_name;
grand_parent_num++;
}
}
if (grand_parent_num != 0 && grand_child_num != 0) {
for (int m = 0; m < grand_child_num; m++) {
for (int n = 0; n < grand_parent_num; n++) {
(new Text(grand_child[m]), new Text(
grand_parent[n]));
}
}
}
}
}
public static void main(String[] args) throws Exception {
Configuration conf = new Configuration();
("", "");
String[] otherArgs = new String[] { "input3", "output3" };
if != 2) {
"Usage: Single Table Join "); (2);
}
Job job = (conf, "Single table join ");
;
;
;
;
;
(job, new Path(otherArgs[0]));
(job, new Path(otherArgs[1]));
(true) ? 0 : 1);
}
}
4.实验报告
| 《云计算》 实验报告 |
| 题目: | MapReduce编程初级实践 | 姓名 | 包生友 | 日期:2016/12/20 |
| 实验环境:机房的虚拟机上配置好的环境 |
| 解决问题的思路:根据老师给的代码进行操作 |
| 实验内容与完成情况:已完成,与同学商量后仍有部分代码尚未知道其作用所在 |
| 出现的问题:执行之后,出现未找到main函数情况,再次执行会报错,说文件已经存在。 |
| 解决方案(列出遇到的问题和解决办法,列出没有解决的问题): 问题:1.执行之后,出现未找到main函数情况 2. 再次执行会报错,说文件已经存在。 解决办法:删除输出文件即可(程序执行时输出文件不能存在) |
5.实验总结通过本次实验,使我掌握基本的MapReduce编程方法;掌握用MapReduce解决一些常见的数据处理问题,包括数据去重、数据排序和数据挖掘等。短暂的云计算课程实验到此结束,到我知道对云计算的学习是没有尽头的。下载本文