richardstartin commented on a change in pull request #8221:
URL: https://github.com/apache/pinot/pull/8221#discussion_r809903284



##########
File path: 
pinot-segment-spi/src/main/java/org/apache/pinot/segment/spi/partition/ByteArrayPartitionFunction.java
##########
@@ -40,8 +42,8 @@ public ByteArrayPartitionFunction(int numPartitions) {
   }
 
   @Override
-  public int getPartition(Object valueIn) {
-    return abs(Arrays.hashCode(valueIn.toString().getBytes())) % 
_numPartitions;
+  public int getPartition(Object value) {
+    return (Math.abs(Arrays.hashCode(value.toString().getBytes(UTF_8))) & 
Integer.MAX_VALUE) % _numPartitions;

Review comment:
       Sorry, what I meant was 
   
   ```java
   Math.abs(Arrays.hashCode(value.toString().getBytes(UTF_8)) % _numPartitions);
   ```
   
   produces the right value, because 
`Arrays.hashCode(value.toString().getBytes(UTF_8)))  % _numPartitions` takes a 
value in the range `(-_numPartitions, _numPartitions)` which excludes 
`Integer.MIN_VALUE`, - `Math.abs` is defined everywhere on this domain.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to