lucene-java-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From uschind...@apache.org
Subject svn commit: r791263 - in /lucene/java/trunk/src/java/org/apache/lucene/search: NumericRangeQuery.java TermRangeFilter.java TermRangeQuery.java TermRangeTermEnum.java
Date Sun, 05 Jul 2009 16:01:52 GMT
Author: uschindler
Date: Sun Jul  5 16:01:52 2009
New Revision: 791263

URL: http://svn.apache.org/viewvc?rev=791263&view=rev
Log:
LUCENE-1713, LUCENE-1673: For completeness, add some getter methods to TermRangeFilter, to
be similar like TermRangeQuery and NumericRangeFilter.
This also unifies the hashCode and equals methods in this family of queries. It also fixes
a bug in hashCode and equals of NumericRangeQuery, missing the constantScoreRewrite property.
TermRangeTermEnum was changed to have a consistent ctor with TermRangeQuery.

Modified:
    lucene/java/trunk/src/java/org/apache/lucene/search/NumericRangeQuery.java
    lucene/java/trunk/src/java/org/apache/lucene/search/TermRangeFilter.java
    lucene/java/trunk/src/java/org/apache/lucene/search/TermRangeQuery.java
    lucene/java/trunk/src/java/org/apache/lucene/search/TermRangeTermEnum.java

Modified: lucene/java/trunk/src/java/org/apache/lucene/search/NumericRangeQuery.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/search/NumericRangeQuery.java?rev=791263&r1=791262&r2=791263&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/search/NumericRangeQuery.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/search/NumericRangeQuery.java Sun Jul  5
16:01:52 2009
@@ -227,7 +227,8 @@
   //@Override
   public final boolean equals(final Object o) {
     if (o==this) return true;
-    if (o==null) return false;
+    if (!super.equals(o))
+      return false;
     if (o instanceof NumericRangeQuery) {
       final NumericRangeQuery q=(NumericRangeQuery)o;
       return (
@@ -236,8 +237,7 @@
         (q.max == null ? max == null : q.max.equals(max)) &&
         minInclusive == q.minInclusive &&
         maxInclusive == q.maxInclusive &&
-        precisionStep == q.precisionStep &&
-        getBoost() == q.getBoost()
+        precisionStep == q.precisionStep
       );
     }
     return false;
@@ -245,11 +245,11 @@
 
   //@Override
   public final int hashCode() {
-    int hash = Float.floatToIntBits(getBoost()) ^ field.hashCode();
-    hash += precisionStep^0x64365465;
+    int hash = super.hashCode();
+    hash += field.hashCode()^0x4565fd66 + precisionStep^0x64365465;
     if (min != null) hash += min.hashCode()^0x14fa55fb;
     if (max != null) hash += max.hashCode()^0x733fa5fe;
-    return hash+
+    return hash +
       (Boolean.valueOf(minInclusive).hashCode()^0x14fa55fb)+
       (Boolean.valueOf(maxInclusive).hashCode()^0x733fa5fe);
   }

Modified: lucene/java/trunk/src/java/org/apache/lucene/search/TermRangeFilter.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/search/TermRangeFilter.java?rev=791263&r1=791262&r2=791263&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/search/TermRangeFilter.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/search/TermRangeFilter.java Sun Jul  5 16:01:52
2009
@@ -85,4 +85,22 @@
   public static TermRangeFilter More(String fieldName, String lowerTerm) {
       return new TermRangeFilter(fieldName, lowerTerm, null, true, false);
   }
+
+  /** Returns the field name for this filter */
+  public String getField() { return ((TermRangeQuery) query).getField(); }
+  
+  /** Returns the lower value of this range filter */
+  public String getLowerTerm() { return ((TermRangeQuery) query).getLowerTerm(); }
+
+  /** Returns the upper value of this range filter */
+  public String getUpperTerm() { return ((TermRangeQuery) query).getUpperTerm(); }
+  
+  /** Returns <code>true</code> if the lower endpoint is inclusive */
+  public boolean includesLower() { return ((TermRangeQuery) query).includesLower(); }
+  
+  /** Returns <code>true</code> if the upper endpoint is inclusive */
+  public boolean includesUpper() { return ((TermRangeQuery) query).includesUpper(); }
+
+  /** Returns the collator used to determine range inclusion, if any. */
+  public Collator getCollator() { return ((TermRangeQuery) query).getCollator(); }
 }

Modified: lucene/java/trunk/src/java/org/apache/lucene/search/TermRangeQuery.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/search/TermRangeQuery.java?rev=791263&r1=791262&r2=791263&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/search/TermRangeQuery.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/search/TermRangeQuery.java Sun Jul  5 16:01:52
2009
@@ -113,9 +113,7 @@
   }
 
   /** Returns the field name for this query */
-  public String getField() {
-    return field;
-  }
+  public String getField() { return field; }
   
   /** Returns the lower value of this range query */
   public String getLowerTerm() { return lowerTerm; }
@@ -133,8 +131,8 @@
   public Collator getCollator() { return collator; }
   
   protected FilteredTermEnum getEnum(IndexReader reader) throws IOException {
-    return new TermRangeTermEnum(reader, collator, field, lowerTerm,
-        upperTerm, includeLower, includeUpper);
+    return new TermRangeTermEnum(reader, field, lowerTerm,
+        upperTerm, includeLower, includeUpper, collator);
   }
 
   /** Prints a user-readable version of this query. */

Modified: lucene/java/trunk/src/java/org/apache/lucene/search/TermRangeTermEnum.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/search/TermRangeTermEnum.java?rev=791263&r1=791262&r2=791263&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/search/TermRangeTermEnum.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/search/TermRangeTermEnum.java Sun Jul  5
16:01:52 2009
@@ -50,10 +50,6 @@
    * explicitly specifying the term to exclude.)
    * 
    * @param reader
-   * @param collator
-   *          The collator to use to collate index Terms, to determine their
-   *          membership in the range bounded by <code>lowerTerm</code> and
-   *          <code>upperTerm</code>.
    * @param field
    *          An interned field that holds both lower and upper terms.
    * @param lowerTermText
@@ -64,11 +60,15 @@
    *          If true, the <code>lowerTerm</code> is included in the range.
    * @param includeUpper
    *          If true, the <code>upperTerm</code> is included in the range.
+   * @param collator
+   *          The collator to use to collate index Terms, to determine their
+   *          membership in the range bounded by <code>lowerTerm</code> and
+   *          <code>upperTerm</code>.
    * 
    * @throws IOException
    */
-  public TermRangeTermEnum(IndexReader reader, Collator collator, String field,
-      String lowerTermText, String upperTermText, boolean includeLower, boolean includeUpper)
throws IOException {
+  public TermRangeTermEnum(IndexReader reader, String field, String lowerTermText, String
upperTermText, 
+    boolean includeLower, boolean includeUpper, Collator collator) throws IOException {
     this.collator = collator;
     this.upperTermText = upperTermText;
     this.lowerTermText = lowerTermText;



Mime
View raw message