lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rm...@apache.org
Subject svn commit: r1451525 - in /lucene/dev/trunk/lucene/core/src: java/org/apache/lucene/search/ test/org/apache/lucene/search/
Date Fri, 01 Mar 2013 08:43:16 GMT
Author: rmuir
Date: Fri Mar  1 08:43:15 2013
New Revision: 1451525

URL: http://svn.apache.org/r1451525
Log:
add missing hashcode/equals to these rewrite methods

Modified:
    lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/search/DocTermOrdsRewriteMethod.java
    lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/search/FieldCacheRewriteMethod.java
    lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/search/TestDocTermOrdsRewriteMethod.java
    lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/search/TestFieldCacheRewriteMethod.java

Modified: lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/search/DocTermOrdsRewriteMethod.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/search/DocTermOrdsRewriteMethod.java?rev=1451525&r1=1451524&r2=1451525&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/search/DocTermOrdsRewriteMethod.java
(original)
+++ lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/search/DocTermOrdsRewriteMethod.java
Fri Mar  1 08:43:15 2013
@@ -163,4 +163,20 @@ public final class DocTermOrdsRewriteMet
       };
     }
   }
+
+  @Override
+  public boolean equals(Object obj) {
+    if (this == obj)
+      return true;
+    if (obj == null)
+      return false;
+    if (getClass() != obj.getClass())
+      return false;
+    return true;
+  }
+
+  @Override
+  public int hashCode() {
+    return 877;
+  }
 }

Modified: lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/search/FieldCacheRewriteMethod.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/search/FieldCacheRewriteMethod.java?rev=1451525&r1=1451524&r2=1451525&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/search/FieldCacheRewriteMethod.java
(original)
+++ lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/search/FieldCacheRewriteMethod.java
Fri Mar  1 08:43:15 2013
@@ -162,4 +162,20 @@ public final class FieldCacheRewriteMeth
       };
     }
   }
+  
+  @Override
+  public boolean equals(Object obj) {
+    if (this == obj)
+      return true;
+    if (obj == null)
+      return false;
+    if (getClass() != obj.getClass())
+      return false;
+    return true;
+  }
+
+  @Override
+  public int hashCode() {
+    return 641;
+  }
 }

Modified: lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/search/TestDocTermOrdsRewriteMethod.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/search/TestDocTermOrdsRewriteMethod.java?rev=1451525&r1=1451524&r2=1451525&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/search/TestDocTermOrdsRewriteMethod.java
(original)
+++ lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/search/TestDocTermOrdsRewriteMethod.java
Fri Mar  1 08:43:15 2013
@@ -126,4 +126,19 @@ public class TestDocTermOrdsRewriteMetho
 
     CheckHits.checkEqual(inverted, invertedDocs.scoreDocs, docValuesDocs.scoreDocs);
   }
+  
+  public void testEquals() throws Exception {
+    RegexpQuery a1 = new RegexpQuery(new Term(fieldName, "[aA]"), RegExp.NONE);
+    RegexpQuery a2 = new RegexpQuery(new Term(fieldName, "[aA]"), RegExp.NONE);
+    RegexpQuery b = new RegexpQuery(new Term(fieldName, "[bB]"), RegExp.NONE);
+    assertEquals(a1, a2);
+    assertFalse(a1.equals(b));
+    
+    a1.setRewriteMethod(new DocTermOrdsRewriteMethod());
+    a2.setRewriteMethod(new DocTermOrdsRewriteMethod());
+    b.setRewriteMethod(new DocTermOrdsRewriteMethod());
+    assertEquals(a1, a2);
+    assertFalse(a1.equals(b));
+    QueryUtils.check(a1);
+  }
 }

Modified: lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/search/TestFieldCacheRewriteMethod.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/search/TestFieldCacheRewriteMethod.java?rev=1451525&r1=1451524&r2=1451525&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/search/TestFieldCacheRewriteMethod.java
(original)
+++ lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/search/TestFieldCacheRewriteMethod.java
Fri Mar  1 08:43:15 2013
@@ -41,4 +41,19 @@ public class TestFieldCacheRewriteMethod
 
     CheckHits.checkEqual(fieldCache, fieldCacheDocs.scoreDocs, filterDocs.scoreDocs);
   }
+  
+  public void testEquals() throws Exception {
+    RegexpQuery a1 = new RegexpQuery(new Term(fieldName, "[aA]"), RegExp.NONE);
+    RegexpQuery a2 = new RegexpQuery(new Term(fieldName, "[aA]"), RegExp.NONE);
+    RegexpQuery b = new RegexpQuery(new Term(fieldName, "[bB]"), RegExp.NONE);
+    assertEquals(a1, a2);
+    assertFalse(a1.equals(b));
+    
+    a1.setRewriteMethod(new FieldCacheRewriteMethod());
+    a2.setRewriteMethod(new FieldCacheRewriteMethod());
+    b.setRewriteMethod(new FieldCacheRewriteMethod());
+    assertEquals(a1, a2);
+    assertFalse(a1.equals(b));
+    QueryUtils.check(a1);
+  }
 }



Mime
View raw message