You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by mi...@apache.org on 2015/08/24 15:21:11 UTC

svn commit: r1697386 - in /lucene/dev/branches/lucene6699/lucene: analysis/common/src/java/org/apache/lucene/analysis/standard/ spatial3d/src/java/org/apache/lucene/bkdtree3d/ spatial3d/src/java/org/apache/lucene/geo3d/ spatial3d/src/test/org/apache/lu...

Author: mikemccand
Date: Mon Aug 24 13:21:10 2015
New Revision: 1697386

URL: http://svn.apache.org/r1697386
Log:
LUCENE-6699: MINIMUM_RESOLUTION back to 1e-12

Modified:
    lucene/dev/branches/lucene6699/lucene/analysis/common/src/java/org/apache/lucene/analysis/standard/StandardTokenizerImpl.jflex
    lucene/dev/branches/lucene6699/lucene/spatial3d/src/java/org/apache/lucene/bkdtree3d/BKD3DTreeReader.java
    lucene/dev/branches/lucene6699/lucene/spatial3d/src/java/org/apache/lucene/bkdtree3d/PointInGeo3DShapeQuery.java
    lucene/dev/branches/lucene6699/lucene/spatial3d/src/java/org/apache/lucene/geo3d/GeoCircle.java
    lucene/dev/branches/lucene6699/lucene/spatial3d/src/java/org/apache/lucene/geo3d/GeoPath.java
    lucene/dev/branches/lucene6699/lucene/spatial3d/src/java/org/apache/lucene/geo3d/Vector.java
    lucene/dev/branches/lucene6699/lucene/spatial3d/src/test/org/apache/lucene/bkdtree3d/TestGeo3DPointField.java
    lucene/dev/branches/lucene6699/lucene/spatial3d/src/test/org/apache/lucene/geo3d/GeoCircleTest.java

Modified: lucene/dev/branches/lucene6699/lucene/analysis/common/src/java/org/apache/lucene/analysis/standard/StandardTokenizerImpl.jflex
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6699/lucene/analysis/common/src/java/org/apache/lucene/analysis/standard/StandardTokenizerImpl.jflex?rev=1697386&r1=1697385&r2=1697386&view=diff
==============================================================================
--- lucene/dev/branches/lucene6699/lucene/analysis/common/src/java/org/apache/lucene/analysis/standard/StandardTokenizerImpl.jflex (original)
+++ lucene/dev/branches/lucene6699/lucene/analysis/common/src/java/org/apache/lucene/analysis/standard/StandardTokenizerImpl.jflex Mon Aug 24 13:21:10 2015
@@ -18,6 +18,7 @@ package org.apache.lucene.analysis.stand
  */
 
 import org.apache.lucene.analysis.tokenattributes.CharTermAttribute;
+import org.apache.lucene.analysis.stages.tokenattributes.TermAttribute;
 
 /**
  * This class implements Word Break rules from the Unicode Text Segmentation 
@@ -100,7 +101,7 @@ ComplexContextEx    = \p{LB:Complex_Cont
   public final void getText(CharTermAttribute t) {
     t.copyBuffer(zzBuffer, zzStartRead, zzMarkedPos-zzStartRead);
   }
-  
+
   /**
    * Sets the scanner buffer size in chars
    */

Modified: lucene/dev/branches/lucene6699/lucene/spatial3d/src/java/org/apache/lucene/bkdtree3d/BKD3DTreeReader.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6699/lucene/spatial3d/src/java/org/apache/lucene/bkdtree3d/BKD3DTreeReader.java?rev=1697386&r1=1697385&r2=1697386&view=diff
==============================================================================
--- lucene/dev/branches/lucene6699/lucene/spatial3d/src/java/org/apache/lucene/bkdtree3d/BKD3DTreeReader.java (original)
+++ lucene/dev/branches/lucene6699/lucene/spatial3d/src/java/org/apache/lucene/bkdtree3d/BKD3DTreeReader.java Mon Aug 24 13:21:10 2015
@@ -150,7 +150,14 @@ final class BKD3DTreeReader implements A
 
         // Up above in the recursion we asked valueFilter to relate our cell, and it returned Relation.CELL_INSIDE_SHAPE
         // so all docs inside this cell better be accepted by the filter:
-        assert state.valueFilter.accept(docID);
+
+        // nocommit back to assert
+        // assert state.valueFilter.accept(docID);
+
+        if (state.valueFilter.accept(docID) == false) {
+          System.out.println("\n" + Thread.currentThread().getName() + ": FAILED: docID=" + docID);
+          throw new RuntimeException("FAILED");
+        }
       }
 
       return count;
