mirror of https://github.com/apache/lucene.git
LUCENE-7295: TermAutomatonQuery.hashCode calculates Automaton.toDot().hash.
This commit is contained in:
parent
dfa3d6c9d9
commit
6e8ca1a094
|
@ -136,6 +136,9 @@ Documentation
|
||||||
|
|
||||||
Other
|
Other
|
||||||
|
|
||||||
|
* LUCENE-7295: TermAutomatonQuery.hashCode calculates Automaton.toDot().hash,
|
||||||
|
equivalence relationship replaced with object identity. (Dawid Weiss)
|
||||||
|
|
||||||
* LUCENE-7277: Make Query.hashCode and Query.equals abstract. (Paul Elschot,
|
* LUCENE-7277: Make Query.hashCode and Query.equals abstract. (Paul Elschot,
|
||||||
Dawid Weiss)
|
Dawid Weiss)
|
||||||
|
|
||||||
|
|
|
@ -245,19 +245,18 @@ public class TermAutomatonQuery extends Query {
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean equalsTo(TermAutomatonQuery other) {
|
private boolean equalsTo(TermAutomatonQuery other) {
|
||||||
// NOTE: not quite correct, because if terms were added in different
|
|
||||||
// order in each query but the language is the same, we return false:
|
|
||||||
return checkFinished(this) &&
|
return checkFinished(this) &&
|
||||||
checkFinished(other) &&
|
checkFinished(other) &&
|
||||||
termToID.equals(other.termToID) &&
|
other == this;
|
||||||
Operations.sameLanguage(det, other.det);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
checkFinished(this);
|
checkFinished(this);
|
||||||
// TODO: LUCENE-7295: Automaton.toDot() is very costly!
|
// LUCENE-7295: this used to be very awkward toDot() call; it is safer to assume
|
||||||
return classHash() ^ termToID.hashCode() + det.toDot().hashCode();
|
// that no two instances are equivalent instead (until somebody finds a better way to check
|
||||||
|
// on automaton equivalence quickly).
|
||||||
|
return System.identityHashCode(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns the dot (graphviz) representation of this automaton.
|
/** Returns the dot (graphviz) representation of this automaton.
|
||||||
|
@ -328,7 +327,6 @@ public class TermAutomatonQuery extends Query {
|
||||||
}
|
}
|
||||||
|
|
||||||
final class TermAutomatonWeight extends Weight {
|
final class TermAutomatonWeight extends Weight {
|
||||||
private final IndexSearcher searcher;
|
|
||||||
final Automaton automaton;
|
final Automaton automaton;
|
||||||
private final Map<Integer,TermContext> termStates;
|
private final Map<Integer,TermContext> termStates;
|
||||||
private final Similarity.SimWeight stats;
|
private final Similarity.SimWeight stats;
|
||||||
|
@ -337,7 +335,6 @@ public class TermAutomatonQuery extends Query {
|
||||||
public TermAutomatonWeight(Automaton automaton, IndexSearcher searcher, Map<Integer,TermContext> termStates) throws IOException {
|
public TermAutomatonWeight(Automaton automaton, IndexSearcher searcher, Map<Integer,TermContext> termStates) throws IOException {
|
||||||
super(TermAutomatonQuery.this);
|
super(TermAutomatonQuery.this);
|
||||||
this.automaton = automaton;
|
this.automaton = automaton;
|
||||||
this.searcher = searcher;
|
|
||||||
this.termStates = termStates;
|
this.termStates = termStates;
|
||||||
this.similarity = searcher.getSimilarity(true);
|
this.similarity = searcher.getSimilarity(true);
|
||||||
List<TermStatistics> allTermStats = new ArrayList<>();
|
List<TermStatistics> allTermStats = new ArrayList<>();
|
||||||
|
|
Loading…
Reference in New Issue