From 5503524b6c32ca7e97b2df623f8bd3686e67cb28 Mon Sep 17 00:00:00 2001 From: Alexander Boruchinkin Date: Wed, 13 Apr 2016 02:46:52 +0300 Subject: [PATCH] Handling the situation when hashCode == Integer.MIN_VALUE --- .../org/apache/phoenix/cache/aggcache/SpillManager.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/phoenix-core/src/main/java/org/apache/phoenix/cache/aggcache/SpillManager.java b/phoenix-core/src/main/java/org/apache/phoenix/cache/aggcache/SpillManager.java index 6d89c99cd05..a9d8c9c22dc 100644 --- a/phoenix-core/src/main/java/org/apache/phoenix/cache/aggcache/SpillManager.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/cache/aggcache/SpillManager.java @@ -247,8 +247,13 @@ public CacheEntry toCacheEntry(byte[] byte // Determines the partition, i.e. spillFile the tuple should get spilled to. private int getPartition(ImmutableBytesWritable key) { + int hashCode = key.hashCode(); + // *Math.abs(Integer.MIN_VALUE) == Integer.MIN_VALUE + if (hashCode == Integer.MIN_VALUE) { + hashCode = hashCode >> 1; + } // Simple implementation hash mod numFiles - return Math.abs(key.hashCode()) % numSpillFiles; + return Math.abs(hashCode) % numSpillFiles; } /**