You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by dw...@apache.org on 2016/05/24 19:25:48 UTC
[2/2] lucene-solr:branch_6x: LUCENE-7295: TermAutomatonQuery.hashCode
calculates Automaton.toDot().hash.
LUCENE-7295: TermAutomatonQuery.hashCode calculates Automaton.toDot().hash.
Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/c367f517
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/c367f517
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/c367f517
Branch: refs/heads/branch_6x
Commit: c367f51793e02220dc9f276aaa1b26c6434aa254
Parents: abba6d9
Author: Dawid Weiss <dw...@apache.org>
Authored: Tue May 24 21:25:05 2016 +0200
Committer: Dawid Weiss <dw...@apache.org>
Committed: Tue May 24 21:25:41 2016 +0200
----------------------------------------------------------------------
lucene/CHANGES.txt | 3 +++
.../org/apache/lucene/search/TermAutomatonQuery.java | 13 +++++--------
2 files changed, 8 insertions(+), 8 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/c367f517/lucene/CHANGES.txt
----------------------------------------------------------------------
diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txt
index cd911b2..3ba5c08 100644
--- a/lucene/CHANGES.txt
+++ b/lucene/CHANGES.txt
@@ -129,6 +129,9 @@ Documentation
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,
Dawid Weiss)
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/c367f517/lucene/sandbox/src/java/org/apache/lucene/search/TermAutomatonQuery.java
----------------------------------------------------------------------
diff --git a/lucene/sandbox/src/java/org/apache/lucene/search/TermAutomatonQuery.java b/lucene/sandbox/src/java/org/apache/lucene/search/TermAutomatonQuery.java
index d0298c4..b3a7ba2 100644
--- a/lucene/sandbox/src/java/org/apache/lucene/search/TermAutomatonQuery.java
+++ b/lucene/sandbox/src/java/org/apache/lucene/search/TermAutomatonQuery.java
@@ -245,19 +245,18 @@ public class TermAutomatonQuery extends Query {
}
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) &&
checkFinished(other) &&
- termToID.equals(other.termToID) &&
- Operations.sameLanguage(det, other.det);
+ other == this;
}
@Override
public int hashCode() {
checkFinished(this);
- // TODO: LUCENE-7295: Automaton.toDot() is very costly!
- return classHash() ^ termToID.hashCode() + det.toDot().hashCode();
+ // LUCENE-7295: this used to be very awkward toDot() call; it is safer to assume
+ // 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.
@@ -328,7 +327,6 @@ public class TermAutomatonQuery extends Query {
}
final class TermAutomatonWeight extends Weight {
- private final IndexSearcher searcher;
final Automaton automaton;
private final Map<Integer,TermContext> termStates;
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 {
super(TermAutomatonQuery.this);
this.automaton = automaton;
- this.searcher = searcher;
this.termStates = termStates;
this.similarity = searcher.getSimilarity(true);
List<TermStatistics> allTermStats = new ArrayList<>();