@@ -188,6 +195,13 @@ final class BKD3DTreeReader implements A
         return 0;
       } else if (r == Relation.CELL_INSIDE_SHAPE) {
         // This cell is fully inside of the query shape: recursively add all points in this cell without filtering
+        
+        /*
+        System.out.println(Thread.currentThread() + ": switch to addAll at cell" +
+                           " x=" + Geo3DDocValuesFormat.decodeValue(cellXMin) + " to " + Geo3DDocValuesFormat.decodeValue(cellXMax) +
+                           " y=" + Geo3DDocValuesFormat.decodeValue(cellYMin) + " to " + Geo3DDocValuesFormat.decodeValue(cellYMax) +
+                           " z=" + Geo3DDocValuesFormat.decodeValue(cellZMin) + " to " + Geo3DDocValuesFormat.decodeValue(cellZMax));
+        */
         return addAll(state, nodeID);
       } else {
         // The cell crosses the shape boundary, so we fall through and do full filtering

Modified: lucene/dev/branches/lucene6699/lucene/spatial3d/src/java/org/apache/lucene/bkdtree3d/PointInGeo3DShapeQuery.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6699/lucene/spatial3d/src/java/org/apache/lucene/bkdtree3d/PointInGeo3DShapeQuery.java?rev=1697386&r1=1697385&r2=1697386&view=diff
==============================================================================
--- lucene/dev/branches/lucene6699/lucene/spatial3d/src/java/org/apache/lucene/bkdtree3d/PointInGeo3DShapeQuery.java (original)
+++ lucene/dev/branches/lucene6699/lucene/spatial3d/src/java/org/apache/lucene/bkdtree3d/PointInGeo3DShapeQuery.java Mon Aug 24 13:21:10 2015
@@ -131,6 +131,8 @@ public class PointInGeo3DShapeQuery exte
                                              double x = Geo3DDocValuesFormat.decodeValue(Geo3DDocValuesFormat.readInt(bytes.bytes, bytes.offset));
                                              double y = Geo3DDocValuesFormat.decodeValue(Geo3DDocValuesFormat.readInt(bytes.bytes, bytes.offset+4));
                                              double z = Geo3DDocValuesFormat.decodeValue(Geo3DDocValuesFormat.readInt(bytes.bytes, bytes.offset+8));
+                                             // System.out.println("  accept docID=" + docID + " point: x=" + x + " y=" + y + " z=" + z);
+
                                              // True if x,y,z is within shape
                                              //System.out.println("    x=" + x + " y=" + y + " z=" + z);
                                              //System.out.println("    ret: " + shape.isWithin(x, y, z));

Modified: lucene/dev/branches/lucene6699/lucene/spatial3d/src/java/org/apache/lucene/geo3d/GeoCircle.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6699/lucene/spatial3d/src/java/org/apache/lucene/geo3d/GeoCircle.java?rev=1697386&r1=1697385&r2=1697386&view=diff
==============================================================================
--- lucene/dev/branches/lucene6699/lucene/spatial3d/src/java/org/apache/lucene/geo3d/GeoCircle.java (original)
+++ lucene/dev/branches/lucene6699/lucene/spatial3d/src/java/org/apache/lucene/geo3d/GeoCircle.java Mon Aug 24 13:21:10 2015
@@ -85,7 +85,8 @@ public class GeoCircle extends GeoBaseDi
       this.circlePlane = SidedPlane.constructNormalizedPerpendicularSidedPlane(center, normalPlane, upperPoint, lowerPoint);
       if (circlePlane == null)
         throw new RuntimeException("Couldn't construct circle plane.  Cutoff angle = "+cutoffAngle+"; upperPoint = "+upperPoint+"; lowerPoint = "+lowerPoint);
-      this.edgePoints = new GeoPoint[]{upperPoint};
+      final GeoPoint recomputedIntersectionPoint = circlePlane.getSampleIntersectionPoint(planetModel, normalPlane);
+      this.edgePoints = new GeoPoint[]{recomputedIntersectionPoint};
     }
   }
 
@@ -140,7 +141,7 @@ public class GeoCircle extends GeoBaseDi
     }
     bounds.addPoint(center);
     // Cheap way of preventing bounds from not agreeing with edgepoint perfectly
-    bounds.addPoint(edgePoints[0]);
+    //bounds.addPoint(edgePoints[0]);
     bounds.addPlane(planetModel, circlePlane);
   }
 

