package whut;
import org.apache.hadoop.io.WritableComparable;
import org.apache.hadoop.io.WritableComparator;
//主要就是对于分组进行排序,分组只按照组建键中的一个值进行分组
public class TextComparator extends WritableComparator {
//必须要调用父类的构造器
protected TextComparator() {
super(TextInt.class,true);//注册comparator
}
@Override
public int compare(WritableComparable a, WritableComparable b) {
// TODO Auto-generated method stub
TextInt ti1=(TextInt)a;
TextInt ti2=(TextInt)b;
return ti1.getFirstKey().compareTo(ti2.getFirstKey());
}
}
相关阅读:
Hadoop权威指南(中文版-带目录索引)PDF
Hadoop权威指南(中文第2版)PDF
采用MapReduce与Hadoop进行大数据分析