开发者学堂课程【Hadoop 分布式计算框架 MapReduce:WordCount 案例 Debug 调试】学习笔记,与课程紧密联系,让用户快速学习知识。
课程地址:https://developer.aliyun.com/learning/course/94/detail/1486
WordCount 案例 Debug 调试
调试程序:
1、打开E盘,删除 output1
2、右键点击 Debug As→Debug Configurations...
3、点击Debug
4、点击 ye
@Override protected void map(Longwritable key,Text value,Context context) throws IOException,InterruptedException { / / atguigu atguigu/l/1获取一行 String line = value.toString(); //2切割单词 String[]words = line.split(""); //3循环写出 for (String word : words) { // atguigu k.set(word); context.write(k, v); } |
@Override protected void reduce(Text key,Iterable<Intwritable> values, Context context) throws IOException,InterruptedException { / / atguigu,1 atguigu,1 Iint sum = 0; //1累加求和 for (Intwritable value : values) { sum += value.get(); } v.set(sum); //2写出atguigu 2 context.write(key, v); }
|