lucene-solr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From yo...@apache.org
Subject svn commit: r881364 - in /lucene/solr/trunk/src/java/org/apache/solr/search/function/distance: GeohashFunction.java GeohashHaversineFunction.java HaversineFunction.java VectorDistanceFunction.java
Date Tue, 17 Nov 2009 16:45:22 GMT
Author: yonik
Date: Tue Nov 17 16:45:22 2009
New Revision: 881364

URL: http://svn.apache.org/viewvc?rev=881364&view=rev
Log:
add override annotations, fix geohash hashcode, simplify other hashcodes

Modified:
    lucene/solr/trunk/src/java/org/apache/solr/search/function/distance/GeohashFunction.java
    lucene/solr/trunk/src/java/org/apache/solr/search/function/distance/GeohashHaversineFunction.java
    lucene/solr/trunk/src/java/org/apache/solr/search/function/distance/HaversineFunction.java
    lucene/solr/trunk/src/java/org/apache/solr/search/function/distance/VectorDistanceFunction.java

Modified: lucene/solr/trunk/src/java/org/apache/solr/search/function/distance/GeohashFunction.java
URL: http://svn.apache.org/viewvc/lucene/solr/trunk/src/java/org/apache/solr/search/function/distance/GeohashFunction.java?rev=881364&r1=881363&r2=881364&view=diff
==============================================================================
--- lucene/solr/trunk/src/java/org/apache/solr/search/function/distance/GeohashFunction.java
(original)
+++ lucene/solr/trunk/src/java/org/apache/solr/search/function/distance/GeohashFunction.java
Tue Nov 17 16:45:22 2009
@@ -85,11 +85,11 @@
   @Override
   public int hashCode() {
     int result = lat.hashCode();
-    result = 31 * result + lon.hashCode();
-    result = 31 * name().hashCode();
+    result = 29 * result - lon.hashCode();
     return result;
   }
 
+  @Override  
   public String description() {
     StringBuilder sb = new StringBuilder();
     sb.append(name()).append('(');

Modified: lucene/solr/trunk/src/java/org/apache/solr/search/function/distance/GeohashHaversineFunction.java
URL: http://svn.apache.org/viewvc/lucene/solr/trunk/src/java/org/apache/solr/search/function/distance/GeohashHaversineFunction.java?rev=881364&r1=881363&r2=881364&view=diff
==============================================================================
--- lucene/solr/trunk/src/java/org/apache/solr/search/function/distance/GeohashHaversineFunction.java
(original)
+++ lucene/solr/trunk/src/java/org/apache/solr/search/function/distance/GeohashHaversineFunction.java
Tue Nov 17 16:45:22 2009
@@ -108,6 +108,7 @@
     geoHash2.createWeight(context, searcher);
   }
 
+  @Override
   public boolean equals(Object o) {
     if (this.getClass() != o.getClass()) return false;
     GeohashHaversineFunction other = (GeohashHaversineFunction) o;
@@ -120,15 +121,15 @@
   @Override
   public int hashCode() {
     int result;
-    long temp;
     result = geoHash1.hashCode();
     result = 31 * result + geoHash2.hashCode();
     result = 31 * result + name().hashCode();
-    temp = radius != +0.0d ? Double.doubleToLongBits(radius) : 0L;
+    long temp =Double.doubleToRawLongBits(radius);
     result = 31 * result + (int) (temp ^ (temp >>> 32));
     return result;
   }
 
+  @Override
   public String description() {
     StringBuilder sb = new StringBuilder();
     sb.append(name()).append('(');

Modified: lucene/solr/trunk/src/java/org/apache/solr/search/function/distance/HaversineFunction.java
URL: http://svn.apache.org/viewvc/lucene/solr/trunk/src/java/org/apache/solr/search/function/distance/HaversineFunction.java?rev=881364&r1=881363&r2=881364&view=diff
==============================================================================
--- lucene/solr/trunk/src/java/org/apache/solr/search/function/distance/HaversineFunction.java
(original)
+++ lucene/solr/trunk/src/java/org/apache/solr/search/function/distance/HaversineFunction.java
Tue Nov 17 16:45:22 2009
@@ -126,6 +126,7 @@
     y2.createWeight(context, searcher);
   }
 
+  @Override
   public boolean equals(Object o) {
     if (this.getClass() != o.getClass()) return false;
     HaversineFunction other = (HaversineFunction) o;
@@ -145,7 +146,7 @@
     result = 31 * result + x2.hashCode();
     result = 31 * result + y2.hashCode();
     result = 31 * result + name().hashCode();
-    temp = radius != +0.0d ? Double.doubleToLongBits(radius) : 0L;
+    temp = Double.doubleToRawLongBits(radius);
     result = 31 * result + (int) (temp ^ (temp >>> 32));
     return result;
   }

Modified: lucene/solr/trunk/src/java/org/apache/solr/search/function/distance/VectorDistanceFunction.java
URL: http://svn.apache.org/viewvc/lucene/solr/trunk/src/java/org/apache/solr/search/function/distance/VectorDistanceFunction.java?rev=881364&r1=881363&r2=881364&view=diff
==============================================================================
--- lucene/solr/trunk/src/java/org/apache/solr/search/function/distance/VectorDistanceFunction.java
(original)
+++ lucene/solr/trunk/src/java/org/apache/solr/search/function/distance/VectorDistanceFunction.java
Tue Nov 17 16:45:22 2009
@@ -57,7 +57,7 @@
 
   protected String name() {
     return "dist";
-  };
+  }
 
   /**
    * Calculate the distance
@@ -129,7 +129,7 @@
       }
 
       public double doubleVal(int doc) {
-        return (double) distance(doc, valsArr1, valsArr2);
+        return distance(doc, valsArr1, valsArr2);
       }
 
       public String strVal(int doc) {
@@ -187,10 +187,11 @@
   public int hashCode() {
     int result = sources1.hashCode();
     result = 31 * result + sources2.hashCode();
-    result = 31 * result + (power != +0.0f ? Float.floatToIntBits(power) : 0);
+    result = 31 * result + Float.floatToRawIntBits(power);
     return result;
   }
 
+  @Override
   public String description() {
     StringBuilder sb = new StringBuilder();
     sb.append(name()).append('(').append(power).append(',');



Mime
View raw message