You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by kw...@apache.org on 2018/04/10 00:14:21 UTC
[1/2] lucene-solr:master: LUCENE-8245: Don't rely only on
'intersects' code to determine whether we should bother looking for crossings;
also see if endpoints lie on travel planes.
Repository: lucene-solr
Updated Branches:
refs/heads/master a12d39887 -> 1cd859713
LUCENE-8245: Don't rely only on 'intersects' code to determine whether we should bother looking for crossings; also see if endpoints lie on travel planes.
Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/9bd6d130
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/9bd6d130
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/9bd6d130
Branch: refs/heads/master
Commit: 9bd6d1305c8bbccf2f3a22079a523b483325e9eb
Parents: bd8fe72
Author: Karl Wright <Da...@gmail.com>
Authored: Mon Apr 9 20:13:12 2018 -0400
Committer: Karl Wright <Da...@gmail.com>
Committed: Mon Apr 9 20:13:12 2018 -0400
----------------------------------------------------------------------
.../spatial3d/geom/GeoComplexPolygon.java | 46 +++++++++++++++-----
.../org/apache/lucene/spatial3d/geom/Plane.java | 5 ++-
.../lucene/spatial3d/geom/GeoPolygonTest.java | 17 ++++++++
3 files changed, 55 insertions(+), 13 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/9bd6d130/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoComplexPolygon.java
----------------------------------------------------------------------
diff --git a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoComplexPolygon.java b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoComplexPolygon.java
index f64755c..5c3521c 100644
--- a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoComplexPolygon.java
+++ b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoComplexPolygon.java
@@ -935,8 +935,10 @@ class GeoComplexPolygon extends GeoBasePolygon {
// Some edges are going to be given to us even when there's no real intersection, so do that as a sanity check, first.
final GeoPoint[] planeCrossings = plane.findIntersections(planetModel, edge.plane, bound, edge.startPlane, edge.endPlane);
if (planeCrossings != null && planeCrossings.length == 0) {
- // No actual crossing
- return true;
+ // Sometimes on the hairy edge an intersection will be missed. This check finds those.
+ if (!plane.evaluateIsZero(edge.startPoint) && !plane.evaluateIsZero(edge.endPoint)) {
+ return true;
+ }
}
// Determine crossings of this edge against all inside/outside planes. There's no further need to look at the actual travel plane itself.
@@ -1021,8 +1023,10 @@ class GeoComplexPolygon extends GeoBasePolygon {
// Some edges are going to be given to us even when there's no real intersection, so do that as a sanity check, first.
final GeoPoint[] planeCrossings = plane.findIntersections(planetModel, edge.plane, bound1, bound2, edge.startPlane, edge.endPlane);
if (planeCrossings != null && planeCrossings.length == 0) {
- // No actual crossing
- return true;
+ // Sometimes on the hairy edge an intersection will be missed. This check finds those.
+ if (!plane.evaluateIsZero(edge.startPoint) && !plane.evaluateIsZero(edge.endPoint)) {
+ return true;
+ }
}
// Determine crossings of this edge against all inside/outside planes. There's no further need to look at the actual travel plane itself.
@@ -1248,8 +1252,6 @@ class GeoComplexPolygon extends GeoBasePolygon {
}
seenEdges.add(edge);
- //System.out.println("Considering edge "+(edge.startPoint)+" -> "+(edge.endPoint));
-
// We've never seen this edge before. Evaluate it in the context of inner and outer planes.
computeInsideOutside();
@@ -1273,14 +1275,36 @@ class GeoComplexPolygon extends GeoBasePolygon {
System.out.println("");
*/
+ //System.out.println("Considering edge "+(edge.startPoint)+" -> "+(edge.endPoint));
+
// Some edges are going to be given to us even when there's no real intersection, so do that as a sanity check, first.
final GeoPoint[] travelCrossings = travelPlane.findIntersections(planetModel, edge.plane, checkPointCutoffPlane, checkPointOtherCutoffPlane, edge.startPlane, edge.endPlane);
if (travelCrossings != null && travelCrossings.length == 0) {
final GeoPoint[] testPointCrossings = testPointPlane.findIntersections(planetModel, edge.plane, testPointCutoffPlane, testPointOtherCutoffPlane, edge.startPlane, edge.endPlane);
if (testPointCrossings != null && testPointCrossings.length == 0) {
- return true;
+ // As a last resort, see if the edge endpoints are on either plane. This is sometimes necessary because the
+ // intersection computation logic might not detect near-miss edges otherwise.
+ if (!travelPlane.evaluateIsZero(edge.startPoint) && !travelPlane.evaluateIsZero(edge.endPoint) &&
+ !testPointPlane.evaluateIsZero(edge.startPoint) && !testPointPlane.evaluateIsZero(edge.endPoint)) {
+ return true;
+ }
}
}
+
+ /*
+ System.out.println(
+ " start point travel dist="+travelPlane.evaluate(edge.startPoint)+"; end point travel dist="+travelPlane.evaluate(edge.endPoint));
+ System.out.println(
+ " start point travel above dist="+travelAbovePlane.evaluate(edge.startPoint)+"; end point travel above dist="+travelAbovePlane.evaluate(edge.endPoint));
+ System.out.println(
+ " start point travel below dist="+travelBelowPlane.evaluate(edge.startPoint)+"; end point travel below dist="+travelBelowPlane.evaluate(edge.endPoint));
+ System.out.println(
+ " start point testpoint dist="+testPointPlane.evaluate(edge.startPoint)+"; end point testpoint dist="+testPointPlane.evaluate(edge.endPoint));
+ System.out.println(
+ " start point testpoint above dist="+testPointAbovePlane.evaluate(edge.startPoint)+"; end point testpoint above dist="+testPointAbovePlane.evaluate(edge.endPoint));
+ System.out.println(
+ " start point testpoint below dist="+testPointBelowPlane.evaluate(edge.startPoint)+"; end point testpoint below dist="+testPointBelowPlane.evaluate(edge.endPoint));
+ */
// Determine crossings of this edge against all inside/outside planes. There's no further need to look at the actual travel plane itself.
final GeoPoint[] travelInnerCrossings = travelInsidePlane.findCrossings(planetModel, edge.plane, checkPointCutoffPlane, insideTravelCutoffPlane, edge.startPlane, edge.endPlane);
@@ -1294,13 +1318,13 @@ class GeoComplexPolygon extends GeoBasePolygon {
if (travelInnerCrossings != null) {
for (final GeoPoint crossing : travelInnerCrossings) {
- //System.out.println(" Travel inner point "+crossing);
+ //System.out.println(" Travel inner point "+crossing+"; edgeplane="+edge.plane.evaluate(crossing)+"; travelInsidePlane="+travelInsidePlane.evaluate(crossing)+"; edgestartplane="+edge.startPlane.evaluate(crossing)+"; edgeendplane="+edge.endPlane.evaluate(crossing));
countingHash.add(crossing);
}
}
if (testPointInnerCrossings != null) {
for (final GeoPoint crossing : testPointInnerCrossings) {
- //System.out.println(" Test point inner point "+crossing);
+ //System.out.println(" Test point inner point "+crossing+"; edgeplane="+edge.plane.evaluate(crossing)+"; testPointInsidePlane="+testPointInsidePlane.evaluate(crossing)+"; edgestartplane="+edge.startPlane.evaluate(crossing)+"; edgeendplane="+edge.endPlane.evaluate(crossing));
countingHash.add(crossing);
}
}
@@ -1310,13 +1334,13 @@ class GeoComplexPolygon extends GeoBasePolygon {
countingHash.clear();
if (travelOuterCrossings != null) {
for (final GeoPoint crossing : travelOuterCrossings) {
- //System.out.println(" Travel outer point "+crossing);
+ //System.out.println(" Travel outer point "+crossing+"; edgeplane="+edge.plane.evaluate(crossing)+"; travelOutsidePlane="+travelOutsidePlane.evaluate(crossing)+"; edgestartplane="+edge.startPlane.evaluate(crossing)+"; edgeendplane="+edge.endPlane.evaluate(crossing));
countingHash.add(crossing);
}
}
if (testPointOuterCrossings != null) {
for (final GeoPoint crossing : testPointOuterCrossings) {
- //System.out.println(" Test point outer point "+crossing);
+ //System.out.println(" Test point outer point "+crossing+"; edgeplane="+edge.plane.evaluate(crossing)+"; testPointOutsidePlane="+testPointOutsidePlane.evaluate(crossing)+"; edgestartplane="+edge.startPlane.evaluate(crossing)+"; edgeendplane="+edge.endPlane.evaluate(crossing));
countingHash.add(crossing);
}
}
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/9bd6d130/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/Plane.java
----------------------------------------------------------------------
diff --git a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/Plane.java b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/Plane.java
index 34a2fce..b47cffd 100755
--- a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/Plane.java
+++ b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/Plane.java
@@ -23,8 +23,9 @@ package org.apache.lucene.spatial3d.geom;
* @lucene.experimental
*/
public class Plane extends Vector {
- /** For plane envelopes, we need a small distance that can't lead to numerical confusion. */
- public final static double MINIMUM_PLANE_OFFSET = MINIMUM_RESOLUTION * 1.1;
+ /** For plane envelopes, we need a small distance that can't lead to numerical confusion. This spacing is large enough to
+ * avoid numerical confusion, but still permit all points within the envelope to belong to one or another plane. */
+ public final static double MINIMUM_PLANE_OFFSET = MINIMUM_RESOLUTION * 2.0;
/** An array with no points in it */
public final static GeoPoint[] NO_POINTS = new GeoPoint[0];
/** An array with no bounds in it */
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/9bd6d130/lucene/spatial3d/src/test/org/apache/lucene/spatial3d/geom/GeoPolygonTest.java
----------------------------------------------------------------------
diff --git a/lucene/spatial3d/src/test/org/apache/lucene/spatial3d/geom/GeoPolygonTest.java b/lucene/spatial3d/src/test/org/apache/lucene/spatial3d/geom/GeoPolygonTest.java
index d1e6688..ee2217d 100755
--- a/lucene/spatial3d/src/test/org/apache/lucene/spatial3d/geom/GeoPolygonTest.java
+++ b/lucene/spatial3d/src/test/org/apache/lucene/spatial3d/geom/GeoPolygonTest.java
@@ -1501,5 +1501,22 @@ shape:
final GeoPoint point = new GeoPoint(PlanetModel.SPHERE, Geo3DUtil.fromDegrees(-6.782152464351765E-11), Geo3DUtil.fromDegrees(91.60559215160585));
assertTrue(polygon.isWithin(point) == largePolygon.isWithin(point));
}
+
+ @Test
+ public void testLUCENE8245() {
+ //POLYGON((-70.19447784626787 -83.117346007187,0.0 2.8E-322,-139.99870438810106 7.994601469571884,-143.14292702670522 -18.500141088122664,-158.7373186858464 -35.42942085357812,-70.19447784626787 -83.117346007187))
+ final List<GeoPoint> points = new ArrayList<>();
+ points.add(new GeoPoint(PlanetModel.SPHERE, Geo3DUtil.fromDegrees(-83.117346007187), Geo3DUtil.fromDegrees(-70.19447784626787)));
+ points.add(new GeoPoint(PlanetModel.SPHERE, Geo3DUtil.fromDegrees(2.8E-322), Geo3DUtil.fromDegrees(0.0)));
+ points.add(new GeoPoint(PlanetModel.SPHERE, Geo3DUtil.fromDegrees(7.994601469571884), Geo3DUtil.fromDegrees(-139.99870438810106)));
+ points.add(new GeoPoint(PlanetModel.SPHERE, Geo3DUtil.fromDegrees(-18.500141088122664), Geo3DUtil.fromDegrees(-143.14292702670522)));
+ points.add(new GeoPoint(PlanetModel.SPHERE, Geo3DUtil.fromDegrees(-35.42942085357812), Geo3DUtil.fromDegrees(-158.7373186858464)));
+ final GeoPolygonFactory.PolygonDescription description = new GeoPolygonFactory.PolygonDescription(points);
+ final GeoPolygon polygon = GeoPolygonFactory.makeGeoPolygon(PlanetModel.SPHERE, description);
+ final GeoPolygon largePolygon = GeoPolygonFactory.makeLargeGeoPolygon(PlanetModel.SPHERE, Collections.singletonList(description));
+ //POINT(-1.91633079336513E-11 12.282452091883385)
+ final GeoPoint point = new GeoPoint(PlanetModel.SPHERE, Geo3DUtil.fromDegrees(12.282452091883385), Geo3DUtil.fromDegrees(-1.91633079336513E-11));
+ assertTrue(polygon.isWithin(point) == largePolygon.isWithin(point));
+ }
}
[2/2] lucene-solr:master: Merge branch 'master' of
https://git-wip-us.apache.org/repos/asf/lucene-solr
Posted by kw...@apache.org.
Merge branch 'master' of https://git-wip-us.apache.org/repos/asf/lucene-solr
Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/1cd85971
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/1cd85971
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/1cd85971
Branch: refs/heads/master
Commit: 1cd859713bda498fe295b2774fa74640d669882b
Parents: 9bd6d13 a12d398
Author: Karl Wright <Da...@gmail.com>
Authored: Mon Apr 9 20:13:23 2018 -0400
Committer: Karl Wright <Da...@gmail.com>
Committed: Mon Apr 9 20:13:23 2018 -0400
----------------------------------------------------------------------
dev-tools/maven/pom.xml.template | 1 -
lucene/CHANGES.txt | 17 ++
lucene/MIGRATE.txt | 6 +
.../icu/segmentation/TestICUTokenizerCJK.java | 2 +
.../lucene/index/FrozenBufferedUpdates.java | 3 +-
.../org/apache/lucene/index/IndexWriter.java | 9 +-
.../apache/lucene/index/PendingSoftDeletes.java | 23 ++-
.../SoftDeletesDirectoryReaderWrapper.java | 177 +++++++++++++++++
.../index/SoftDeletesRetentionMergePolicy.java | 33 +--
.../lucene/index/StandardDirectoryReader.java | 2 +-
.../org/apache/lucene/search/IndexSearcher.java | 22 +-
.../org/apache/lucene/search/QueryRescorer.java | 3 +-
.../org/apache/lucene/search/package-info.java | 4 +-
.../org/apache/lucene/index/TestAddIndexes.java | 81 ++++++++
.../lucene/index/TestDirectoryReaderReopen.java | 54 +++++
.../TestSoftDeletesDirectoryReaderWrapper.java | 199 +++++++++++++++++++
.../org/apache/lucene/index/TestStressNRT.java | 8 +-
.../TestApproximationSearchEquivalence.java | 30 ++-
.../org/apache/lucene/search/TestBooleanOr.java | 2 +-
.../apache/lucene/search/TestBooleanQuery.java | 18 +-
.../search/TestBooleanQueryVisitSubscorers.java | 6 +-
.../lucene/search/TestBooleanRewrites.java | 2 +-
.../apache/lucene/search/TestBooleanScorer.java | 12 +-
.../lucene/search/TestConstantScoreQuery.java | 10 +-
.../lucene/search/TestDisjunctionMaxQuery.java | 4 +-
.../lucene/search/TestDocValuesQueries.java | 2 +-
.../search/TestIndexOrDocValuesQuery.java | 4 +-
.../apache/lucene/search/TestLRUQueryCache.java | 6 +-
.../lucene/search/TestMinShouldMatch2.java | 2 +-
.../apache/lucene/search/TestPointQueries.java | 4 +-
.../lucene/search/TestReqOptSumScorer.java | 2 +-
.../lucene/search/TestSearcherManager.java | 2 +-
.../org/apache/lucene/search/TestTermQuery.java | 4 +-
.../apache/lucene/search/TestTermScorer.java | 10 +-
.../apache/lucene/search/TestTopDocsMerge.java | 2 +-
.../apache/lucene/search/TestWANDScorer.java | 14 +-
.../search/spans/TestNearSpansOrdered.java | 2 +-
.../apache/lucene/facet/DrillSidewaysQuery.java | 2 +-
.../facet/range/DoubleRangeFacetCounts.java | 2 +-
.../facet/range/LongRangeFacetCounts.java | 2 +-
.../lucene/search/grouping/GroupingSearch.java | 3 +-
.../lucene/search/grouping/TestGrouping.java | 5 +-
.../search/highlight/QueryTermExtractor.java | 2 +-
.../highlight/WeightedSpanTermExtractor.java | 4 +-
.../lucene/search/uhighlight/PhraseHelper.java | 2 +-
.../search/uhighlight/UnifiedHighlighter.java | 2 +-
.../lucene/search/join/QueryBitSetProducer.java | 3 +-
.../lucene/search/join/TestBlockJoin.java | 10 +-
.../search/join/TestBlockJoinValidation.java | 2 +-
.../apache/lucene/index/PKIndexSplitter.java | 3 +-
.../function/valuesource/QueryValueSource.java | 3 +-
.../function/TestIndexReaderFunctions.java | 4 +-
.../apache/lucene/payloads/PayloadSpanUtil.java | 3 +-
.../apache/lucene/index/RandomIndexWriter.java | 9 +-
.../org/apache/lucene/search/CheckHits.java | 16 +-
.../org/apache/lucene/search/QueryUtils.java | 19 +-
.../lucene/search/ShardSearchingTestBase.java | 3 +-
solr/CHANGES.txt | 8 +-
.../java/org/apache/solr/ltr/LTRRescorer.java | 6 +-
.../solr/ltr/feature/OriginalScoreFeature.java | 2 +-
.../apache/solr/ltr/feature/SolrFeature.java | 2 +-
.../apache/solr/ltr/TestLTRScoringQuery.java | 2 +-
.../solr/ltr/TestSelectiveWeightCreation.java | 2 +-
.../solr/response/GeoJSONResponseWriter.java | 3 +-
.../solr/response/JSONResponseWriter.java | 6 +-
.../apache/solr/search/QueryWrapperFilter.java | 3 +-
.../apache/solr/search/SolrIndexSearcher.java | 2 +-
.../apache/solr/search/ValueSourceParser.java | 3 +-
.../solr/search/function/EqualFunction.java | 61 ++++++
.../solr/search/stats/ExactStatsCache.java | 22 +-
.../apache/solr/response/JSONWriterTest.java | 24 ++-
.../TestSubQueryTransformerDistrib.java | 59 ++++--
.../solr/search/TestQueryWrapperFilter.java | 2 +-
.../solr/search/function/TestFunctionQuery.java | 78 ++++++++
solr/solr-ref-guide/src/function-queries.adoc | 3 +-
75 files changed, 973 insertions(+), 196 deletions(-)
----------------------------------------------------------------------