Jackie-Jiang commented on a change in pull request #8221:
URL: https://github.com/apache/pinot/pull/8221#discussion_r810313565



##########
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:
       Actually they are not the same if the hash code is `Integer.MIN_VALUE`, 
where the current one will always result in `0`. We are trying to match the 
Kafka 
[ByteArrayPartitioner](https://github.com/a0x8o/kafka/blob/master/core/src/main/scala/kafka/producer/ByteArrayPartitioner.scala)
 which uses this 
[abs()](https://github.com/a0x8o/kafka/blob/master/clients/src/main/java/org/apache/kafka/common/utils/Utils.java#L179).
   
   Let me add some comments on this




-- 
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