drempapis commented on code in PR #15961:
URL: https://github.com/apache/lucene/pull/15961#discussion_r3086186672
##########
lucene/core/src/java/org/apache/lucene/util/automaton/CompiledAutomaton.java:
##########
@@ -509,8 +509,7 @@ public TransitionAccessor getTransitionAccessor() {
public int hashCode() {
final int prime = 31;
int result = 1;
- result = prime * result + ((runAutomaton == null) ? 0 :
runAutomaton.hashCode());
- result = prime * result + ((nfaRunAutomaton == null) ? 0 :
nfaRunAutomaton.hashCode());
+ result = prime * result + normalAutomatonHashCode();
Review Comment:
Without that change I am getting errors of the like
```
java.lang.AssertionError: expected:
org.apache.lucene.queries.intervals.IntervalQuery<f:MultiTerm(*.txt)> but was:
org.apache.lucene.queries.intervals.IntervalQuery<f:MultiTerm(*.txt)>
at
__randomizedtesting.SeedInfo.seed([CA4FA9AC9103B4C8:8C2346BE162DAD34]:0)
at [email protected]/org.junit.Assert.fail(Assert.java:89)
at [email protected]/org.junit.Assert.failNotEquals(Assert.java:835)
at [email protected]/org.junit.Assert.assertEquals(Assert.java:120)
at [email protected]/org.junit.Assert.assertEquals(Assert.java:146)
at
org.apache.lucene.queries.intervals.TestIntervalQuery.testEquality(TestIntervalQuery.java:485)
```
in tests
```
- org.apache.lucene.queries.intervals.TestIntervalQuery.testEquality
(:lucene:queries)
- org.apache.lucene.queries.intervals.TestIntervals.testEquality
(:lucene:queries)
- org.apache.lucene.search.TestWildcardQuery.testEquals (:lucene:core)
```
`CompiledAutomaton.equals()` was updated so two NFA-backed `NORMAL` automata
are considered equal when their automaton graphs are the same, even if they are
different Java objects. That means `hashCode()` also had to change.
Previously, NFA hash code came from `nfaRunAutomaton.hashCode()`. So two
objects that are now `equals()` could still produce different hash codes, which
breaks the Java equals/hashCode contract.
The current update keeps existing DFA behavior (`runAutomaton.hashCode()`),
and for NFA computes a structural hash from the underlying automaton graph
using `AutomatonStructuralComparator.structuralAutomatonHashCode()`
--
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]