mirror of https://github.com/apache/druid.git
avoid using Math.abs
review comment on - c6f5311
To avoid overflow issues and unnecessary calls to Math.abs.
This commit is contained in:
parent
f726e52e3b
commit
2c8682a1b6
|
@ -51,11 +51,7 @@ public class HashBasedNumberedShardSpec extends NumberedShardSpec
|
||||||
@Override
|
@Override
|
||||||
public boolean isInChunk(InputRow inputRow)
|
public boolean isInChunk(InputRow inputRow)
|
||||||
{
|
{
|
||||||
int hash = Math.abs(hash(inputRow));
|
return (((long) hash(inputRow)) - getPartitionNum()) % getPartitions() == 0;
|
||||||
if (hash == Integer.MIN_VALUE) {
|
|
||||||
hash = 0;
|
|
||||||
}
|
|
||||||
return hash % getPartitions() == getPartitionNum();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected int hash(InputRow inputRow)
|
protected int hash(InputRow inputRow)
|
||||||
|
|
Loading…
Reference in New Issue