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 2015/09/23 04:46:43 UTC

svn commit: r1704759 - in /lucene/dev/trunk: lucene/ lucene/licenses/ lucene/spatial/ lucene/spatial/src/java/org/apache/lucene/spatial/prefix/tree/ lucene/spatial/src/java/org/apache/lucene/spatial/spatial4j/ lucene/spatial/src/test/org/apache/lucene/...

Author: dsmiley
Date: Wed Sep 23 02:46:43 2015
New Revision: 1704759

URL: http://svn.apache.org/viewvc?rev=1704759&view=rev
Log:
LUCENE-6810: Spatial4j 0.5 upgrade. Mostly fixes a few edge-case bugs.
* the spatial4j tests jar is published and we use some utilities there; this adds a test dependency on it & SLF4J.

Added:
    lucene/dev/trunk/lucene/licenses/slf4j-api-1.7.7.jar.sha1
      - copied unchanged from r1704209, lucene/dev/trunk/solr/licenses/slf4j-api-1.7.7.jar.sha1
    lucene/dev/trunk/lucene/licenses/spatial4j-0.5-tests.jar.sha1   (with props)
    lucene/dev/trunk/lucene/licenses/spatial4j-0.5.jar.sha1   (with props)
    lucene/dev/trunk/solr/licenses/spatial4j-0.5.jar.sha1   (with props)
Removed:
    lucene/dev/trunk/lucene/licenses/spatial4j-0.4.1.jar.sha1
    lucene/dev/trunk/lucene/spatial/src/test/org/apache/lucene/spatial/spatial4j/LogRule.java
    lucene/dev/trunk/lucene/spatial/src/test/org/apache/lucene/spatial/spatial4j/RectIntersectionTestHelper.java
Modified:
    lucene/dev/trunk/lucene/CHANGES.txt
    lucene/dev/trunk/lucene/ivy-versions.properties
    lucene/dev/trunk/lucene/spatial/ivy.xml
    lucene/dev/trunk/lucene/spatial/src/java/org/apache/lucene/spatial/prefix/tree/NumberRangePrefixTree.java
    lucene/dev/trunk/lucene/spatial/src/java/org/apache/lucene/spatial/spatial4j/Geo3dShape.java
    lucene/dev/trunk/lucene/spatial/src/test/org/apache/lucene/spatial/bbox/TestBBoxStrategy.java
    lucene/dev/trunk/lucene/spatial/src/test/org/apache/lucene/spatial/prefix/RandomSpatialOpFuzzyPrefixTreeTest.java
    lucene/dev/trunk/lucene/spatial/src/test/org/apache/lucene/spatial/spatial4j/Geo3dShapeRectRelationTestCase.java

Modified: lucene/dev/trunk/lucene/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/CHANGES.txt?rev=1704759&r1=1704758&r2=1704759&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/CHANGES.txt (original)
+++ lucene/dev/trunk/lucene/CHANGES.txt Wed Sep 23 02:46:43 2015
@@ -150,6 +150,10 @@ Bug Fixes
   handling a tragic exception but another is still committing (Mike
   McCandless)
 
+* LUCENE-6810: Upgrade to Spatial4j 0.5 -- fixes some edge-case bugs in the
+  spatial module. See https://github.com/locationtech/spatial4j/blob/master/CHANGES.md
+  (David Smiley)
+
 Other
 
 * LUCENE-6812: Upgrade RandomizedTesting to 2.1.17. (Dawid Weiss)

Modified: lucene/dev/trunk/lucene/ivy-versions.properties
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/ivy-versions.properties?rev=1704759&r1=1704758&r2=1704759&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/ivy-versions.properties (original)
+++ lucene/dev/trunk/lucene/ivy-versions.properties Wed Sep 23 02:46:43 2015
@@ -41,7 +41,7 @@ com.google.inject.guice.version = 3.0
 /com.googlecode.mp4parser/isoparser = 1.0.2
 /com.ibm.icu/icu4j = 54.1
 /com.pff/java-libpst = 0.8.1
