[
https://issues.apache.org/jira/browse/PHOENIX-1472?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14225758#comment-14225758
]
James Taylor commented on PHOENIX-1472:
---------------------------------------
How about we just release note it? It's somewhat unlikely, right? It's only if
the value was Integer.MAX_VALUE, right? Otherwise it's a bigger issue.
Kind of esoteric, but would one alternative to your solution be to do this?
{code}
--- a/phoenix-core/src/main/java/org/apache/phoenix/schema/SaltingUtil.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/schema/SaltingUtil.java
@@ -73,8 +73,7 @@ public class SaltingUtil {
// Generate the bucket byte given a byte array and the number of buckets.
public static byte getSaltingByte(byte[] value, int offset, int length,
int bucketNum) {
int hash = calculateHashCode(value, offset, length);
- byte bucketByte = (byte) ((Math.abs(hash) % bucketNum));
- return bucketByte;
+ return (byte) Math.abs(hash % bucketNum);
}
{code}
> SaltingUtil calculates wrong salt key for Integer.MIN_VALUE hash code
> ---------------------------------------------------------------------
>
> Key: PHOENIX-1472
> URL: https://issues.apache.org/jira/browse/PHOENIX-1472
> Project: Phoenix
> Issue Type: Bug
> Reporter: Gabriel Reid
> Attachments: PHOENIX-1472.patch
>
>
> There is an edge case in SaltingUtil.getSaltingByte where an invalid salt
> byte is calculated. This happens when the hash code of the row key being
> salted is equal to {{Integer.MIN_VALUE}}. The underlying bug is the use of
> Math.abs(hashCode) in SaltingUtil.getSaltingByte, and the result of the bug
> is that a hash code outside of the range of configured salt buckets can be
> returned.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)