Jackie-Jiang commented on code in PR #8891:
URL: https://github.com/apache/pinot/pull/8891#discussion_r899406054


##########
pinot-spi/src/main/java/org/apache/pinot/spi/utils/ByteArray.java:
##########
@@ -54,6 +53,9 @@ public class ByteArray implements Comparable<ByteArray>, 
Serializable {
 
   private final byte[] _bytes;
 
+  // Hash for empty ByteArray is 1
+  private int _hash = 1;
+
   public ByteArray(byte[] bytes) {

Review Comment:
   @richardstartin I'm following the `String` implementation within the 
`adopt-openjdk-11` which has the following check:
   ```
       public int hashCode() {
           int h = hash;
           if (h == 0 && value.length > 0) {
               hash = h = isLatin1() ? StringLatin1.hashCode(value)
                                     : StringUTF16.hashCode(value);
           }
           return h;
       }
   ```
   I assume the collision will be super rare, and is not worth the overhead of 
storing an extra boolean field? Do you know if this implementation is changed 
in newer JDK version?



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