-/com.spatial4j/spatial4j = 0.4.1
+/com.spatial4j/spatial4j = 0.5
 
 com.sun.jersey.version = 1.9
 /com.sun.jersey.contribs/jersey-guice = ${com.sun.jersey.version}

Added: lucene/dev/trunk/lucene/licenses/spatial4j-0.5-tests.jar.sha1
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/licenses/spatial4j-0.5-tests.jar.sha1?rev=1704759&view=auto
==============================================================================
--- lucene/dev/trunk/lucene/licenses/spatial4j-0.5-tests.jar.sha1 (added)
+++ lucene/dev/trunk/lucene/licenses/spatial4j-0.5-tests.jar.sha1 Wed Sep 23 02:46:43 2015
@@ -0,0 +1 @@
+bdcdf20a723516a233b5bcc0ca7d4decaa88b6ed

Added: lucene/dev/trunk/lucene/licenses/spatial4j-0.5.jar.sha1
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/licenses/spatial4j-0.5.jar.sha1?rev=1704759&view=auto
==============================================================================
--- lucene/dev/trunk/lucene/licenses/spatial4j-0.5.jar.sha1 (added)
+++ lucene/dev/trunk/lucene/licenses/spatial4j-0.5.jar.sha1 Wed Sep 23 02:46:43 2015
@@ -0,0 +1 @@
+6e16edaf6b1ba76db7f08c2f3723fce3b358ecc3

Modified: lucene/dev/trunk/lucene/spatial/ivy.xml
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/spatial/ivy.xml?rev=1704759&r1=1704758&r2=1704759&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/spatial/ivy.xml (original)
+++ lucene/dev/trunk/lucene/spatial/ivy.xml Wed Sep 23 02:46:43 2015
@@ -16,13 +16,20 @@
    specific language governing permissions and limitations
    under the License.    
 -->
-<ivy-module version="2.0">
+<ivy-module version="2.0"  xmlns:maven="http://ant.apache.org/ivy/maven">
   <info organisation="org.apache.lucene" module="spatial"/>
-  <configurations defaultconfmapping="compile->master">
+  <configurations defaultconfmapping="compile->master;test->master">
     <conf name="compile" transitive="false"/>
+    <conf name="test" transitive="false"/>
   </configurations>
   <dependencies>
-    <dependency org="com.spatial4j" name="spatial4j" rev="${/com.spatial4j/spatial4j}" conf="compile"/>
-    <exclude org="*" ext="*" matcher="regexp" type="${ivy.exclude.types}"/> 
+    <dependency org="com.spatial4j" name="spatial4j" rev="${/com.spatial4j/spatial4j}" conf="compile">
+      <artifact name="spatial4j" ext="jar" />
+      <artifact name="spatial4j" type="test" ext="jar" maven:classifier="tests" />
+    </dependency>
+
+    <dependency org="org.slf4j" name="slf4j-api" rev="${/org.slf4j/slf4j-api}" conf="test"/>
+
+    <exclude org="*" ext="*" matcher="regexp" type="${ivy.exclude.types}"/>
   </dependencies>
 </ivy-module>

Modified: lucene/dev/trunk/lucene/spatial/src/java/org/apache/lucene/spatial/prefix/tree/NumberRangePrefixTree.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/spatial/src/java/org/apache/lucene/spatial/prefix/tree/NumberRangePrefixTree.java?rev=1704759&r1=1704758&r2=1704759&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/spatial/src/java/org/apache/lucene/spatial/prefix/tree/NumberRangePrefixTree.java (original)
+++ lucene/dev/trunk/lucene/spatial/src/java/org/apache/lucene/spatial/prefix/tree/NumberRangePrefixTree.java Wed Sep 23 02:46:43 2015
@@ -266,6 +266,11 @@ public abstract class NumberRangePrefixT
       lastLevelInCommon = level - 1;
     }
 
+    @Override
+    public SpatialContext getContext() {
+      return DUMMY_CTX;
+    }
+
     public UnitNRShape getMinUnit() { return minLV; }
 
     public UnitNRShape getMaxUnit() { return maxLV; }
@@ -954,6 +959,11 @@ public abstract class NumberRangePrefixT
     }
 
     @Override
