richardstartin commented on code in PR #8891:
URL: https://github.com/apache/pinot/pull/8891#discussion_r898958120


##########
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:
   Java’s string added a flag whether the hash had been computed to avoid 
computing the hash every time if the hash code happened to be 0, the same 
should be done here in case the hash happens to be 1 (finding {x_i} such that 
sum(x_i * 31^(n-i)) = 1 gives the byte arrays which collide, it’s easy to 
construct examples and they do occur in reality)



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