Modified: lucene/dev/branches/lucene6699/lucene/spatial3d/src/java/org/apache/lucene/geo3d/GeoPath.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6699/lucene/spatial3d/src/java/org/apache/lucene/geo3d/GeoPath.java?rev=1697386&r1=1697385&r2=1697386&view=diff
==============================================================================
--- lucene/dev/branches/lucene6699/lucene/spatial3d/src/java/org/apache/lucene/geo3d/GeoPath.java (original)
+++ lucene/dev/branches/lucene6699/lucene/spatial3d/src/java/org/apache/lucene/geo3d/GeoPath.java Mon Aug 24 13:21:10 2015
@@ -140,10 +140,14 @@ public class GeoPath extends GeoBaseDist
       }
       final GeoPoint upperPoint = new GeoPoint(planetModel, upperLat, upperLon);
       final GeoPoint lowerPoint = new GeoPoint(planetModel, lowerLat, lowerLon);
+      final GeoPoint point = points.get(0);
+      
+      // Construct normal plane
+      final Plane normalPlane = Plane.constructNormalizedZPlane(upperPoint, lowerPoint, point);
 
-      final SegmentEndpoint onlyEndpoint = new SegmentEndpoint(points.get(0), upperPoint, lowerPoint);
+      final SegmentEndpoint onlyEndpoint = new SegmentEndpoint(point, normalPlane, upperPoint, lowerPoint);
       endPoints.add(onlyEndpoint);
-      this.edgePoints = new GeoPoint[]{upperPoint};
+      this.edgePoints = new GeoPoint[]{onlyEndpoint.circlePlane.getSampleIntersectionPoint(planetModel, normalPlane)};
       return;
     }
     
@@ -338,7 +342,9 @@ public class GeoPath extends GeoBaseDist
     public final GeoPoint[] notablePoints;
     /** No notable points from the circle itself */
     public final static GeoPoint[] circlePoints = new GeoPoint[0];
