You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by ds...@apache.org on 2017/06/05 16:45:43 UTC

lucene-solr:master: LUCENE-7845: spatial-extras undo optimize; don't consider any rect or circle to be a point

Repository: lucene-solr
Updated Branches:
  refs/heads/master 78d95014e -> 6b022c98f


LUCENE-7845: spatial-extras undo optimize; don't consider any rect or circle to be a point


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

Branch: refs/heads/master
Commit: 6b022c98f9a1f69de17445004ce8464ee936e51c
Parents: 78d9501
Author: David Smiley <ds...@apache.org>
Authored: Mon Jun 5 12:44:51 2017 -0400
Committer: David Smiley <ds...@apache.org>
Committed: Mon Jun 5 12:44:51 2017 -0400

----------------------------------------------------------------------
 .../lucene/spatial/prefix/PrefixTreeStrategy.java  | 17 ++++++-----------
 .../prefix/RecursivePrefixTreeStrategy.java        |  1 +
 .../prefix/RandomSpatialOpFuzzyPrefixTreeTest.java | 13 +++++++++++++
 3 files changed, 20 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/6b022c98/lucene/spatial-extras/src/java/org/apache/lucene/spatial/prefix/PrefixTreeStrategy.java
----------------------------------------------------------------------
diff --git a/lucene/spatial-extras/src/java/org/apache/lucene/spatial/prefix/PrefixTreeStrategy.java b/lucene/spatial-extras/src/java/org/apache/lucene/spatial/prefix/PrefixTreeStrategy.java
index 43851c7..0716e78 100644
--- a/lucene/spatial-extras/src/java/org/apache/lucene/spatial/prefix/PrefixTreeStrategy.java
+++ b/lucene/spatial-extras/src/java/org/apache/lucene/spatial/prefix/PrefixTreeStrategy.java
@@ -32,9 +32,7 @@ import org.apache.lucene.spatial.prefix.tree.SpatialPrefixTree;
 import org.apache.lucene.spatial.query.SpatialArgs;
 import org.apache.lucene.spatial.util.ShapeFieldCacheDistanceValueSource;
 import org.apache.lucene.util.Bits;
-import org.locationtech.spatial4j.shape.Circle;
 import org.locationtech.spatial4j.shape.Point;
-import org.locationtech.spatial4j.shape.Rectangle;
 import org.locationtech.spatial4j.shape.Shape;
 
 /**
@@ -208,15 +206,12 @@ public abstract class PrefixTreeStrategy extends SpatialStrategy {
     return HeatmapFacetCounter.calcFacets(this, context, topAcceptDocs, inputShape, facetLevel, maxCells);
   }
 
+  /**
+   * Returns true if the {@code shape} is a {@link Point}.  For custom spatial contexts, it may make sense to
+   * have certain other shapes return true.
+   * @lucene.experimental
+   */
   protected boolean isPointShape(Shape shape) {
-    if (shape instanceof Point) {
-      return true;
-    } else if (shape instanceof Circle) {
-      return ((Circle) shape).getRadius() == 0.0;
-    } else if (shape instanceof Rectangle) {
-      Rectangle rect = (Rectangle) shape;
-      return rect.getWidth() == 0.0 && rect.getHeight() == 0.0;
-    }
-    return false;
+    return shape instanceof Point;
   }
 }

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/6b022c98/lucene/spatial-extras/src/java/org/apache/lucene/spatial/prefix/RecursivePrefixTreeStrategy.java
----------------------------------------------------------------------
diff --git a/lucene/spatial-extras/src/java/org/apache/lucene/spatial/prefix/RecursivePrefixTreeStrategy.java b/lucene/spatial-extras/src/java/org/apache/lucene/spatial/prefix/RecursivePrefixTreeStrategy.java
index 7c79200..819c504 100644
--- a/lucene/spatial-extras/src/java/org/apache/lucene/spatial/prefix/RecursivePrefixTreeStrategy.java
+++ b/lucene/spatial-extras/src/java/org/apache/lucene/spatial/prefix/RecursivePrefixTreeStrategy.java
@@ -216,6 +216,7 @@ public class RecursivePrefixTreeStrategy extends PrefixTreeStrategy {
         cell = cellIterator.next();
         assert prevLevel < cell.getLevel();
       }
+      assert cell.isLeaf();
       return new TermQuery(new Term(getFieldName(), cell.getTokenBytesWithLeaf(null)));
     } else {
       // Well there could be parent cells. But we can reduce the "scan level" which will be slower for a point query.

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/6b022c98/lucene/spatial-extras/src/test/org/apache/lucene/spatial/prefix/RandomSpatialOpFuzzyPrefixTreeTest.java
----------------------------------------------------------------------
diff --git a/lucene/spatial-extras/src/test/org/apache/lucene/spatial/prefix/RandomSpatialOpFuzzyPrefixTreeTest.java b/lucene/spatial-extras/src/test/org/apache/lucene/spatial/prefix/RandomSpatialOpFuzzyPrefixTreeTest.java
index cfc9980..c5b145f 100644
--- a/lucene/spatial-extras/src/test/org/apache/lucene/spatial/prefix/RandomSpatialOpFuzzyPrefixTreeTest.java
+++ b/lucene/spatial-extras/src/test/org/apache/lucene/spatial/prefix/RandomSpatialOpFuzzyPrefixTreeTest.java
@@ -164,6 +164,19 @@ public class RandomSpatialOpFuzzyPrefixTreeTest extends StrategyTestCase {
     assertEquals(1, executeQuery(query, 1).numFound);
   }
 
+  @Test
+  public void testPointsOnlyOptBug() throws IOException {
+    setupQuadGrid(8, false);
+    setupCtx2D(ctx);
+    ((PrefixTreeStrategy) strategy).setPointsOnly(true);
+    Point point = ctx.makePoint(86, -127.44362190053255);
+    adoc("0", point);
+    commit();
+    Query query = strategy.makeQuery(new SpatialArgs(SpatialOperation.Intersects,
+        ctx.makeRectangle(point, point)));
+    assertEquals(1, executeQuery(query, 1).numFound);
+  }
+
   /** See LUCENE-5062, {@link ContainsPrefixTreeQuery#multiOverlappingIndexedShapes}. */
   @Test
   public void testContainsPairOverlap() throws IOException {