HIVE-11761: DoubleWritable hashcode for GroupBy is not properly generated (Aihua Xu, reviewed by Chao Sun)
Project: http://git-wip-us.apache.org/repos/asf/hive/repo Commit: http://git-wip-us.apache.org/repos/asf/hive/commit/70144073 Tree: http://git-wip-us.apache.org/repos/asf/hive/tree/70144073 Diff: http://git-wip-us.apache.org/repos/asf/hive/diff/70144073 Branch: refs/heads/llap Commit: 70144073466fb72b5903ede37d65b159d44a367a Parents: 7a71e50 Author: Aihua Xu <aihu...@gmail.com> Authored: Thu Sep 10 10:18:24 2015 -0700 Committer: Chao Sun <sunc...@apache.org> Committed: Thu Sep 10 10:18:33 2015 -0700 ---------------------------------------------------------------------- .../java/org/apache/hadoop/hive/ql/exec/KeyWrapperFactory.java | 4 ++++ 1 file changed, 4 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/hive/blob/70144073/ql/src/java/org/apache/hadoop/hive/ql/exec/KeyWrapperFactory.java ---------------------------------------------------------------------- diff --git a/ql/src/java/org/apache/hadoop/hive/ql/exec/KeyWrapperFactory.java b/ql/src/java/org/apache/hadoop/hive/ql/exec/KeyWrapperFactory.java index 22bd951..1c409a2 100644 --- a/ql/src/java/org/apache/hadoop/hive/ql/exec/KeyWrapperFactory.java +++ b/ql/src/java/org/apache/hadoop/hive/ql/exec/KeyWrapperFactory.java @@ -29,6 +29,7 @@ import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspectorUtils.Object import org.apache.hadoop.hive.serde2.objectinspector.primitive.StringObjectInspector; import org.apache.hadoop.hive.serde2.typeinfo.TypeInfoFactory; import org.apache.hadoop.hive.serde2.typeinfo.TypeInfoUtils; +import org.apache.hadoop.io.DoubleWritable; import org.apache.hadoop.io.Text; public class KeyWrapperFactory { @@ -114,6 +115,9 @@ public class KeyWrapperFactory { if(element instanceof LazyDouble) { long v = Double.doubleToLongBits(((LazyDouble)element).getWritableObject().get()); hashcode = hashcode + (int) (v ^ (v >>> 32)); + } else if (element instanceof DoubleWritable){ + long v = Double.doubleToLongBits(((DoubleWritable)element).get()); + hashcode = hashcode + (int) (v ^ (v >>> 32)); } else { hashcode = hashcode + element.hashCode(); }