squah-confluent commented on code in PR #19678: URL: https://github.com/apache/kafka/pull/19678#discussion_r2085136665
########## group-coordinator/src/main/java/org/apache/kafka/coordinator/group/assignor/RangeSet.java: ########## @@ -176,8 +178,18 @@ public boolean equals(Object o) { @Override public int hashCode() { - int result = from; - result = 31 * result + to; - return result; + // The hash code of a Set is defined as the sum of the hash codes of its elements. + // The hash code of an integer is the integer itself. + + // The sum of the integers from 1 to n is n * (n + 1) / 2. + // To get the sum of the integers from 1 + k to n + k, we can add n * k. + // So our hash code comes out to n * (from + to - 1) / 2. + long size = (long) to - (long) from; Review Comment: Thanks for the feedback. I'm not sure what will happen with very large ranges, so I'll forbid them in the constructor. -- 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: jira-unsubscr...@kafka.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org