avoid using Math.abs

review comment on - c6f5311
To avoid overflow issues and unnecessary calls to Math.abs.
This commit is contained in:
nishantmonu51 2014-04-08 21:58:54 +05:30
parent f726e52e3b
commit 2c8682a1b6
1 changed files with 1 additions and 5 deletions

View File

@ -51,11 +51,7 @@ public class HashBasedNumberedShardSpec extends NumberedShardSpec
@Override
public boolean isInChunk(InputRow inputRow)
{
int hash = Math.abs(hash(inputRow));
if (hash == Integer.MIN_VALUE) {
hash = 0;
}
return hash % getPartitions() == getPartitionNum();
return (((long) hash(inputRow)) - getPartitionNum()) % getPartitions() == 0;
}
protected int hash(InputRow inputRow)