From 2c8682a1b66a7b17aacf5d4b5886f287c808b770 Mon Sep 17 00:00:00 2001 From: nishantmonu51 Date: Tue, 8 Apr 2014 21:58:54 +0530 Subject: [PATCH] avoid using Math.abs review comment on - c6f5311 To avoid overflow issues and unnecessary calls to Math.abs. --- .../timeline/partition/HashBasedNumberedShardSpec.java | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/server/src/main/java/io/druid/timeline/partition/HashBasedNumberedShardSpec.java b/server/src/main/java/io/druid/timeline/partition/HashBasedNumberedShardSpec.java index 57cb5660f0f..5110f886601 100644 --- a/server/src/main/java/io/druid/timeline/partition/HashBasedNumberedShardSpec.java +++ b/server/src/main/java/io/druid/timeline/partition/HashBasedNumberedShardSpec.java @@ -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)