MapReduce关于key的定义、hashCode()、equals(Object obj)、compareTo(CustomCombineKey other)

版权声明:个人 https://blog.csdn.net/csdnmrliu/article/details/83306760

1. mapreduce中自定义mapout、reduceinput的key

key需实现WritableComparable<KEY> 接口

1.1 重写下面的三个方法

1.2 重写hashCode()和equals(Object obj)

2. mapreduce何时调用hashCode()、equals(Object obj)、compareTo(CustomCombineKey other)

2.1 compareTo(CustomCombineKey other)

spill(溢出)到磁盘时,会先进行一次快排,此时调用key的compareTo方法。

猜你喜欢

转载自blog.csdn.net/csdnmrliu/article/details/83306760