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; } /**