lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rm...@apache.org
Subject svn commit: r1666528 - in /lucene/dev/trunk/lucene/queries/src: java/org/apache/lucene/queries/TermsQuery.java test/org/apache/lucene/queries/TermsQueryTest.java
Date Fri, 13 Mar 2015 17:56:35 GMT
Author: rmuir
Date: Fri Mar 13 17:56:34 2015
New Revision: 1666528

URL: http://svn.apache.org/r1666528
Log:
LUCENE-6333: fix hashcode impl for TermsQuery

Modified:
    lucene/dev/trunk/lucene/queries/src/java/org/apache/lucene/queries/TermsQuery.java
    lucene/dev/trunk/lucene/queries/src/test/org/apache/lucene/queries/TermsQueryTest.java

Modified: lucene/dev/trunk/lucene/queries/src/java/org/apache/lucene/queries/TermsQuery.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/queries/src/java/org/apache/lucene/queries/TermsQuery.java?rev=1666528&r1=1666527&r2=1666528&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/queries/src/java/org/apache/lucene/queries/TermsQuery.java (original)
+++ lucene/dev/trunk/lucene/queries/src/java/org/apache/lucene/queries/TermsQuery.java Fri
Mar 13 17:56:34 2015
@@ -209,6 +209,11 @@ public class TermsQuery extends Query im
   }
 
   @Override
+  public int hashCode() {
+      return super.hashCode() ^ this.hashCode;
+  }
+
+  @Override
   public String toString(String defaultField) {
     StringBuilder builder = new StringBuilder();
     BytesRef spare = new BytesRef(termsBytes);

Modified: lucene/dev/trunk/lucene/queries/src/test/org/apache/lucene/queries/TermsQueryTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/queries/src/test/org/apache/lucene/queries/TermsQueryTest.java?rev=1666528&r1=1666527&r2=1666528&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/queries/src/test/org/apache/lucene/queries/TermsQueryTest.java
(original)
+++ lucene/dev/trunk/lucene/queries/src/test/org/apache/lucene/queries/TermsQueryTest.java
Fri Mar 13 17:56:34 2015
@@ -166,6 +166,15 @@ public class TermsQueryTest extends Luce
         assertFalse(right.equals(notEqual));
       }
     }
+
+    TermsQuery tq1 = new TermsQuery(new Term("thing", "apple"));
+    TermsQuery tq2 = new TermsQuery(new Term("thing", "orange"));
+    assertFalse(tq1.hashCode() == tq2.hashCode());
+
+    // different fields with the same term should have differing hashcodes
+    tq1 = new TermsQuery(new Term("thing1", "apple"));
+    tq2 = new TermsQuery(new Term("thing2", "apple"));
+    assertFalse(tq1.hashCode() == tq2.hashCode());
   }
 
   public void testSingleFieldEquals() {



Mime
View raw message