You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by iv...@apache.org on 2019/08/26 07:37:09 UTC

[lucene-solr] branch branch_8x updated: LUCENE-8955: Move compare logic to IntersectVisitor in NearestNeighbor (#842)

This is an automated email from the ASF dual-hosted git repository.

ivera pushed a commit to branch branch_8x
in repository https://gitbox.apache.org/repos/asf/lucene-solr.git


The following commit(s) were added to refs/heads/branch_8x by this push:
     new d0ea612  LUCENE-8955: Move compare logic to IntersectVisitor in NearestNeighbor (#842)
d0ea612 is described below

commit d0ea612d4eafece77db76c12437978032fcd90e3
Author: Ignacio Vera <iv...@apache.org>
AuthorDate: Mon Aug 26 09:35:57 2019 +0200

    LUCENE-8955: Move compare logic to IntersectVisitor in NearestNeighbor (#842)
---
 lucene/CHANGES.txt                                      |  7 +++++--
 .../java/org/apache/lucene/search/NearestNeighbor.java  | 17 ++++++++++-------
 2 files changed, 15 insertions(+), 9 deletions(-)

diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txt
index 469400b..08ee234 100644
--- a/lucene/CHANGES.txt
+++ b/lucene/CHANGES.txt
@@ -34,8 +34,11 @@ Improvements
 
 * LUCENE-8894: Add APIs to find SPI names for Tokenizer/CharFilter/TokenFilter factory classes. (Tomoko Uchida)
 
-* LUCENE-8914: move the logic for discarding inner modes to the IntersectVisitor so we take advantage
-  of the change introduced in LUCENE-7862. (Ignacio Vera)
+* LUCENE-8914: move the logic for discarding inner modes in FloatPointNearestNeighbor to the IntersectVisitor
+  so we take advantage of the change introduced in LUCENE-7862. (Ignacio Vera)
+
+* LUCENE-8955: move the logic for discarding inner modes in LatLonPoint NearestNeighbor to the IntersectVisitor
+  so we take advantage of the change introduced in LUCENE-7862. (Ignacio Vera)
 
 * LUCENE-8918: PhraseQuery throws exceptions at construction time if it is passed
   null arguments. (Alan Woodward)
diff --git a/lucene/sandbox/src/java/org/apache/lucene/search/NearestNeighbor.java b/lucene/sandbox/src/java/org/apache/lucene/search/NearestNeighbor.java
index 86a0a15..50fc48e 100644
--- a/lucene/sandbox/src/java/org/apache/lucene/search/NearestNeighbor.java
+++ b/lucene/sandbox/src/java/org/apache/lucene/search/NearestNeighbor.java
@@ -182,6 +182,15 @@ class NearestNeighbor {
 
     @Override
     public Relation compare(byte[] minPackedValue, byte[] maxPackedValue) {
+      double cellMinLat = decodeLatitude(minPackedValue, 0);
+      double cellMinLon = decodeLongitude(minPackedValue, Integer.BYTES);
+      double cellMaxLat = decodeLatitude(maxPackedValue, 0);
+      double cellMaxLon = decodeLongitude(maxPackedValue, Integer.BYTES);
+
+      if (cellMaxLat < minLat || maxLat < cellMinLat || ((cellMaxLon < minLon || maxLon < cellMinLon) && cellMaxLon < minLon2)) {
+        // this cell is outside our search bbox; don't bother exploring any more
+        return Relation.CELL_OUTSIDE_QUERY;
+      }
       return Relation.CELL_CROSSES_QUERY;
     }
   }
@@ -266,13 +275,7 @@ class NearestNeighbor {
         //System.out.println("    non-leaf");
         // Non-leaf block: split into two cells and put them back into the queue:
 
-        double cellMinLat = decodeLatitude(cell.minPacked, 0);
-        double cellMinLon = decodeLongitude(cell.minPacked, Integer.BYTES);
-        double cellMaxLat = decodeLatitude(cell.maxPacked, 0);
-        double cellMaxLon = decodeLongitude(cell.maxPacked, Integer.BYTES);
-
-        if (cellMaxLat < visitor.minLat || visitor.maxLat < cellMinLat || ((cellMaxLon < visitor.minLon || visitor.maxLon < cellMinLon) && cellMaxLon < visitor.minLon2)) {
-          // this cell is outside our search bbox; don't bother exploring any more
+        if (visitor.compare(cell.minPacked, cell.maxPacked) == Relation.CELL_OUTSIDE_QUERY) {
           continue;
         }