lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kwri...@apache.org
Subject [1/2] lucene-solr:branch_6x: LUCENE-7225: Handle case where we don't know what truth is properly.
Date Sat, 16 Apr 2016 14:20:08 GMT
Repository: lucene-solr
Updated Branches:
  refs/heads/branch_6x 930d9f912 -> 69dfdb771


LUCENE-7225: Handle case where we don't know what truth is properly.


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

Branch: refs/heads/branch_6x
Commit: 080e67c4f21338b2c75d797f27689b6d6733f5b0
Parents: 930d9f9
Author: Karl Wright <DaddyWri@gmail.com>
Authored: Sat Apr 16 08:29:43 2016 -0400
Committer: Karl Wright <DaddyWri@gmail.com>
Committed: Sat Apr 16 10:15:58 2016 -0400

----------------------------------------------------------------------
 .../spatial3d/PointInShapeIntersectVisitor.java | 35 +++++++++---
 .../apache/lucene/spatial3d/TestGeo3DPoint.java | 58 ++++++++++++--------
 .../lucene/spatial3d/geom/GeoBBoxTest.java      |  2 +-
 3 files changed, 61 insertions(+), 34 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/080e67c4/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/PointInShapeIntersectVisitor.java
----------------------------------------------------------------------
diff --git a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/PointInShapeIntersectVisitor.java
b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/PointInShapeIntersectVisitor.java
index 348396b..268f3ce 100644
--- a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/PointInShapeIntersectVisitor.java
+++ b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/PointInShapeIntersectVisitor.java
@@ -46,14 +46,31 @@ class PointInShapeIntersectVisitor implements IntersectVisitor {
   @Override
   public void visit(int docID, byte[] packedValue) {
     assert packedValue.length == 12;
-    double x = Geo3DPoint.decodeDimension(packedValue, 0);
-    double y = Geo3DPoint.decodeDimension(packedValue, Integer.BYTES);
-    double z = Geo3DPoint.decodeDimension(packedValue, 2 * Integer.BYTES);
-    if (x >= shapeBounds.getMinimumX() && x <= shapeBounds.getMaximumX() &&
-      y >= shapeBounds.getMinimumY() && y <= shapeBounds.getMaximumY() &&
-      z >= shapeBounds.getMinimumZ() && z <= shapeBounds.getMaximumZ()) {
-      if (shape.isWithin(x, y, z)) {
-        hits.add(docID);
+    final int xInt = NumericUtils.sortableBytesToInt(packedValue, 0);
+    final double xMin = Geo3DUtil.decodeValueFloor(xInt);
+    final double xMax = Geo3DUtil.decodeValueCeil(xInt);
+    if (xMin >= shapeBounds.getMinimumX() && xMin <= shapeBounds.getMaximumX()
||
+      xMax >= shapeBounds.getMinimumX() && xMax <= shapeBounds.getMaximumX())
{
+      // X is OK
+      final int yInt = NumericUtils.sortableBytesToInt(packedValue, Integer.BYTES);
+      final double yMin = Geo3DUtil.decodeValueFloor(yInt);
+      final double yMax = Geo3DUtil.decodeValueCeil(yInt);
+      if (yMin >= shapeBounds.getMinimumY() && yMin <= shapeBounds.getMaximumY()
||
+        yMax >= shapeBounds.getMinimumY() && yMax <= shapeBounds.getMaximumY())
{
+        // Y is OK
+        final int zInt = NumericUtils.sortableBytesToInt(packedValue, 2 * Integer.BYTES);
+        final double zMin = Geo3DUtil.decodeValueFloor(zInt);
+        final double zMax = Geo3DUtil.decodeValueCeil(zInt);
+        if (zMin >= shapeBounds.getMinimumZ() && zMin <= shapeBounds.getMaximumZ()
||
+          zMax >= shapeBounds.getMinimumZ() && zMax <= shapeBounds.getMaximumZ())
{
+          // Z is OK
+          final double x = Geo3DUtil.decodeValue(xInt);
+          final double y = Geo3DUtil.decodeValue(yInt);
+          final double z = Geo3DUtil.decodeValue(zInt);
+          if (shape.isWithin(x, y, z)) {
+            hits.add(docID);
+          }
+        }
       }
     }
   }
@@ -82,7 +99,7 @@ class PointInShapeIntersectVisitor implements IntersectVisitor {
       shapeBounds.getMinimumZ() >= zMin && shapeBounds.getMaximumZ() <= zMax)
{
       return Relation.CELL_CROSSES_QUERY;
     }
-    
+
     // Quick test failed so do slower one...
     GeoArea xyzSolid = GeoAreaFactory.makeGeoArea(PlanetModel.WGS84, xMin, xMax, yMin, yMax,
zMin, zMax);
 

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/080e67c4/lucene/spatial3d/src/test/org/apache/lucene/spatial3d/TestGeo3DPoint.java
----------------------------------------------------------------------
diff --git a/lucene/spatial3d/src/test/org/apache/lucene/spatial3d/TestGeo3DPoint.java b/lucene/spatial3d/src/test/org/apache/lucene/spatial3d/TestGeo3DPoint.java
index 48e7f0a..a8a7300 100644
--- a/lucene/spatial3d/src/test/org/apache/lucene/spatial3d/TestGeo3DPoint.java
+++ b/lucene/spatial3d/src/test/org/apache/lucene/spatial3d/TestGeo3DPoint.java
@@ -686,12 +686,14 @@ public class TestGeo3DPoint extends LuceneTestCase {
     IndexWriterConfig iwc = newIndexWriterConfig();
 
     GeoPoint[] points = new GeoPoint[lats.length];
-
+    GeoPoint[] unquantizedPoints = new GeoPoint[lats.length];
+    
     // Pre-quantize all lat/lons:
     for(int i=0;i<lats.length;i++) {
       if (Double.isNaN(lats[i]) == false) {
         //System.out.println("lats[" + i + "] = " + lats[i]);
-        points[i] = quantize(new GeoPoint(PlanetModel.WGS84, toRadians(lats[i]), toRadians(lons[i])));
+        unquantizedPoints[i] = new GeoPoint(PlanetModel.WGS84, toRadians(lats[i]), toRadians(lons[i]));
+        points[i] = quantize(unquantizedPoints[i]);
       }
     }
 
@@ -789,26 +791,36 @@ public class TestGeo3DPoint extends LuceneTestCase {
       for(int docID=0;docID<r.maxDoc();docID++) {
         int id = (int) docIDToID.get(docID);
         GeoPoint point = points[id];
-        if (point != null) {
-          boolean expected = ((deleted.contains(id) == false) && ((PointInGeo3DShapeQuery)query).getShape().isWithin(point));
+        GeoPoint unquantizedPoint = unquantizedPoints[id];
+        if (point != null && unquantizedPoint != null) {
+          GeoShape shape = ((PointInGeo3DShapeQuery)query).getShape();
+          // If there's a conflict, we don't know what 'truth' actually is; either result
is OK
+          boolean conflict = shape.isWithin(point) != shape.isWithin(unquantizedPoint);
+          boolean expected = ((deleted.contains(id) == false) && shape.isWithin(unquantizedPoint));
           if (hits.get(docID) != expected) {
-            GeoPoint scaledPoint = PlanetModel.WGS84.createSurfacePoint(point);
-            StringBuilder b = new StringBuilder();
-            if (expected) {
-              b.append("FAIL: id=" + id + " should have matched but did not\n");
+            if (conflict) {
+              if (VERBOSE) {
+                System.err.println("CONFLICT: id=" + id + " quantized point membership disagrees
with non-quantized point: truth unknown");
+              }
             } else {
-              b.append("FAIL: id=" + id + " should not have matched but did\n");
+              StringBuilder b = new StringBuilder();
+              if (expected) {
+                b.append("FAIL: id=" + id + " should have matched but did not\n");
+              } else {
+                b.append("FAIL: id=" + id + " should not have matched but did\n");
+              }
+              b.append("  shape=" + ((PointInGeo3DShapeQuery)query).getShape() + "\n");
+              b.append("  world bounds=(" +
+                " minX=" + PlanetModel.WGS84.getMinimumXValue() + " maxX=" + PlanetModel.WGS84.getMaximumXValue()
+
+                " minY=" + PlanetModel.WGS84.getMinimumYValue() + " maxY=" + PlanetModel.WGS84.getMaximumYValue()
+
+                " minZ=" + PlanetModel.WGS84.getMinimumZValue() + " maxZ=" + PlanetModel.WGS84.getMaximumZValue()
+ "\n");
+              b.append("  quantized point=" + point + " within shape? "+shape.isWithin(point)+"\n");
+              b.append("  unquantized point=" + unquantizedPoint + " within shape? "+shape.isWithin(unquantizedPoint)+"\n");
+              b.append("  docID=" + docID + " deleted?=" + deleted.contains(id) + "\n");
+              b.append("  query=" + query + "\n");
+              b.append("  explanation:\n    " + explain("point", shape, point, unquantizedPoint,
r, docID).replace("\n", "\n  "));
+              fail(b.toString());
             }
-            b.append("  shape=" + ((PointInGeo3DShapeQuery)query).getShape() + "\n");
-            b.append("  world bounds=(" +
-              " minX=" + PlanetModel.WGS84.getMinimumXValue() + " maxX=" + PlanetModel.WGS84.getMaximumXValue()
+
-              " minY=" + PlanetModel.WGS84.getMinimumYValue() + " maxY=" + PlanetModel.WGS84.getMaximumYValue()
+
-              " minZ=" + PlanetModel.WGS84.getMinimumZValue() + " maxZ=" + PlanetModel.WGS84.getMaximumZValue()
+ "\n");
-            b.append("  point=" + point + "\n");
-            b.append("  docID=" + docID + " deleted?=" + deleted.contains(id) + "\n");
-            b.append("  query=" + query + "\n");
-            b.append("  explanation:\n    " + explain("point", ((PointInGeo3DShapeQuery)query).getShape(),
point, scaledPoint, r, docID).replace("\n", "\n  "));
-            fail(b.toString());
           }
         } else {
           assertFalse(hits.get(docID));
@@ -1271,7 +1283,7 @@ public class TestGeo3DPoint extends LuceneTestCase {
       } else {
         Relation result = in.compare(minPackedValue, maxPackedValue);
         if (targetStackUpto < stackToTargetDoc.size() && cell.equals(stackToTargetDoc.get(targetStackUpto)))
{
-          b.append("  on cell " + stackToTargetDoc.get(targetStackUpto) + ", wrapped visitor
returned " + result);
+          b.append("  on cell " + stackToTargetDoc.get(targetStackUpto) + ", wrapped visitor
returned " + result + "\n");
           targetStackUpto++;
         }
         return result;
@@ -1314,9 +1326,7 @@ public class TestGeo3DPoint extends LuceneTestCase {
         double zMax = Geo3DUtil.decodeValueCeil(NumericUtils.sortableBytesToInt(maxPackedValue,
2 * Integer.BYTES));
         final XYZSolid xyzSolid = XYZSolidFactory.makeXYZSolid(PlanetModel.WGS84, xMin, xMax,
yMin, yMax, zMin, zMax);
         final int relationship = xyzSolid.getRelationship(shape);
-        final boolean pointWithinShape = shape.isWithin(targetDocPoint);
         final boolean pointWithinCell = xyzSolid.isWithin(targetDocPoint);
-        final boolean scaledWithinShape = shape.isWithin(scaledDocPoint);
         final boolean scaledWithinCell = xyzSolid.isWithin(scaledDocPoint);
 
         final String relationshipString;
@@ -1339,8 +1349,8 @@ public class TestGeo3DPoint extends LuceneTestCase {
         }
         return "Cell(x=" + xMin + " TO " + xMax + " y=" + yMin + " TO " + yMax + " z=" +
zMin + " TO " + zMax +
           "); Shape relationship = "+relationshipString+
-          "; Point within cell = "+pointWithinCell+"; Point within shape = "+pointWithinShape+
-          "; Scaled point within cell = "+scaledWithinCell+"; Scaled point within shape =
"+scaledWithinShape;
+          "; Quantized point within cell = "+pointWithinCell+
+          "; Unquantized point within cell = "+scaledWithinCell;
       }
 
       @Override

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/080e67c4/lucene/spatial3d/src/test/org/apache/lucene/spatial3d/geom/GeoBBoxTest.java
----------------------------------------------------------------------
diff --git a/lucene/spatial3d/src/test/org/apache/lucene/spatial3d/geom/GeoBBoxTest.java b/lucene/spatial3d/src/test/org/apache/lucene/spatial3d/geom/GeoBBoxTest.java
index f5a148f..4442a79 100755
--- a/lucene/spatial3d/src/test/org/apache/lucene/spatial3d/geom/GeoBBoxTest.java
+++ b/lucene/spatial3d/src/test/org/apache/lucene/spatial3d/geom/GeoBBoxTest.java
@@ -360,5 +360,5 @@ public class GeoBBoxTest {
     //assertEquals(Math.PI,b.getRightLongitude(),0.000001);
 
   }
-
+  
 }


Mime
View raw message