rafalh commented on code in PR #12354:
URL: https://github.com/apache/lucene/pull/12354#discussion_r2534212883
##########
lucene/core/src/java/org/apache/lucene/search/TermQuery.java:
##########
@@ -264,11 +264,25 @@ public TermStates getTermStates() {
/** Returns true iff <code>other</code> is equal to <code>this</code>. */
@Override
public boolean equals(Object other) {
- return sameClassAs(other) && term.equals(((TermQuery) other).term);
+ if (!sameClassAs(other)) {
+ return false;
+ }
+ TermQuery otherTermQuery = (TermQuery) other;
+ if (!term.equals(otherTermQuery.term)) {
+ return false;
+ }
+ if (perReaderTermState != null && otherTermQuery.perReaderTermState !=
null) {
+ return perReaderTermState.docFreq() ==
otherTermQuery.perReaderTermState.docFreq();
+ }
+ return perReaderTermState == null && otherTermQuery.perReaderTermState ==
null;
}
@Override
public int hashCode() {
- return classHash() ^ term.hashCode();
+ int hash = classHash() ^ term.hashCode();
+ if (perReaderTermState != null) {
+ hash ^= Integer.hashCode(perReaderTermState.docFreq());
Review Comment:
Done, but I'm not sure if calculating hash code from just one field is okay
--
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]