lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kris...@apache.org
Subject [07/35] lucene-solr:jira/solr-8593: LUCENE-7660: LatLonPointDistanceQuery could skip distance computations more often.
Date Wed, 01 Feb 2017 17:00:35 GMT
LUCENE-7660: LatLonPointDistanceQuery could skip distance computations more often.


Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/076662d1
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/076662d1
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/076662d1

Branch: refs/heads/jira/solr-8593
Commit: 076662d1b23414b94e332206dd7ff73e8d9f9d0b
Parents: 74240be
Author: Adrien Grand <jpountz@gmail.com>
Authored: Mon Jan 30 09:47:51 2017 +0100
Committer: Adrien Grand <jpountz@gmail.com>
Committed: Mon Jan 30 09:47:51 2017 +0100

----------------------------------------------------------------------
 lucene/CHANGES.txt                                     |  4 ++++
 .../core/src/java/org/apache/lucene/geo/GeoUtils.java  | 13 ++++++++++++-
 .../src/test/org/apache/lucene/geo/TestGeoUtils.java   | 12 ++++++++++++
 3 files changed, 28 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/076662d1/lucene/CHANGES.txt
----------------------------------------------------------------------
diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txt
index 0be102c..6a0d17d 100644
--- a/lucene/CHANGES.txt
+++ b/lucene/CHANGES.txt
@@ -131,6 +131,10 @@ Optimizations
 * LUCENE-7661: Speed up for LatLonPointInPolygonQuery by pre-computing the
   relation of the polygon with a grid. (Adrien Grand)
 
+* LUCENE-7660: Speed up LatLonPointDistanceQuery by improving the detection of
+  whether BKD cells are entirely within the distance close to the dateline.
+  (Adrien Grand)
+
 Build
 
 * LUCENE-7651: Fix Javadocs build for Java 8u121 by injecting "Google Code

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/076662d1/lucene/core/src/java/org/apache/lucene/geo/GeoUtils.java
----------------------------------------------------------------------
diff --git a/lucene/core/src/java/org/apache/lucene/geo/GeoUtils.java b/lucene/core/src/java/org/apache/lucene/geo/GeoUtils.java
index defcb48..aaca549 100644
--- a/lucene/core/src/java/org/apache/lucene/geo/GeoUtils.java
+++ b/lucene/core/src/java/org/apache/lucene/geo/GeoUtils.java
@@ -152,7 +152,7 @@ public final class GeoUtils {
       }
     }
 
-    if (maxLon - lon < 90 && lon - minLon < 90 &&
+    if (within90LonDegrees(lon, minLon, maxLon) &&
         SloppyMath.haversinSortKey(lat, lon, minLat, minLon) <= distanceSortKey &&
         SloppyMath.haversinSortKey(lat, lon, minLat, maxLon) <= distanceSortKey &&
         SloppyMath.haversinSortKey(lat, lon, maxLat, minLon) <= distanceSortKey &&
@@ -163,4 +163,15 @@ public final class GeoUtils {
 
     return Relation.CELL_CROSSES_QUERY;
   }
+
+  /** Return whether all points of {@code [minLon,maxLon]} are within 90 degrees of {@code
lon}. */
+  static boolean within90LonDegrees(double lon, double minLon, double maxLon) {
+    if (maxLon <= lon - 180) {
+      lon -= 360;
+    } else if (minLon >= lon + 180) {
+      lon += 360;
+    }
+    return maxLon - lon < 90 && lon - minLon < 90;
+  }
+
 }

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/076662d1/lucene/core/src/test/org/apache/lucene/geo/TestGeoUtils.java
----------------------------------------------------------------------
diff --git a/lucene/core/src/test/org/apache/lucene/geo/TestGeoUtils.java b/lucene/core/src/test/org/apache/lucene/geo/TestGeoUtils.java
index 2cfb2f8..3d95a6d 100644
--- a/lucene/core/src/test/org/apache/lucene/geo/TestGeoUtils.java
+++ b/lucene/core/src/test/org/apache/lucene/geo/TestGeoUtils.java
@@ -293,4 +293,16 @@ public class TestGeoUtils extends LuceneTestCase {
 
     return false;
   }
+
+  public void testWithin90LonDegrees() {
+    assertTrue(GeoUtils.within90LonDegrees(0, -80, 80));
+    assertFalse(GeoUtils.within90LonDegrees(0, -100, 80));
+    assertFalse(GeoUtils.within90LonDegrees(0, -80, 100));
+
+    assertTrue(GeoUtils.within90LonDegrees(-150, 140, 170));
+    assertFalse(GeoUtils.within90LonDegrees(-150, 120, 150));
+
+    assertTrue(GeoUtils.within90LonDegrees(150, -170, -140));
+    assertFalse(GeoUtils.within90LonDegrees(150, -150, -120));
+  }
 }


Mime
View raw message