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 2020/12/14 11:16:11 UTC

[lucene-solr] branch master updated: LUCENE-9552: make sure we don't construct Illegal rectangles due to quantization (#2131)

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

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


The following commit(s) were added to refs/heads/master by this push:
     new bc854b2  LUCENE-9552: make sure we don't construct Illegal rectangles due to quantization (#2131)
bc854b2 is described below

commit bc854b262769a128d3b710813087c65c71b3916a
Author: Ignacio Vera <iv...@apache.org>
AuthorDate: Mon Dec 14 12:15:54 2020 +0100

    LUCENE-9552: make sure we don't construct Illegal rectangles due to quantization (#2131)
---
 .../LatLonDocValuesPointInGeometryQuery.java       | 24 ++++++++++++++++++----
 .../document/LatLonPointInGeometryQuery.java       | 16 ++++++++++++++-
 2 files changed, 35 insertions(+), 5 deletions(-)

diff --git a/lucene/core/src/java/org/apache/lucene/document/LatLonDocValuesPointInGeometryQuery.java b/lucene/core/src/java/org/apache/lucene/document/LatLonDocValuesPointInGeometryQuery.java
index 3d6f25b..04cb612 100644
--- a/lucene/core/src/java/org/apache/lucene/document/LatLonDocValuesPointInGeometryQuery.java
+++ b/lucene/core/src/java/org/apache/lucene/document/LatLonDocValuesPointInGeometryQuery.java
@@ -104,12 +104,28 @@ public class LatLonDocValuesPointInGeometryQuery extends Query {
 
   @Override
   public Weight createWeight(IndexSearcher searcher, ScoreMode scoreMode, float boost) throws IOException {
+    final Component2D tree = LatLonGeometry.create(geometries);
+
+    if (tree.getMinY() > tree.getMaxY()) {
+      // encodeLatitudeCeil may cause minY to be > maxY iff
+      // the delta between the longitude < the encoding resolution
+      return new ConstantScoreWeight(this, boost) {
+        @Override
+        public Scorer scorer(LeafReaderContext context) {
+          return null;
+        }
 
-    return new ConstantScoreWeight(this, boost) {
-
-      final Component2D tree = LatLonGeometry.create(geometries);
-      final GeoEncodingUtils.Component2DPredicate component2DPredicate = GeoEncodingUtils.createComponentPredicate(tree);
+        @Override
+        public boolean isCacheable(LeafReaderContext ctx) {
+          return false;
+        }
+      };
+    }
 
+    final GeoEncodingUtils.Component2DPredicate component2DPredicate = GeoEncodingUtils.createComponentPredicate(tree);
+    
+    return new ConstantScoreWeight(this, boost) {
+      
       @Override
       public Scorer scorer(LeafReaderContext context) throws IOException {
         final SortedNumericDocValues values = context.reader().getSortedNumericDocValues(field);
diff --git a/lucene/core/src/java/org/apache/lucene/document/LatLonPointInGeometryQuery.java b/lucene/core/src/java/org/apache/lucene/document/LatLonPointInGeometryQuery.java
index adeba14..2d749cc 100644
--- a/lucene/core/src/java/org/apache/lucene/document/LatLonPointInGeometryQuery.java
+++ b/lucene/core/src/java/org/apache/lucene/document/LatLonPointInGeometryQuery.java
@@ -142,8 +142,22 @@ final class LatLonPointInGeometryQuery extends Query {
 
   @Override
   public Weight createWeight(IndexSearcher searcher, ScoreMode scoreMode, float boost) throws IOException {
-
     final Component2D tree = LatLonGeometry.create(geometries);
+    if (tree.getMinY() > tree.getMaxY()) {
+      // encodeLatitudeCeil may cause minY to be > maxY iff
+      // the delta between the longitude < the encoding resolution
+      return new ConstantScoreWeight(this, boost) {
+        @Override
+        public Scorer scorer(LeafReaderContext context) {
+          return null;
+        }
+
+        @Override
+        public boolean isCacheable(LeafReaderContext ctx) {
+          return false;
+        }
+      };
+    }
     final GeoEncodingUtils.Component2DPredicate component2DPredicate = GeoEncodingUtils.createComponentPredicate(tree);
     // bounding box over all geometries, this can speed up tree intersection/cheaply improve approximation for complex multi-geometries
     final byte minLat[] = new byte[Integer.BYTES];