aokolnychyi commented on code in PR #9245: URL: https://github.com/apache/iceberg/pull/9245#discussion_r1419845126
########## api/src/main/java/org/apache/iceberg/util/CharSequenceSet.java: ########## @@ -168,22 +167,29 @@ public void clear() { } @Override - public boolean equals(Object o) { - if (this == o) { + public boolean equals(Object other) { + if (this == other) { return true; + } else if (!(other instanceof Set)) { + return false; } - if (o == null || getClass() != o.getClass()) { + Set<?> that = (Set<?>) other; + + if (size() != that.size()) { return false; } - CharSequenceSet that = (CharSequenceSet) o; - return wrapperSet.equals(that.wrapperSet); + try { + return containsAll(that); + } catch (ClassCastException | NullPointerException unused) { + return false; + } } @Override public int hashCode() { - return Objects.hashCode(wrapperSet); + return wrapperSet.stream().mapToInt(CharSequenceWrapper::hashCode).sum(); Review Comment: The `Set` API requires the hash code to be a sum of hash codes of all elements. See `Set.hashCode()`. ########## api/src/main/java/org/apache/iceberg/util/CharSequenceSet.java: ########## @@ -168,22 +167,29 @@ public void clear() { } @Override - public boolean equals(Object o) { - if (this == o) { + public boolean equals(Object other) { Review Comment: See `Set$equals()` and `AbstractSet$equals()` for background. -- 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: issues-unsubscr...@iceberg.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org For additional commands, e-mail: issues-h...@iceberg.apache.org