开发者学堂课程【Hadoop 分布式计算框架 MapReduce:序列化案例 Mapper】学习笔记,与课程紧密联系,让用户快速学习知识。
课程地址:https://developer.aliyun.com/learning/course/94/detail/1493
序列化案例 Mapper
1. 获取一行
2. 切割 \t
3. 封装对象
4. 写出
1.获取一行
String line = value. toString ();
2. 切割\t
String[] fields = line. split("\t");
3.封装对象
k.set(fields[1]);//封装手机号
long upFlow = Long. parseLong (fields [fields. length- 3]);long downFlow = Long. parseLong (fields [fields. length- 2);
v.setUpFlow(upFlow);
v.setDownFlow(downFlow);
//v.set(upFlow,downFlow);
4.写出
context. write (k, v);