-
+    /** Null membership */
+    public final static Membership[] NO_MEMBERSHIP = new Membership[0];
+    
     /** Base case.  Does nothing at all.
      */
     public SegmentEndpoint(final GeoPoint point) {
@@ -354,14 +360,12 @@ public class GeoPath extends GeoBaseDist
      *@param upperPoint is a point that must be on the circle plane.
      *@param lowerPoint is another point that must be on the circle plane.
      */
-    public SegmentEndpoint(final GeoPoint point, final GeoPoint upperPoint, final GeoPoint lowerPoint) {
+    public SegmentEndpoint(final GeoPoint point, final Plane normalPlane, final GeoPoint upperPoint, final GeoPoint lowerPoint) {
       this.point = point;
-      // Construct normal plane
-      final Plane normalPlane = Plane.constructNormalizedZPlane(upperPoint, lowerPoint, point);
       // Construct a sided plane that goes through the two points and whose normal is in the normalPlane.
       this.circlePlane = SidedPlane.constructNormalizedPerpendicularSidedPlane(point, normalPlane, upperPoint, lowerPoint);
-      this.cutoffPlanes = new Membership[0];
-      this.notablePoints = new GeoPoint[0];
+      this.cutoffPlanes = NO_MEMBERSHIP;
+      this.notablePoints = circlePoints;
     }
     
     /** Constructor for case (2).

Modified: lucene/dev/branches/lucene6699/lucene/spatial3d/src/java/org/apache/lucene/geo3d/Vector.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6699/lucene/spatial3d/src/java/org/apache/lucene/geo3d/Vector.java?rev=1697386&r1=1697385&r2=1697386&view=diff
==============================================================================
--- lucene/dev/branches/lucene6699/lucene/spatial3d/src/java/org/apache/lucene/geo3d/Vector.java (original)
+++ lucene/dev/branches/lucene6699/lucene/spatial3d/src/java/org/apache/lucene/geo3d/Vector.java Mon Aug 24 13:21:10 2015
@@ -28,7 +28,7 @@ public class Vector {
    * Values that are all considered to be essentially zero have a magnitude
    * less than this.
    */
-  public static final double MINIMUM_RESOLUTION = 7.5e-11;
+  public static final double MINIMUM_RESOLUTION = 1e-12;//7.5e-11;
   /**
    * For squared quantities, the bound is squared too.
    */

Modified: lucene/dev/branches/lucene6699/lucene/spatial3d/src/test/org/apache/lucene/bkdtree3d/TestGeo3DPointField.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6699/lucene/spatial3d/src/test/org/apache/lucene/bkdtree3d/TestGeo3DPointField.java?rev=1697386&r1=1697385&r2=1697386&view=diff
==============================================================================
--- lucene/dev/branches/lucene6699/lucene/spatial3d/src/test/org/apache/lucene/bkdtree3d/TestGeo3DPointField.java (original)
+++ lucene/dev/branches/lucene6699/lucene/spatial3d/src/test/org/apache/lucene/bkdtree3d/TestGeo3DPointField.java Mon Aug 24 13:21:10 2015
@@ -262,6 +262,7 @@ public class TestGeo3DPointField extends
                                       Point point = points.get(docID);
                                       //System.out.println("  accept docID=" + docID + " point=" + point + " (x=" + encodeValue(point.x) + " y=" + encodeValue(point.y) + " z=" + encodeValue(point.z) + ")");
 
+                                      // System.out.println("  accept docID=" + docID + " point: x=" + point.x + " y=" + point.y + " z=" + point.z);
                                       int xEnc = encodeValue(point.x);
                                       int yEnc = encodeValue(point.y);
                                       int zEnc = encodeValue(point.z);
@@ -548,7 +549,7 @@ public class TestGeo3DPointField extends
                 shape = new GeoCircle(planetModel, lat, lon, angle);
 
                 if (VERBOSE) {
-                  System.err.println("\nTEST: iter=" + iter + " shape="+shape);
+                  System.err.println("\n" + Thread.currentThread() + ": TEST: iter=" + iter + " shape="+shape);
                 }
 
               } else {
@@ -570,7 +571,7 @@ public class TestGeo3DPointField extends
                 shape = GeoBBoxFactory.makeGeoBBox(planetModel, lat1, lat0, lon0, lon1);
 
                 if (VERBOSE) {
-                  System.err.println("\nTEST: iter=" + iter + " shape="+shape);
+                  System.err.println("\n" + Thread.currentThread() + ": TEST: iter=" + iter + " shape="+shape);
                 }
 
               }

Modified: lucene/dev/branches/lucene6699/lucene/spatial3d/src/test/org/apache/lucene/geo3d/GeoCircleTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6699/lucene/spatial3d/src/test/org/apache/lucene/geo3d/GeoCircleTest.java?rev=1697386&r1=1697385&r2=1697386&view=diff
==============================================================================
--- lucene/dev/branches/lucene6699/lucene/spatial3d/src/test/org/apache/lucene/geo3d/GeoCircleTest.java (original)
+++ lucene/dev/branches/lucene6699/lucene/spatial3d/src/test/org/apache/lucene/geo3d/GeoCircleTest.java Mon Aug 24 13:21:10 2015
@@ -23,7 +23,9 @@ import static org.junit.Assert.assertEqu
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertTrue;
 
-public class GeoCircleTest {
+import org.apache.lucene.util.LuceneTestCase;
+
+public class GeoCircleTest extends LuceneTestCase {
 
   @Test
   public void testCircleDistance() {
@@ -98,7 +100,28 @@ public class GeoCircleTest {
     GeoArea area;
     GeoPoint p1;
     GeoPoint p2;
-
+    
+    // Sixth BKD discovered failure
+    c = new GeoCircle(PlanetModel.WGS84,-0.006450320645814321,0.004660694205115142,0.00489710732634323);
+    //xyzb = new XYZBounds();
+    //c.getBounds(xyzb);
+    //System.err.println("xmin="+xyzb.getMinimumX()+", xmax="+xyzb.getMaximumX()+",ymin="+xyzb.getMinimumY()+", ymax="+xyzb.getMaximumY()+",zmin="+xyzb.getMinimumZ()+", zmax="+xyzb.getMaximumZ());
+    //xmin=1.0010356621420726, xmax=1.0011141249179447,ymin=-2.5326643901354566E-4, ymax=0.009584741915757169,zmin=-0.011359874956269283, zmax=-0.0015549504447452225
+    area = GeoAreaFactory.makeGeoArea(PlanetModel.WGS84,1.0010822580620098,1.0010945779732867,0.007079167343247293,0.007541006774427837,-0.0021855011220022575,-0.001896122718181518);
+    assertTrue(GeoArea.CONTAINS != area.getRelationship(c));
+    /*
+    p1 = new GeoPoint(1.0010893045436076,0.007380935180644008,-0.002140671370616495);
+    // This has a different bounding box, so we can't use it.
+    //p2 = new GeoPoint(PlanetModel.WGS84,-0.002164069780096702, 0.007505617500830066);
+    p2 = new GeoPoint(PlanetModel.WGS84,p1.getLatitude(),p1.getLongitude());
+    assertTrue(PlanetModel.WGS84.pointOnSurface(p2));
+    assertTrue(!c.isWithin(p2));
+    assertTrue(!area.isWithin(p2));
+    assertTrue(!c.isWithin(p1));
+    assertTrue(PlanetModel.WGS84.pointOnSurface(p1)); // This fails
+    assertTrue(!area.isWithin(p1)); // This fails
+    */
+    
     // Fifth BKD discovered failure
     c = new GeoCircle(PlanetModel.SPHERE, -0.004282454525970269, -1.6739831367422277E-4, 1.959639723134033E-6);
     assertTrue(c.isWithin(c.getEdgePoints()[0]));