Skip to content

armgit / solr

Public Imported from GitHub
0

Apache Solr open-source search software

LUCENE-8955: Move compare logic to IntersectVisitor in NearestNeighbor (#842)

Ignacio Veraff1e2fa65837
diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txt
index 6ea7f94764b..779b1c2195d 100644
--- a/lucene/CHANGES.txt
+++ b/lucene/CHANGES.txt
@@ -88,8 +88,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 86a0a150107..50fc48eaa58 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;
}