MapReduce 自定义数据类型
需求:
具体实现
(1)创建类实现WritableComparable或者Writable
(2)根据需要定义属性,生成get/set
(3)构造:空参,带参数
(4)序列化和反序列方法实现
(5)比较方法compareTo
(6)toString方法的实现
Map代码:
package com.huadian.bigdata.usertest;
import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;
import java.io.IOException;
public class UserMapper extends Mapper<LongWritable,Text,Text, IntWritable> {
private Text mapOutKey = new Text( );
private final static IntWritable mapOutValue = new IntWritable(1);
@Override
protected void map(LongWritable key, Tex