+    public SpatialContext getContext() {
+      return DUMMY_CTX;
+    }
+
+    @Override
     public int hashCode() {
       //trick to re-use bytesref; provided that we re-instate it
       int myLastLen = term.length;

Modified: lucene/dev/trunk/lucene/spatial/src/java/org/apache/lucene/spatial/spatial4j/Geo3dShape.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/spatial/src/java/org/apache/lucene/spatial/spatial4j/Geo3dShape.java?rev=1704759&r1=1704758&r2=1704759&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/spatial/src/java/org/apache/lucene/spatial/spatial4j/Geo3dShape.java (original)
+++ lucene/dev/trunk/lucene/spatial/src/java/org/apache/lucene/spatial/spatial4j/Geo3dShape.java Wed Sep 23 02:46:43 2015
@@ -62,6 +62,11 @@ public class Geo3dShape implements Shape
   }
 
   @Override
+  public SpatialContext getContext() {
+    return ctx;
+  }
+
+  @Override
   public SpatialRelation relate(Shape other) {
     if (other instanceof Rectangle)
       return relate((Rectangle)other);

Modified: lucene/dev/trunk/lucene/spatial/src/test/org/apache/lucene/spatial/bbox/TestBBoxStrategy.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/spatial/src/test/org/apache/lucene/spatial/bbox/TestBBoxStrategy.java?rev=1704759&r1=1704758&r2=1704759&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/spatial/src/test/org/apache/lucene/spatial/bbox/TestBBoxStrategy.java (original)
+++ lucene/dev/trunk/lucene/spatial/src/test/org/apache/lucene/spatial/bbox/TestBBoxStrategy.java Wed Sep 23 02:46:43 2015
@@ -57,27 +57,18 @@ public class TestBBoxStrategy extends Ra
     int worldHeight = (int) Math.round(world.getHeight());
     int deltaTop = nextIntInclusive(worldHeight);
     int deltaBottom = nextIntInclusive(worldHeight - deltaTop);
-
-    double rectMinX = world.getMinX() + deltaLeft;
-    double rectMaxX = world.getMaxX() - deltaRight;
-    if (ctx.isGeo()) {
-      int shift = 0;
-      if ((deltaLeft != 0 || deltaRight != 0)) {
-        //if geo & doesn't world-wrap, we shift randomly to potentially cross dateline
-        shift = nextIntInclusive(360);
-      }
-      rectMinX = DistanceUtils.normLonDEG(rectMinX + shift);
-      rectMaxX = DistanceUtils.normLonDEG(rectMaxX + shift);
-      if (rectMinX == 180 && rectMaxX == 180) {
-        // Work-around for https://github.com/spatial4j/spatial4j/issues/85
-        rectMinX = -180;
-        rectMaxX = -180;
-      }
+    if (ctx.isGeo() && (deltaLeft != 0 || deltaRight != 0)) {
+      //if geo & doesn't world-wrap, we shift randomly to potentially cross dateline
+      int shift = nextIntInclusive(360);
+      return ctx.makeRectangle(
+          DistanceUtils.normLonDEG(world.getMinX() + deltaLeft + shift),
+          DistanceUtils.normLonDEG(world.getMaxX() - deltaRight + shift),
+          world.getMinY() + deltaBottom, world.getMaxY() - deltaTop);
+    } else {
+      return ctx.makeRectangle(
+          world.getMinX() + deltaLeft, world.getMaxX() - deltaRight,
+          world.getMinY() + deltaBottom, world.getMaxY() - deltaTop);
     }
-    return ctx.makeRectangle(
-        rectMinX,
-        rectMaxX,
-        world.getMinY() + deltaBottom, world.getMaxY() - deltaTop);
   }
 
   /** next int, inclusive, rounds to multiple of 10 if given evenly divisible. */

Modified: lucene/dev/trunk/lucene/spatial/src/test/org/apache/lucene/spatial/prefix/RandomSpatialOpFuzzyPrefixTreeTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/spatial/src/test/org/apache/lucene/spatial/prefix/RandomSpatialOpFuzzyPrefixTreeTest.java?rev=1704759&r1=1704758&r2=1704759&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/spatial/src/test/org/apache/lucene/spatial/prefix/RandomSpatialOpFuzzyPrefixTreeTest.java (original)
+++ lucene/dev/trunk/lucene/spatial/src/test/org/apache/lucene/spatial/prefix/RandomSpatialOpFuzzyPrefixTreeTest.java Wed Sep 23 02:46:43 2015
@@ -447,7 +447,7 @@ public class RandomSpatialOpFuzzyPrefixT
     final boolean biasContainsThenWithin;
 
     public ShapePair(Shape shape1, Shape shape2, boolean containsThenWithin) {
-      super(Arrays.asList(shape1, shape2), ctx);
+      super(Arrays.asList(shape1, shape2), RandomSpatialOpFuzzyPrefixTreeTest.this.ctx);
       this.shape1 = shape1;
       this.shape2 = shape2;
       this.shape1_2D = toNonGeo(shape1);

Modified: lucene/dev/trunk/lucene/spatial/src/test/org/apache/lucene/spatial/spatial4j/Geo3dShapeRectRelationTestCase.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/spatial/src/test/org/apache/lucene/spatial/spatial4j/Geo3dShapeRectRelationTestCase.java?rev=1704759&r1=1704758&r2=1704759&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/spatial/src/test/org/apache/lucene/spatial/spatial4j/Geo3dShapeRectRelationTestCase.java (original)
+++ lucene/dev/trunk/lucene/spatial/src/test/org/apache/lucene/spatial/spatial4j/Geo3dShapeRectRelationTestCase.java Wed Sep 23 02:46:43 2015
@@ -22,10 +22,12 @@ import java.util.List;
 import java.util.Random;
 
 import com.carrotsearch.randomizedtesting.RandomizedContext;
+import com.spatial4j.core.TestLog;
 import com.spatial4j.core.context.SpatialContext;
 import com.spatial4j.core.distance.DistanceUtils;
 import com.spatial4j.core.shape.Circle;
 import com.spatial4j.core.shape.Point;
+import com.spatial4j.core.shape.RectIntersectionTestHelper;
 import org.apache.lucene.geo3d.LatLonBounds;
 import org.apache.lucene.geo3d.GeoBBox;
 import org.apache.lucene.geo3d.GeoBBoxFactory;
@@ -44,7 +46,7 @@ public abstract class Geo3dShapeRectRela
   protected final static double RADIANS_PER_DEGREE = Math.PI/180.0;
 
   @Rule
-  public final LogRule testLog = LogRule.instance;
+  public final TestLog testLog = TestLog.instance;
 
   protected static Random random() {
     return RandomizedContext.current().getRandom();
@@ -91,15 +93,26 @@ public abstract class Geo3dShapeRectRela
       super(ctx);
     }
 
-    @Override
-    protected int getMaxLaps() {
-      //sometimes, getWithinMinimum needs some more attempts then normal; 20k is suggested max.
-      return 200_000;//200k
+    //20 times each -- should be plenty
+
+    protected int getContainsMinimum(int laps) {
+      return 20;
+    }
+
+    protected int getIntersectsMinimum(int laps) {
+      return 20;
+    }
+
+    protected int getWithinMinimum(int laps) {
+      return 20;
+    }
+
+    protected int getDisjointMinimum(int laps) {
+      return 20;
     }
 
-    @Override
-    protected int getDefaultMinimumPredicateFrequency(int maxLaps) {
-      return 20;//20 times each -- should be plenty in 200k
+    protected int getBoundingMinimum(int laps) {
+      return 20;
     }
   }
 

Added: lucene/dev/trunk/solr/licenses/spatial4j-0.5.jar.sha1
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/licenses/spatial4j-0.5.jar.sha1?rev=1704759&view=auto
==============================================================================
--- lucene/dev/trunk/solr/licenses/spatial4j-0.5.jar.sha1 (added)
+++ lucene/dev/trunk/solr/licenses/spatial4j-0.5.jar.sha1 Wed Sep 23 02:46:43 2015
@@ -0,0 +1 @@
+6e16edaf6b1ba76db7f08c2f3723fce3b358ecc3