You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by th...@apache.org on 2016/04/14 01:21:17 UTC
[01/50] lucene-solr:jira/SOLR-8908: LUCENE-7184: update CHANGES.txt
Repository: lucene-solr
Updated Branches:
refs/heads/jira/SOLR-8908 146f00c1a -> c948a9058
LUCENE-7184: update CHANGES.txt
Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/455f3dd6
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/455f3dd6
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/455f3dd6
Branch: refs/heads/jira/SOLR-8908
Commit: 455f3dd694c431d9391a910d054d6a599dff59d4
Parents: eb87512
Author: nknize <nk...@apache.org>
Authored: Fri Apr 8 15:15:40 2016 -0500
Committer: nknize <nk...@apache.org>
Committed: Fri Apr 8 15:15:57 2016 -0500
----------------------------------------------------------------------
lucene/CHANGES.txt | 4 ++++
1 file changed, 4 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/455f3dd6/lucene/CHANGES.txt
----------------------------------------------------------------------
diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txt
index d0a16d7..8209415 100644
--- a/lucene/CHANGES.txt
+++ b/lucene/CHANGES.txt
@@ -18,6 +18,10 @@ New Features
API Changes
+* LUCENE-7184: Refactor LatLonPoint encoding methods to new GeoEncodingUtils
+ helper class in core geo package. Also refactors LatLonPointTests to
+ TestGeoEncodingUtils (Nick Knize)
+
* LUCENE-7163: refactor GeoRect, Polygon, and GeoUtils tests to geo
package in core (Nick Knize)
[28/50] lucene-solr:jira/SOLR-8908: LUCENE-7203: Fix the javadoc
broken in the previous commit.
Posted by th...@apache.org.
LUCENE-7203: Fix the javadoc broken in the previous commit.
Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/a3ee984b
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/a3ee984b
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/a3ee984b
Branch: refs/heads/jira/SOLR-8908
Commit: a3ee984bc824f4d2a6ac69b4dd0069b92568f3af
Parents: 91f74ee
Author: Karl Wright <Da...@gmail.com>
Authored: Tue Apr 12 06:05:22 2016 -0400
Committer: Karl Wright <Da...@gmail.com>
Committed: Tue Apr 12 06:05:22 2016 -0400
----------------------------------------------------------------------
.../java/org/apache/lucene/spatial3d/geom/GeoConcavePolygon.java | 3 ++-
.../java/org/apache/lucene/spatial3d/geom/GeoConvexPolygon.java | 3 ++-
2 files changed, 4 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/a3ee984b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoConcavePolygon.java
----------------------------------------------------------------------
diff --git a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoConcavePolygon.java b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoConcavePolygon.java
index 518df33..995e191 100644
--- a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoConcavePolygon.java
+++ b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoConcavePolygon.java
@@ -318,7 +318,8 @@ class GeoConcavePolygon extends GeoBasePolygon {
protected final SidedPlane sideBound2;
/** Constructor.
- * @param exception is the one plane to exclude from the check.
+ * @param sideBound1 is the first side bound.
+ * @param sideBound2 is the second side bound.
*/
public EitherBound(final SidedPlane sideBound1, final SidedPlane sideBound2) {
this.sideBound1 = sideBound1;
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/a3ee984b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoConvexPolygon.java
----------------------------------------------------------------------
diff --git a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoConvexPolygon.java b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoConvexPolygon.java
index 4cc8177..dd5971f 100755
--- a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoConvexPolygon.java
+++ b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoConvexPolygon.java
@@ -304,7 +304,8 @@ class GeoConvexPolygon extends GeoBasePolygon {
protected final SidedPlane sideBound2;
/** Constructor.
- * @param exception is the one plane to exclude from the check.
+ * @param sideBound1 is the first side bound.
+ * @param sideBound2 is the second side bound.
*/
public EitherBound(final SidedPlane sideBound1, final SidedPlane sideBound2) {
this.sideBound1 = sideBound1;
[18/50] lucene-solr:jira/SOLR-8908: SOLR-8967: UI should not show the
replication tab in the core selector panel in cloud mode
Posted by th...@apache.org.
SOLR-8967: UI should not show the replication tab in the core selector panel in cloud mode
Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/812c8da0
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/812c8da0
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/812c8da0
Branch: refs/heads/jira/SOLR-8908
Commit: 812c8da0138fc8e3f781ded2bb5235ef4d4eafda
Parents: 739c752
Author: Varun Thacker <va...@gmail.com>
Authored: Mon Apr 11 17:17:03 2016 +0530
Committer: Varun Thacker <va...@gmail.com>
Committed: Mon Apr 11 17:17:55 2016 +0530
----------------------------------------------------------------------
solr/CHANGES.txt | 3 +++
solr/webapp/web/index.html | 2 +-
2 files changed, 4 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/812c8da0/solr/CHANGES.txt
----------------------------------------------------------------------
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index b0047a1..0b98fa0 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -148,6 +148,9 @@ Other Changes
* SOLR-8097: Implement builder pattern design for constructing SolrJ clients and also deprecate direct construction
of client objects. (Jason Gerlowski, Shawn Heisey, Anshum Gupta)
+* SOLR-8967: In SolrCloud mode, under the 'Core Selector' dropdown in the UI the Replication tab won't be displayed
+ anymore. The Replication tab is only beneficial to users running Solr in master-slave mode. (Varun Thacker)
+
================== 6.0.0 ==================
Consult the LUCENE_CHANGES.txt file for additional, low level, changes in this release
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/812c8da0/solr/webapp/web/index.html
----------------------------------------------------------------------
diff --git a/solr/webapp/web/index.html b/solr/webapp/web/index.html
index 6c4df6a..a8567a5 100644
--- a/solr/webapp/web/index.html
+++ b/solr/webapp/web/index.html
@@ -209,7 +209,7 @@ limitations under the License.
<li class="ping" ng-class="{active:page=='ping'}"><a ng-click="ping()"><span>Ping</span><small class="qtime" ng-show="pingMS"> (<span>{{pingMS}}ms</span>)</small></a></li>
<li class="plugins" ng-class="{active:page=='plugins'}"><a href="#/{{currentCore.name}}/plugins"><span>Plugins / Stats</span></a></li>
<li ng-hide="isCloudEnabled" class="query" ng-class="{active:page=='query'}"><a href="#/{{currentCore.name}}/query"><span>Query</span></a></li>
- <li class="replication" ng-class="{active:page=='replication'}"><a href="#/{{currentCore.name}}/replication"><span>Replication</span></a></li>
+ <li ng-hide="isCloudEnabled" class="replication" ng-class="{active:page=='replication'}"><a href="#/{{currentCore.name}}/replication"><span>Replication</span></a></li>
<li ng-hide="isCloudEnabled" class="schema" ng-class="{active:page=='schema'}"><a href="#/{{currentCore.name}}/schema"><span>Schema</span></a></li>
<li class="segments" ng-class="{active:page=='segments'}"><a href="#/{{currentCore.name}}/segments"><span>Segments info</span></a></li>
</ul>
[05/50] lucene-solr:jira/SOLR-8908: LUCENE-7197: Fix two test
failures and add more forensics that helped resolve the issue.
Posted by th...@apache.org.
LUCENE-7197: Fix two test failures and add more forensics that helped resolve the issue.
Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/d377e7fd
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/d377e7fd
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/d377e7fd
Branch: refs/heads/jira/SOLR-8908
Commit: d377e7fd34b4ace829ee6d4ba0486500aaef506b
Parents: 4d3a633
Author: Karl Wright <Da...@gmail.com>
Authored: Sat Apr 9 16:12:39 2016 -0400
Committer: Karl Wright <Da...@gmail.com>
Committed: Sat Apr 9 16:12:39 2016 -0400
----------------------------------------------------------------------
.../spatial3d/geom/GeoConcavePolygon.java | 10 ++++----
.../lucene/spatial3d/geom/GeoConvexPolygon.java | 1 +
.../apache/lucene/spatial3d/geom/GeoPoint.java | 2 +-
.../spatial3d/geom/GeoPolygonFactory.java | 12 ++++++++--
.../lucene/spatial3d/geom/PlanetModel.java | 25 ++++++++++++++++++++
.../lucene/spatial3d/geom/StandardXYZSolid.java | 18 +++++++++++++-
.../apache/lucene/spatial3d/TestGeo3DPoint.java | 25 +++++++++++++++-----
7 files changed, 78 insertions(+), 15 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/d377e7fd/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoConcavePolygon.java
----------------------------------------------------------------------
diff --git a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoConcavePolygon.java b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoConcavePolygon.java
index 05e58ee..8c6f757 100644
--- a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoConcavePolygon.java
+++ b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoConcavePolygon.java
@@ -202,11 +202,9 @@ class GeoConcavePolygon extends GeoBasePolygon {
throw new IllegalArgumentException("Polygon points are all coplanar");
}
final GeoPoint check = points.get(endPointIndex);
- // Here note the flip of the sense of the sided plane!!
- final SidedPlane sp = new SidedPlane(check, false, start, end);
//System.out.println("Created edge "+sp+" using start="+start+" end="+end+" check="+check);
- edges[i] = sp;
- invertedEdges[i] = new SidedPlane(sp);
+ edges[i] = new SidedPlane(check, false, start, end);
+ invertedEdges[i] = new SidedPlane(edges[i]);
notableEdgePoints[i] = new GeoPoint[]{start, end};
}
// In order to naively confirm that the polygon is concave, I would need to
@@ -277,9 +275,11 @@ class GeoConcavePolygon extends GeoBasePolygon {
// cannot use them as bounds. They are independent hemispheres.
for (int edgeIndex = 0; edgeIndex < edges.length; edgeIndex++) {
final SidedPlane edge = edges[edgeIndex];
+ final SidedPlane invertedEdge = invertedEdges[edgeIndex];
final GeoPoint[] points = this.notableEdgePoints[edgeIndex];
if (!isInternalEdges.get(edgeIndex)) {
- if (edge.intersects(planetModel, p, notablePoints, points, bounds, eitherBounds.get(edge))) {
+ //System.err.println("Checking concave edge "+edge+" for intersection against plane "+p);
+ if (invertedEdge.intersects(planetModel, p, notablePoints, points, bounds, eitherBounds.get(edge))) {
//System.err.println(" intersects!");
return true;
}
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/d377e7fd/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoConvexPolygon.java
----------------------------------------------------------------------
diff --git a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoConvexPolygon.java b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoConvexPolygon.java
index d1e0091..b631b55 100755
--- a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoConvexPolygon.java
+++ b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoConvexPolygon.java
@@ -265,6 +265,7 @@ class GeoConvexPolygon extends GeoBasePolygon {
final SidedPlane edge = edges[edgeIndex];
final GeoPoint[] points = this.notableEdgePoints[edgeIndex];
if (!isInternalEdges.get(edgeIndex)) {
+ //System.err.println("Checking convex edge "+edge+" for intersection against plane "+p);
if (edge.intersects(planetModel, p, notablePoints, points, bounds, eitherBounds.get(edge))) {
//System.err.println(" intersects!");
return true;
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/d377e7fd/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoPoint.java
----------------------------------------------------------------------
diff --git a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoPoint.java b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoPoint.java
index 31ab0aa..662a056 100755
--- a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoPoint.java
+++ b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoPoint.java
@@ -188,6 +188,6 @@ public class GeoPoint extends Vector {
if (this.longitude == Double.NEGATIVE_INFINITY) {
return super.toString();
}
- return "[lat="+getLatitude()+", lon="+getLongitude()+"]";
+ return "[lat="+getLatitude()+", lon="+getLongitude()+"("+super.toString()+")]";
}
}
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/d377e7fd/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoPolygonFactory.java
----------------------------------------------------------------------
diff --git a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoPolygonFactory.java b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoPolygonFactory.java
index a68f908..7fc22dd 100755
--- a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoPolygonFactory.java
+++ b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoPolygonFactory.java
@@ -395,6 +395,7 @@ public class GeoPolygonFactory {
if (confirmEdge == checkEdge) {
continue;
}
+ // Look for a point that is on the wrong side of the check edge. This means that we can't build the polygon.
final GeoPoint thePoint;
if (checkEdge.startPoint != confirmEdge.startPoint && checkEdge.endPoint != confirmEdge.startPoint && !flippedPlane.isWithin(confirmEdge.startPoint)) {
thePoint = confirmEdge.startPoint;
@@ -404,7 +405,11 @@ public class GeoPolygonFactory {
thePoint = null;
}
if (thePoint != null) {
- // Found a split!!
+ // thePoint is on the wrong side of the complementary plane. That means we cannot build a concave polygon, because the complement would not
+ // be a legal convex polygon.
+ // But we can take advantage of the fact that the distance between the edge and thePoint is less than 180 degrees, and so we can split the
+ // would-be concave polygon into three segments. The first segment includes the edge and thePoint, and uses the sense of the edge to determine the sense
+ // of the polygon.
// This should be the only problematic part of the polygon.
// We know that thePoint is on the "wrong" side of the edge -- that is, it's on the side that the
@@ -431,6 +436,8 @@ public class GeoPolygonFactory {
}
//System.out.println("...done convex part.");
+ // ??? check if we get the sense right
+
// The part preceding the bad edge, back to thePoint, needs to be recursively
// processed. So, assemble what we need, which is basically a list of edges.
Edge loopEdge = edgeBuffer.getPrevious(checkEdge);
@@ -459,6 +466,7 @@ public class GeoPolygonFactory {
return false;
}
//System.out.println("...done first part.");
+
final List<GeoPoint> secondPartPoints = new ArrayList<>();
final BitSet secondPartInternal = new BitSet();
loopEdge = edgeBuffer.getNext(checkEdge);
@@ -479,7 +487,7 @@ public class GeoPolygonFactory {
secondPartInternal,
secondPartPoints.size()-1,
0,
- new SidedPlane(checkEdge.endPoint, true, checkEdge.startPoint, thePoint),
+ new SidedPlane(checkEdge.startPoint, false, checkEdge.endPoint, thePoint),
holes,
testPoint) == false) {
return false;
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/d377e7fd/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/PlanetModel.java
----------------------------------------------------------------------
diff --git a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/PlanetModel.java b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/PlanetModel.java
index c7d45a8..f5ab8d8 100644
--- a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/PlanetModel.java
+++ b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/PlanetModel.java
@@ -189,6 +189,31 @@ public class PlanetModel {
return (x * x + y * y) * inverseAb * inverseAb + z * z * inverseC * inverseC - 1.0 > Vector.MINIMUM_RESOLUTION;
}
+ /** Compute a GeoPoint that's scaled to actually be on the planet surface.
+ * @param vector is the vector.
+ * @return the scaled point.
+ */
+ public GeoPoint createSurfacePoint(final Vector vector) {
+ return createSurfacePoint(vector.x, vector.y, vector.z);
+ }
+
+ /** Compute a GeoPoint that's based on (x,y,z) values, but is scaled to actually be on the planet surface.
+ * @param x is the x value.
+ * @param y is the y value.
+ * @param z is the z value.
+ * @return the scaled point.
+ */
+ public GeoPoint createSurfacePoint(final double x, final double y, final double z) {
+ // The equation of the surface is:
+ // (x^2 / a^2 + y^2 / b^2 + z^2 / c^2) = 1
+ // We will need to scale the passed-in x, y, z values:
+ // ((tx)^2 / a^2 + (ty)^2 / b^2 + (tz)^2 / c^2) = 1
+ // t^2 * (x^2 / a^2 + y^2 / b^2 + z^2 / c^2) = 1
+ // t = sqrt ( 1 / (x^2 / a^2 + y^2 / b^2 + z^2 / c^2))
+ final double t = Math.sqrt(1.0 / (x*x*inverseAbSquared + y*y*inverseAbSquared + z*z*inverseCSquared));
+ return new GeoPoint(t*x, t*y, t*z);
+ }
+
/** Compute a GeoPoint that's a bisection between two other GeoPoints.
* @param pt1 is the first point.
* @param pt2 is the second point.
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/d377e7fd/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/StandardXYZSolid.java
----------------------------------------------------------------------
diff --git a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/StandardXYZSolid.java b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/StandardXYZSolid.java
index ec2e26c..9d94c51 100644
--- a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/StandardXYZSolid.java
+++ b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/StandardXYZSolid.java
@@ -16,6 +16,8 @@
*/
package org.apache.lucene.spatial3d.geom;
+import java.util.Arrays;
+
/**
* 3D rectangle, bounded on six sides by X,Y,Z limits
*
@@ -152,6 +154,11 @@ class StandardXYZSolid extends BaseXYZSolid {
notableMinZPoints = glueTogether(minXminZ, maxXminZ, minYminZ, maxYminZ);
notableMaxZPoints = glueTogether(minXmaxZ, maxXmaxZ, minYmaxZ, maxYmaxZ);
+ //System.err.println(
+ // " notableMinXPoints="+Arrays.asList(notableMinXPoints)+" notableMaxXPoints="+Arrays.asList(notableMaxXPoints)+
+ // " notableMinYPoints="+Arrays.asList(notableMinYPoints)+" notableMaxYPoints="+Arrays.asList(notableMaxYPoints)+
+ // " notableMinZPoints="+Arrays.asList(notableMinZPoints)+" notableMaxZPoints="+Arrays.asList(notableMaxZPoints));
+
// Now, compute the edge points.
// This is the trickiest part of setting up an XYZSolid. We've computed intersections already, so
// we'll start there.
@@ -173,7 +180,11 @@ class StandardXYZSolid extends BaseXYZSolid {
final boolean maxXminYmaxZ = planetModel.pointOutside(maxX, minY, maxZ);
final boolean maxXmaxYminZ = planetModel.pointOutside(maxX, maxY, minZ);
final boolean maxXmaxYmaxZ = planetModel.pointOutside(maxX, maxY, maxZ);
-
+
+ //System.err.println("Outside world: minXminYminZ="+minXminYminZ+" minXminYmaxZ="+minXminYmaxZ+" minXmaxYminZ="+minXmaxYminZ+
+ // " minXmaxYmaxZ="+minXmaxYmaxZ+" maxXminYminZ="+maxXminYminZ+" maxXminYmaxZ="+maxXminYmaxZ+" maxXmaxYminZ="+maxXmaxYminZ+
+ // " maxXmaxYmaxZ="+maxXmaxYmaxZ);
+
// Look at single-plane/world intersections.
// We detect these by looking at the world model and noting its x, y, and z bounds.
@@ -286,6 +297,11 @@ class StandardXYZSolid extends BaseXYZSolid {
maxZEdges = EMPTY_POINTS;
}
+ //System.err.println(
+ // " minXEdges="+Arrays.asList(minXEdges)+" maxXEdges="+Arrays.asList(maxXEdges)+
+ // " minYEdges="+Arrays.asList(minYEdges)+" maxYEdges="+Arrays.asList(maxYEdges)+
+ // " minZEdges="+Arrays.asList(minZEdges)+" maxZEdges="+Arrays.asList(maxZEdges));
+
// Glue everything together. This is not a minimal set of edgepoints, as of now, but it does completely describe all shapes on the
// planet.
this.edgePoints = glueTogether(minXminY, minXmaxY, minXminZ, minXmaxZ,
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/d377e7fd/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 4edfd2d..5c876ce 100644
--- a/lucene/spatial3d/src/test/org/apache/lucene/spatial3d/TestGeo3DPoint.java
+++ b/lucene/spatial3d/src/test/org/apache/lucene/spatial3d/TestGeo3DPoint.java
@@ -782,6 +782,7 @@ public class TestGeo3DPoint extends LuceneTestCase {
if (point != null) {
boolean expected = ((deleted.contains(id) == false) && ((PointInGeo3DShapeQuery)query).getShape().isWithin(point));
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");
@@ -789,10 +790,14 @@ public class TestGeo3DPoint extends LuceneTestCase {
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(" 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, r, docID).replace("\n", "\n "));
+ b.append(" explanation:\n " + explain("point", ((PointInGeo3DShapeQuery)query).getShape(), point, scaledPoint, r, docID).replace("\n", "\n "));
fail(b.toString());
}
} else {
@@ -810,7 +815,7 @@ public class TestGeo3DPoint extends LuceneTestCase {
}
public void testShapeQueryToString() {
- assertEquals("PointInGeo3DShapeQuery: field=point: Shape: GeoStandardCircle: {planetmodel=PlanetModel.WGS84, center=[lat=0.7722082215479366, lon=0.13560747521073413], radius=0.1(5.729577951308232)}",
+ assertEquals("PointInGeo3DShapeQuery: field=point: Shape: GeoStandardCircle: {planetmodel=PlanetModel.WGS84, center=[lat=0.7722082215479366, lon=0.13560747521073413([X=0.7094263130137863, Y=0.09679758930862137, Z=0.6973564619248455])], radius=0.1(5.729577951308232)}",
Geo3DPoint.newShapeQuery("point", GeoCircleFactory.makeGeoCircle(PlanetModel.WGS84, toRadians(44.244272), toRadians(7.769736), 0.1)).toString());
}
@@ -1171,6 +1176,7 @@ public class TestGeo3DPoint extends LuceneTestCase {
final GeoShape shape;
final GeoPoint targetDocPoint;
+ final GeoPoint scaledDocPoint;
final IntersectVisitor in;
final List<Cell> stack = new ArrayList<>();
private List<Cell> stackToTargetDoc;
@@ -1183,9 +1189,10 @@ public class TestGeo3DPoint extends LuceneTestCase {
// In the first phase, we always return CROSSES to do a full scan of the BKD tree to see which leaf block the document lives in
boolean firstPhase = true;
- public ExplainingVisitor(GeoShape shape, GeoPoint targetDocPoint, IntersectVisitor in, int targetDocID, int numDims, int bytesPerDim, StringBuilder b) {
+ public ExplainingVisitor(GeoShape shape, GeoPoint targetDocPoint, GeoPoint scaledDocPoint, IntersectVisitor in, int targetDocID, int numDims, int bytesPerDim, StringBuilder b) {
this.shape = shape;
this.targetDocPoint = targetDocPoint;
+ this.scaledDocPoint = scaledDocPoint;
this.in = in;
this.targetDocID = targetDocID;
this.numDims = numDims;
@@ -1302,6 +1309,9 @@ public class TestGeo3DPoint extends LuceneTestCase {
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;
switch (relationship) {
case GeoArea.CONTAINS:
@@ -1320,7 +1330,10 @@ public class TestGeo3DPoint extends LuceneTestCase {
relationshipString = "UNKNOWN";
break;
}
- 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;
+ 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;
}
@Override
@@ -1340,7 +1353,7 @@ public class TestGeo3DPoint extends LuceneTestCase {
}
}
- public static String explain(String fieldName, GeoShape shape, GeoPoint targetDocPoint, IndexReader reader, int docID) throws Exception {
+ public static String explain(String fieldName, GeoShape shape, GeoPoint targetDocPoint, GeoPoint scaledDocPoint, IndexReader reader, int docID) throws Exception {
// First find the leaf reader that owns this doc:
int subIndex = ReaderUtil.subIndex(docID, reader.leaves());
@@ -1350,7 +1363,7 @@ public class TestGeo3DPoint extends LuceneTestCase {
b.append("target is in leaf " + leafReader + " of full reader " + reader + "\n");
DocIdSetBuilder hits = new DocIdSetBuilder(leafReader.maxDoc());
- ExplainingVisitor visitor = new ExplainingVisitor(shape, targetDocPoint, new PointInShapeIntersectVisitor(hits, shape), docID - reader.leaves().get(subIndex).docBase, 3, Integer.BYTES, b);
+ ExplainingVisitor visitor = new ExplainingVisitor(shape, targetDocPoint, scaledDocPoint, new PointInShapeIntersectVisitor(hits, shape), docID - reader.leaves().get(subIndex).docBase, 3, Integer.BYTES, b);
// Do first phase, where we just figure out the "path" that leads to the target docID:
leafReader.getPointValues().intersect(fieldName, visitor);
[25/50] lucene-solr:jira/SOLR-8908: LUCENE-7188: remove incorrect
sanity check in NRTCachingDirectory.listAll() that throws
IllegalStateException
Posted by th...@apache.org.
LUCENE-7188: remove incorrect sanity check in NRTCachingDirectory.listAll() that throws IllegalStateException
Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/c1a70f31
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/c1a70f31
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/c1a70f31
Branch: refs/heads/jira/SOLR-8908
Commit: c1a70f31a605ac254c4c5d556444659aaa3201e5
Parents: 10c7757
Author: yonik <yo...@apache.org>
Authored: Mon Apr 11 23:51:41 2016 -0400
Committer: yonik <yo...@apache.org>
Committed: Mon Apr 11 23:51:41 2016 -0400
----------------------------------------------------------------------
lucene/CHANGES.txt | 4 ++++
.../src/java/org/apache/lucene/store/NRTCachingDirectory.java | 5 +----
2 files changed, 5 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/c1a70f31/lucene/CHANGES.txt
----------------------------------------------------------------------
diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txt
index 6b549f2..e371f25 100644
--- a/lucene/CHANGES.txt
+++ b/lucene/CHANGES.txt
@@ -76,6 +76,10 @@ Bug Fixes
* LUCENE-7187: Block join queries' Weight#extractTerms(...) implementations
should delegate to the wrapped weight. (Martijn van Groningen)
+* LUCENE-7188: remove incorrect sanity check in NRTCachingDirectory.listAll()
+ that led to IllegalStateException being thrown when nothing was wrong.
+ (David Smiley, yonik)
+
Other
* LUCENE-7174: Upgrade randomizedtesting to 2.3.4. (Uwe Schindler, Dawid Weiss)
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/c1a70f31/lucene/core/src/java/org/apache/lucene/store/NRTCachingDirectory.java
----------------------------------------------------------------------
diff --git a/lucene/core/src/java/org/apache/lucene/store/NRTCachingDirectory.java b/lucene/core/src/java/org/apache/lucene/store/NRTCachingDirectory.java
index 22a9571..9be0b9e 100644
--- a/lucene/core/src/java/org/apache/lucene/store/NRTCachingDirectory.java
+++ b/lucene/core/src/java/org/apache/lucene/store/NRTCachingDirectory.java
@@ -101,10 +101,7 @@ public class NRTCachingDirectory extends FilterDirectory implements Accountable
files.add(f);
}
for(String f : in.listAll()) {
- if (!files.add(f)) {
- throw new IllegalStateException("file: " + in + " appears both in delegate and in cache: " +
- "cache=" + Arrays.toString(cache.listAll()) + ",delegate=" + Arrays.toString(in.listAll()));
- }
+ files.add(f);
}
String[] result = files.toArray(new String[files.size()]);
Arrays.sort(result);
[32/50] lucene-solr:jira/SOLR-8908: Merge branch 'master' of
https://git-wip-us.apache.org/repos/asf/lucene-solr
Posted by th...@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/9a150920
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/9a150920
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/9a150920
Branch: refs/heads/jira/SOLR-8908
Commit: 9a150920a6d1a64b2661e3766f0307d168145581
Parents: 414bdea 8f5ef07
Author: Karl Wright <Da...@gmail.com>
Authored: Tue Apr 12 15:37:47 2016 -0400
Committer: Karl Wright <Da...@gmail.com>
Committed: Tue Apr 12 15:37:47 2016 -0400
----------------------------------------------------------------------
.../org/apache/lucene/spatial/util/BaseGeoPointTestCase.java | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
[13/50] lucene-solr:jira/SOLR-8908: LUCENE-7196 - guaranteed class
coverage in split indexes through grouping by class
Posted by th...@apache.org.
LUCENE-7196 - guaranteed class coverage in split indexes through grouping by class
Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/112078ea
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/112078ea
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/112078ea
Branch: refs/heads/jira/SOLR-8908
Commit: 112078eaf909bdda27a092d13a8431c046a82ac0
Parents: d7867b8
Author: Tommaso Teofili <to...@apache.org>
Authored: Fri Apr 8 16:59:41 2016 +0200
Committer: Tommaso Teofili <to...@apache.org>
Committed: Mon Apr 11 09:59:22 2016 +0200
----------------------------------------------------------------------
lucene/classification/build.xml | 6 +-
.../classification/utils/DatasetSplitter.java | 126 +++++++++++++------
.../classification/utils/DataSplitterTest.java | 33 ++---
3 files changed, 106 insertions(+), 59 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/112078ea/lucene/classification/build.xml
----------------------------------------------------------------------
diff --git a/lucene/classification/build.xml b/lucene/classification/build.xml
index 930b1fa..fd15239 100644
--- a/lucene/classification/build.xml
+++ b/lucene/classification/build.xml
@@ -27,6 +27,7 @@
<path id="classpath">
<path refid="base.classpath"/>
<pathelement path="${queries.jar}"/>
+ <pathelement path="${grouping.jar}"/>
</path>
<path id="test.classpath">
@@ -35,15 +36,16 @@
<path refid="test.base.classpath"/>
</path>
- <target name="compile-core" depends="jar-queries,jar-analyzers-common,common.compile-core" />
+ <target name="compile-core" depends="jar-grouping,jar-queries,jar-analyzers-common,common.compile-core" />
<target name="jar-core" depends="common.jar-core" />
- <target name="javadocs" depends="javadocs-queries,compile-core,check-javadocs-uptodate"
+ <target name="javadocs" depends="javadocs-grouping,javadocs-misc,compile-core,check-javadocs-uptodate"
unless="javadocs-uptodate-${name}">
<invoke-module-javadoc>
<links>
<link href="../queries"/>
+ <link href="../group"/>
</links>
</invoke-module-javadoc>
</target>
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/112078ea/lucene/classification/src/java/org/apache/lucene/classification/utils/DatasetSplitter.java
----------------------------------------------------------------------
diff --git a/lucene/classification/src/java/org/apache/lucene/classification/utils/DatasetSplitter.java b/lucene/classification/src/java/org/apache/lucene/classification/utils/DatasetSplitter.java
index 0b03b94..fce786b 100644
--- a/lucene/classification/src/java/org/apache/lucene/classification/utils/DatasetSplitter.java
+++ b/lucene/classification/src/java/org/apache/lucene/classification/utils/DatasetSplitter.java
@@ -18,6 +18,7 @@ package org.apache.lucene.classification.utils;
import java.io.IOException;
+import java.util.HashMap;
import org.apache.lucene.analysis.Analyzer;
import org.apache.lucene.document.Document;
@@ -28,11 +29,16 @@ import org.apache.lucene.index.IndexWriter;
import org.apache.lucene.index.IndexWriterConfig;
import org.apache.lucene.index.IndexableField;
import org.apache.lucene.index.LeafReader;
+import org.apache.lucene.index.Terms;
import org.apache.lucene.search.IndexSearcher;
import org.apache.lucene.search.MatchAllDocsQuery;
import org.apache.lucene.search.ScoreDoc;
-import org.apache.lucene.search.TopDocs;
+import org.apache.lucene.search.Sort;
+import org.apache.lucene.search.grouping.GroupDocs;
+import org.apache.lucene.search.grouping.GroupingSearch;
+import org.apache.lucene.search.grouping.TopGroups;
import org.apache.lucene.store.Directory;
+import org.apache.lucene.uninverting.UninvertingReader;
/**
* Utility class for creating training / test / cross validation indexes from the original index.
@@ -61,67 +67,78 @@ public class DatasetSplitter {
* @param testIndex a {@link Directory} used to write the test index
* @param crossValidationIndex a {@link Directory} used to write the cross validation index
* @param analyzer {@link Analyzer} used to create the new docs
+ * @param termVectors {@code true} if term vectors should be kept
+ * @param classFieldName names of the field used as the label for classification
* @param fieldNames names of fields that need to be put in the new indexes or <code>null</code> if all should be used
* @throws IOException if any writing operation fails on any of the indexes
*/
public void split(LeafReader originalIndex, Directory trainingIndex, Directory testIndex, Directory crossValidationIndex,
- Analyzer analyzer, String... fieldNames) throws IOException {
+ Analyzer analyzer, boolean termVectors, String classFieldName, String... fieldNames) throws IOException {
// create IWs for train / test / cv IDXs
IndexWriter testWriter = new IndexWriter(testIndex, new IndexWriterConfig(analyzer));
IndexWriter cvWriter = new IndexWriter(crossValidationIndex, new IndexWriterConfig(analyzer));
IndexWriter trainingWriter = new IndexWriter(trainingIndex, new IndexWriterConfig(analyzer));
+ // try to get the exact no. of existing classes
+ Terms terms = originalIndex.terms(classFieldName);
+ long noOfClasses = -1;
+ if (terms != null) {
+ noOfClasses = terms.size();
+
+ }
+ if (noOfClasses == -1) {
+ noOfClasses = 10000; // fallback
+ }
+
+ HashMap<String, UninvertingReader.Type> mapping = new HashMap<>();
+ mapping.put(classFieldName, UninvertingReader.Type.SORTED);
+ UninvertingReader uninvertingReader = new UninvertingReader(originalIndex, mapping);
+
try {
- int size = originalIndex.maxDoc();
- IndexSearcher indexSearcher = new IndexSearcher(originalIndex);
- TopDocs topDocs = indexSearcher.search(new MatchAllDocsQuery(), Integer.MAX_VALUE);
+ IndexSearcher indexSearcher = new IndexSearcher(uninvertingReader);
+ GroupingSearch gs = new GroupingSearch(classFieldName);
+ gs.setGroupSort(Sort.INDEXORDER);
+ gs.setSortWithinGroup(Sort.INDEXORDER);
+ gs.setAllGroups(true);
+ gs.setGroupDocsLimit(originalIndex.maxDoc());
+ TopGroups<Object> topGroups = gs.search(indexSearcher, new MatchAllDocsQuery(), 0, (int) noOfClasses);
// set the type to be indexed, stored, with term vectors
FieldType ft = new FieldType(TextField.TYPE_STORED);
- ft.setStoreTermVectors(true);
- ft.setStoreTermVectorOffsets(true);
- ft.setStoreTermVectorPositions(true);
+ if (termVectors) {
+ ft.setStoreTermVectors(true);
+ ft.setStoreTermVectorOffsets(true);
+ ft.setStoreTermVectorPositions(true);
+ }
int b = 0;
// iterate over existing documents
- for (ScoreDoc scoreDoc : topDocs.scoreDocs) {
-
- // create a new document for indexing
- Document doc = new Document();
- Document document = originalIndex.document(scoreDoc.doc);
- if (fieldNames != null && fieldNames.length > 0) {
- for (String fieldName : fieldNames) {
- IndexableField field = document.getField(fieldName);
- if (field != null) {
- doc.add(new Field(fieldName, field.stringValue(), ft));
- }
+ for (GroupDocs group : topGroups.groups) {
+ int totalHits = group.totalHits;
+ double testSize = totalHits * testRatio;
+ int tc = 0;
+ double cvSize = totalHits * crossValidationRatio;
+ int cvc = 0;
+ for (ScoreDoc scoreDoc : group.scoreDocs) {
+
+ // create a new document for indexing
+ Document doc = createNewDoc(originalIndex, ft, scoreDoc, fieldNames);
+
+ // add it to one of the IDXs
+ if (b % 2 == 0 && tc < testSize) {
+ testWriter.addDocument(doc);
+ tc++;
+ } else if (cvc < cvSize) {
+ cvWriter.addDocument(doc);
+ cvc++;
+ } else {
+ trainingWriter.addDocument(doc);
}
- } else {
- for (IndexableField field : document.getFields()) {
- if (field.readerValue() != null) {
- doc.add(new Field(field.name(), field.readerValue(), ft));
- } else if (field.binaryValue() != null) {
- doc.add(new Field(field.name(), field.binaryValue(), ft));
- } else if (field.stringValue() != null) {
- doc.add(new Field(field.name(), field.stringValue(), ft));
- } else if (field.numericValue() != null) {
- doc.add(new Field(field.name(), field.numericValue().toString(), ft));
- }
- }
- }
-
- // add it to one of the IDXs
- if (b % 2 == 0 && testWriter.maxDoc() < size * testRatio) {
- testWriter.addDocument(doc);
- } else if (cvWriter.maxDoc() < size * crossValidationRatio) {
- cvWriter.addDocument(doc);
- } else {
- trainingWriter.addDocument(doc);
+ b++;
}
- b++;
}
// commit
testWriter.commit();
@@ -139,7 +156,34 @@ public class DatasetSplitter {
testWriter.close();
cvWriter.close();
trainingWriter.close();
+ uninvertingReader.close();
+ }
+ }
+
+ private Document createNewDoc(LeafReader originalIndex, FieldType ft, ScoreDoc scoreDoc, String[] fieldNames) throws IOException {
+ Document doc = new Document();
+ Document document = originalIndex.document(scoreDoc.doc);
+ if (fieldNames != null && fieldNames.length > 0) {
+ for (String fieldName : fieldNames) {
+ IndexableField field = document.getField(fieldName);
+ if (field != null) {
+ doc.add(new Field(fieldName, field.stringValue(), ft));
+ }
+ }
+ } else {
+ for (IndexableField field : document.getFields()) {
+ if (field.readerValue() != null) {
+ doc.add(new Field(field.name(), field.readerValue(), ft));
+ } else if (field.binaryValue() != null) {
+ doc.add(new Field(field.name(), field.binaryValue(), ft));
+ } else if (field.stringValue() != null) {
+ doc.add(new Field(field.name(), field.stringValue(), ft));
+ } else if (field.numericValue() != null) {
+ doc.add(new Field(field.name(), field.numericValue().toString(), ft));
+ }
+ }
}
+ return doc;
}
}
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/112078ea/lucene/classification/src/test/org/apache/lucene/classification/utils/DataSplitterTest.java
----------------------------------------------------------------------
diff --git a/lucene/classification/src/test/org/apache/lucene/classification/utils/DataSplitterTest.java b/lucene/classification/src/test/org/apache/lucene/classification/utils/DataSplitterTest.java
index 2984bb5..0b6f077 100644
--- a/lucene/classification/src/test/org/apache/lucene/classification/utils/DataSplitterTest.java
+++ b/lucene/classification/src/test/org/apache/lucene/classification/utils/DataSplitterTest.java
@@ -17,27 +17,28 @@
package org.apache.lucene.classification.utils;
-import org.apache.lucene.analysis.Analyzer;
+import java.io.IOException;
+import java.util.Random;
+
import org.apache.lucene.analysis.MockAnalyzer;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
import org.apache.lucene.document.FieldType;
+import org.apache.lucene.document.SortedDocValuesField;
import org.apache.lucene.document.TextField;
-import org.apache.lucene.index.LeafReader;
import org.apache.lucene.index.DirectoryReader;
import org.apache.lucene.index.IndexReader;
+import org.apache.lucene.index.LeafReader;
import org.apache.lucene.index.RandomIndexWriter;
import org.apache.lucene.store.BaseDirectoryWrapper;
import org.apache.lucene.store.Directory;
-import org.apache.lucene.util.TestUtil;
+import org.apache.lucene.util.BytesRef;
import org.apache.lucene.util.LuceneTestCase;
+import org.apache.lucene.util.TestUtil;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
-import java.io.IOException;
-import java.util.Random;
-
/**
* Testcase for {@link org.apache.lucene.classification.utils.DatasetSplitter}
*/
@@ -47,9 +48,9 @@ public class DataSplitterTest extends LuceneTestCase {
private RandomIndexWriter indexWriter;
private Directory dir;
- private String textFieldName = "text";
- private String classFieldName = "class";
- private String idFieldName = "id";
+ private static final String textFieldName = "text";
+ private static final String classFieldName = "class";
+ private static final String idFieldName = "id";
@Override
@Before
@@ -65,11 +66,11 @@ public class DataSplitterTest extends LuceneTestCase {
Document doc;
Random rnd = random();
- for (int i = 0; i < 100; i++) {
+ for (int i = 0; i < 1000; i++) {
doc = new Document();
- doc.add(new Field(idFieldName, Integer.toString(i), ft));
+ doc.add(new Field(idFieldName, "id" + Integer.toString(i), ft));
doc.add(new Field(textFieldName, TestUtil.randomUnicodeString(rnd, 1024), ft));
- doc.add(new Field(classFieldName, TestUtil.randomUnicodeString(rnd, 10), ft));
+ doc.add(new Field(classFieldName, Integer.toString(rnd.nextInt(10)), ft));
indexWriter.addDocument(doc);
}
@@ -108,18 +109,18 @@ public class DataSplitterTest extends LuceneTestCase {
try {
DatasetSplitter datasetSplitter = new DatasetSplitter(testRatio, crossValidationRatio);
- datasetSplitter.split(originalIndex, trainingIndex, testIndex, crossValidationIndex, new MockAnalyzer(random()), fieldNames);
+ datasetSplitter.split(originalIndex, trainingIndex, testIndex, crossValidationIndex, new MockAnalyzer(random()), true, classFieldName, fieldNames);
assertNotNull(trainingIndex);
assertNotNull(testIndex);
assertNotNull(crossValidationIndex);
DirectoryReader trainingReader = DirectoryReader.open(trainingIndex);
- assertTrue((int) (originalIndex.maxDoc() * (1d - testRatio - crossValidationRatio)) == trainingReader.maxDoc());
+ assertEquals((int) (originalIndex.maxDoc() * (1d - testRatio - crossValidationRatio)), trainingReader.maxDoc(), 20);
DirectoryReader testReader = DirectoryReader.open(testIndex);
- assertTrue((int) (originalIndex.maxDoc() * testRatio) == testReader.maxDoc());
+ assertEquals((int) (originalIndex.maxDoc() * testRatio), testReader.maxDoc(), 20);
DirectoryReader cvReader = DirectoryReader.open(crossValidationIndex);
- assertTrue((int) (originalIndex.maxDoc() * crossValidationRatio) == cvReader.maxDoc());
+ assertEquals((int) (originalIndex.maxDoc() * crossValidationRatio), cvReader.maxDoc(), 20);
trainingReader.close();
testReader.close();
[07/50] lucene-solr:jira/SOLR-8908: tests: better DocSetCollector
tests, including better smallSetSize boundary testing
Posted by th...@apache.org.
tests: better DocSetCollector tests, including better smallSetSize boundary testing
Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/93f9456e
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/93f9456e
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/93f9456e
Branch: refs/heads/jira/SOLR-8908
Commit: 93f9456e2aa9061944e8ca87fec2113c66f64a5d
Parents: cfba58f
Author: yonik <yo...@apache.org>
Authored: Sat Apr 9 19:21:27 2016 -0400
Committer: yonik <yo...@apache.org>
Committed: Sat Apr 9 19:21:27 2016 -0400
----------------------------------------------------------------------
.../test/org/apache/solr/search/TestDocSet.java | 27 +++++++++++++++++++-
1 file changed, 26 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/93f9456e/solr/core/src/test/org/apache/solr/search/TestDocSet.java
----------------------------------------------------------------------
diff --git a/solr/core/src/test/org/apache/solr/search/TestDocSet.java b/solr/core/src/test/org/apache/solr/search/TestDocSet.java
index 3d93099..9c46d5b 100644
--- a/solr/core/src/test/org/apache/solr/search/TestDocSet.java
+++ b/solr/core/src/test/org/apache/solr/search/TestDocSet.java
@@ -55,7 +55,29 @@ public class TestDocSet extends LuceneTestCase {
super.setUp();
rand = random();
}
-
+
+ // test the DocSetCollector
+ public void collect(DocSet set, int maxDoc) {
+ int smallSetSize = maxDoc >> 64 + 3;
+ if (set.size() > 1) {
+ if (random().nextBoolean()) {
+ smallSetSize = set.size() + random().nextInt(3) - 1; // test the bounds around smallSetSize
+ }
+ }
+ DocSetCollector collector = new DocSetCollector(smallSetSize, maxDoc);
+
+ for(DocIterator i1 = set.iterator(); i1.hasNext();) {
+ try {
+ collector.collect( i1.nextDoc() );
+ } catch (IOException e) {
+ throw new RuntimeException(e); // should be impossible
+ }
+ }
+
+ DocSet result = collector.getDocSet();
+ iter(set, result); // check that they are equal
+ }
+
public FixedBitSet getRandomSet(int sz, int bitsToSet) {
FixedBitSet bs = new FixedBitSet(sz);
if (sz==0) return bs;
@@ -165,6 +187,9 @@ public class TestDocSet extends LuceneTestCase {
iter(a1,b1);
iter(a2,b2);
+ collect(a1, maxSize);
+ collect(a2, maxSize);
+
FixedBitSet a_and = bs1.clone(); a_and.and(bs2);
FixedBitSet a_or = bs1.clone(); a_or.or(bs2);
// FixedBitSet a_xor = bs1.clone(); a_xor.xor(bs2);
[08/50] lucene-solr:jira/SOLR-8908: LUCENE-7194: Roll our own
toRadians() method,
and also make it less likely we'll need to restaple the toString() tests.
Posted by th...@apache.org.
LUCENE-7194: Roll our own toRadians() method, and also make it less likely we'll need to restaple the toString() tests.
Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/a4bf526a
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/a4bf526a
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/a4bf526a
Branch: refs/heads/jira/SOLR-8908
Commit: a4bf526a62dbf5e2c3fed6d98112c71ed33e15d6
Parents: d377e7f
Author: Karl Wright <Da...@gmail.com>
Authored: Sun Apr 10 05:11:12 2016 -0400
Committer: Karl Wright <Da...@gmail.com>
Committed: Sun Apr 10 05:11:12 2016 -0400
----------------------------------------------------------------------
.../org/apache/lucene/spatial3d/Geo3DPoint.java | 10 ++++++----
.../apache/lucene/spatial3d/TestGeo3DPoint.java | 20 ++++++++++++--------
2 files changed, 18 insertions(+), 12 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/a4bf526a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/Geo3DPoint.java
----------------------------------------------------------------------
diff --git a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/Geo3DPoint.java b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/Geo3DPoint.java
index 1e07aa7..1a36c3e 100644
--- a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/Geo3DPoint.java
+++ b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/Geo3DPoint.java
@@ -51,7 +51,9 @@ import org.apache.lucene.util.NumericUtils;
public final class Geo3DPoint extends Field {
/** How many radians are in one earth surface meter */
- protected final static double RADIANS_PER_METER = 1.0 / PlanetModel.WGS84_MEAN;
+ public final static double RADIANS_PER_METER = 1.0 / PlanetModel.WGS84_MEAN;
+ /** How many radians are in one degree */
+ public final static double RADIANS_PER_DEGREE = Math.PI / 180.0;
/** Indexing {@link FieldType}. */
public static final FieldType TYPE = new FieldType();
@@ -75,12 +77,12 @@ public final class Geo3DPoint extends Field {
}
/** Converts degress to radians */
- protected static double fromDegrees(final double degrees) {
- return Math.toRadians(degrees);
+ private static double fromDegrees(final double degrees) {
+ return degrees * RADIANS_PER_DEGREE;
}
/** Converts earth-surface meters to radians */
- protected static double fromMeters(final double meters) {
+ private static double fromMeters(final double meters) {
return meters * RADIANS_PER_METER;
}
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/a4bf526a/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 5c876ce..c80f3bb 100644
--- a/lucene/spatial3d/src/test/org/apache/lucene/spatial3d/TestGeo3DPoint.java
+++ b/lucene/spatial3d/src/test/org/apache/lucene/spatial3d/TestGeo3DPoint.java
@@ -132,7 +132,7 @@ public class TestGeo3DPoint extends LuceneTestCase {
}
private static double toRadians(double degrees) {
- return Math.toRadians(degrees);
+ return degrees * Geo3DPoint.RADIANS_PER_DEGREE;
}
private static class Cell {
@@ -810,13 +810,17 @@ public class TestGeo3DPoint extends LuceneTestCase {
}
public void testToString() {
+ // Don't compare entire strings because Java 9 and Java 8 have slightly different values
Geo3DPoint point = new Geo3DPoint("point", 44.244272, 7.769736);
- assertEquals("Geo3DPoint <point: x=", point.toString().substring(0,"Geo3DPoint <point: x=".length()));
+ final String stringToCompare = "Geo3DPoint <point: x=";
+ assertEquals(stringToCompare, point.toString().substring(0,stringToCompare.length()));
}
public void testShapeQueryToString() {
- assertEquals("PointInGeo3DShapeQuery: field=point: Shape: GeoStandardCircle: {planetmodel=PlanetModel.WGS84, center=[lat=0.7722082215479366, lon=0.13560747521073413([X=0.7094263130137863, Y=0.09679758930862137, Z=0.6973564619248455])], radius=0.1(5.729577951308232)}",
- Geo3DPoint.newShapeQuery("point", GeoCircleFactory.makeGeoCircle(PlanetModel.WGS84, toRadians(44.244272), toRadians(7.769736), 0.1)).toString());
+ // Don't compare entire strings because Java 9 and Java 8 have slightly different values
+ final String stringToCompare = "PointInGeo3DShapeQuery: field=point: Shape: GeoStandardCircle: {planetmodel=PlanetModel.WGS84, center=[lat=0.7";
+ assertEquals(stringToCompare,
+ Geo3DPoint.newShapeQuery("point", GeoCircleFactory.makeGeoCircle(PlanetModel.WGS84, toRadians(44.244272), toRadians(7.769736), 0.1)).toString().substring(0,stringToCompare.length()));
}
private static Directory getDirectory() {
@@ -841,7 +845,7 @@ public class TestGeo3DPoint extends LuceneTestCase {
public void testComplexPolygons() {
final PlanetModel pm = PlanetModel.WGS84;
// Pick a random pole
- final GeoPoint randomPole = new GeoPoint(pm, Math.toRadians(GeoTestUtil.nextLatitude()), Math.toRadians(GeoTestUtil.nextLongitude()));
+ final GeoPoint randomPole = new GeoPoint(pm, toRadians(GeoTestUtil.nextLatitude()), toRadians(GeoTestUtil.nextLongitude()));
int iters = atLeast(100);
for (int i = 0; i < iters; i++) {
// Create a polygon that's less than 180 degrees
@@ -854,8 +858,8 @@ public class TestGeo3DPoint extends LuceneTestCase {
}
}
- protected static double MINIMUM_EDGE_ANGLE = Math.toRadians(5.0);
- protected static double MINIMUM_ARC_ANGLE = Math.toRadians(1.0);
+ protected static double MINIMUM_EDGE_ANGLE = toRadians(5.0);
+ protected static double MINIMUM_ARC_ANGLE = toRadians(1.0);
/** Cook up a random Polygon that makes sense, with possible nested polygon within.
* This is part of testing more complex polygons with nested holes. Picking random points
@@ -1036,7 +1040,7 @@ public class TestGeo3DPoint extends LuceneTestCase {
final double[] lons = polygon.getPolyLons();
final List<GeoPoint> polyPoints = new ArrayList<>(lats.length-1);
for (int i = 0; i < lats.length - 1; i++) {
- final GeoPoint newPoint = new GeoPoint(pm, Math.toRadians(lats[i]), Math.toRadians(lons[i]));
+ final GeoPoint newPoint = new GeoPoint(pm, toRadians(lats[i]), toRadians(lons[i]));
if (!outsidePolygon.isWithin(newPoint)) {
return false;
}
[14/50] lucene-solr:jira/SOLR-8908: LUCENE-7196 - added missing misc
dependency
Posted by th...@apache.org.
LUCENE-7196 - added missing misc dependency
Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/273d586b
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/273d586b
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/273d586b
Branch: refs/heads/jira/SOLR-8908
Commit: 273d586be410a14e58c20bad596b5790349d03c2
Parents: 112078e
Author: Tommaso Teofili <to...@apache.org>
Authored: Mon Apr 11 10:03:37 2016 +0200
Committer: Tommaso Teofili <to...@apache.org>
Committed: Mon Apr 11 10:03:37 2016 +0200
----------------------------------------------------------------------
lucene/classification/build.xml | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/273d586b/lucene/classification/build.xml
----------------------------------------------------------------------
diff --git a/lucene/classification/build.xml b/lucene/classification/build.xml
index fd15239..c56d481 100644
--- a/lucene/classification/build.xml
+++ b/lucene/classification/build.xml
@@ -28,6 +28,7 @@
<path refid="base.classpath"/>
<pathelement path="${queries.jar}"/>
<pathelement path="${grouping.jar}"/>
+ <pathelement path="${misc.jar}"/>
</path>
<path id="test.classpath">
@@ -36,16 +37,17 @@
<path refid="test.base.classpath"/>
</path>
- <target name="compile-core" depends="jar-grouping,jar-queries,jar-analyzers-common,common.compile-core" />
+ <target name="compile-core" depends="jar-misc,jar-grouping,jar-queries,jar-analyzers-common,common.compile-core" />
<target name="jar-core" depends="common.jar-core" />
- <target name="javadocs" depends="javadocs-grouping,javadocs-misc,compile-core,check-javadocs-uptodate"
+ <target name="javadocs" depends="javadocs-misc,javadocs-grouping,javadocs-misc,compile-core,check-javadocs-uptodate"
unless="javadocs-uptodate-${name}">
<invoke-module-javadoc>
<links>
<link href="../queries"/>
<link href="../group"/>
+ <link href="../misc"/>
</links>
</invoke-module-javadoc>
</target>
[40/50] lucene-solr:jira/SOLR-8908: LUCENE-7211: Use DocIdSetBuilder
instead of FixedBitSet in spatial RPT intersects predicate.
Posted by th...@apache.org.
LUCENE-7211: Use DocIdSetBuilder instead of FixedBitSet in spatial RPT intersects predicate.
Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/f7f64c21
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/f7f64c21
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/f7f64c21
Branch: refs/heads/jira/SOLR-8908
Commit: f7f64c21722e739bc7cc9fbd62c2275ef6340fc1
Parents: cd673eb
Author: David Smiley <ds...@apache.org>
Authored: Wed Apr 13 10:39:09 2016 -0400
Committer: David Smiley <ds...@apache.org>
Committed: Wed Apr 13 10:39:09 2016 -0400
----------------------------------------------------------------------
lucene/CHANGES.txt | 3 +++
.../spatial/prefix/IntersectsPrefixTreeQuery.java | 13 ++++++-------
2 files changed, 9 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/f7f64c21/lucene/CHANGES.txt
----------------------------------------------------------------------
diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txt
index 87d039f..58eee6a 100644
--- a/lucene/CHANGES.txt
+++ b/lucene/CHANGES.txt
@@ -63,6 +63,9 @@ Optimizations
* LUCENE-7159: Speed up LatLonPoint polygon performance for complex
polygons. (Robert Muir)
+* LUCENE-7211: Reduce memory & GC for spatial RPT Intersects when the number of
+ matching docs is small. (Jeff Wartes, David Smiley)
+
Bug Fixes
* LUCENE-7127: Fix corner case bugs in GeoPointDistanceQuery. (Robert Muir)
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/f7f64c21/lucene/spatial-extras/src/java/org/apache/lucene/spatial/prefix/IntersectsPrefixTreeQuery.java
----------------------------------------------------------------------
diff --git a/lucene/spatial-extras/src/java/org/apache/lucene/spatial/prefix/IntersectsPrefixTreeQuery.java b/lucene/spatial-extras/src/java/org/apache/lucene/spatial/prefix/IntersectsPrefixTreeQuery.java
index 89129a1..17c5a7e 100644
--- a/lucene/spatial-extras/src/java/org/apache/lucene/spatial/prefix/IntersectsPrefixTreeQuery.java
+++ b/lucene/spatial-extras/src/java/org/apache/lucene/spatial/prefix/IntersectsPrefixTreeQuery.java
@@ -18,14 +18,13 @@ package org.apache.lucene.spatial.prefix;
import java.io.IOException;
-import org.locationtech.spatial4j.shape.Shape;
-import org.locationtech.spatial4j.shape.SpatialRelation;
import org.apache.lucene.index.LeafReaderContext;
import org.apache.lucene.search.DocIdSet;
import org.apache.lucene.spatial.prefix.tree.Cell;
import org.apache.lucene.spatial.prefix.tree.SpatialPrefixTree;
-import org.apache.lucene.util.BitDocIdSet;
-import org.apache.lucene.util.FixedBitSet;
+import org.apache.lucene.util.DocIdSetBuilder;
+import org.locationtech.spatial4j.shape.Shape;
+import org.locationtech.spatial4j.shape.SpatialRelation;
/**
* A Query matching documents that have an {@link SpatialRelation#INTERSECTS}
@@ -53,16 +52,16 @@ public class IntersectsPrefixTreeQuery extends AbstractVisitingPrefixTreeQuery {
*/
return new VisitorTemplate(context) {
- private FixedBitSet results;
+ private DocIdSetBuilder results;
@Override
protected void start() {
- results = new FixedBitSet(maxDoc);
+ results = new DocIdSetBuilder(maxDoc);
}
@Override
protected DocIdSet finish() {
- return new BitDocIdSet(results);
+ return results.build();
}
@Override
[49/50] lucene-solr:jira/SOLR-8908: LUCENE-7215: don't invoke full
haversin for LatLonPoint.newDistanceQuery
Posted by th...@apache.org.
LUCENE-7215: don't invoke full haversin for LatLonPoint.newDistanceQuery
Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/2335a458
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/2335a458
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/2335a458
Branch: refs/heads/jira/SOLR-8908
Commit: 2335a458d8340bbb8e4fe8133a74763bd2d37fd1
Parents: 1a1c8db
Author: Robert Muir <rm...@apache.org>
Authored: Wed Apr 13 19:02:11 2016 -0400
Committer: Robert Muir <rm...@apache.org>
Committed: Wed Apr 13 19:02:11 2016 -0400
----------------------------------------------------------------------
lucene/CHANGES.txt | 3 +-
.../org/apache/lucene/util/TestSloppyMath.java | 4 ++
.../document/LatLonPointDistanceQuery.java | 70 +++++++++++++-------
3 files changed, 52 insertions(+), 25 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/2335a458/lucene/CHANGES.txt
----------------------------------------------------------------------
diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txt
index ac68f78..5cd5d04 100644
--- a/lucene/CHANGES.txt
+++ b/lucene/CHANGES.txt
@@ -39,7 +39,8 @@ Optimizations
* LUCENE-7071: Reduce bytes copying in OfflineSorter, giving ~10%
speedup on merging 2D LatLonPoint values (Mike McCandless)
-* LUCENE-7105: Optimize LatLonPoint's newDistanceQuery. (Robert Muir)
+* LUCENE-7105, LUCENE-7215: Optimize LatLonPoint's newDistanceQuery.
+ (Robert Muir)
* LUCENE-7109: LatLonPoint's newPolygonQuery supports two-phase
iteration. (Robert Muir)
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/2335a458/lucene/core/src/test/org/apache/lucene/util/TestSloppyMath.java
----------------------------------------------------------------------
diff --git a/lucene/core/src/test/org/apache/lucene/util/TestSloppyMath.java b/lucene/core/src/test/org/apache/lucene/util/TestSloppyMath.java
index ea55971..6a2eb86 100644
--- a/lucene/core/src/test/org/apache/lucene/util/TestSloppyMath.java
+++ b/lucene/core/src/test/org/apache/lucene/util/TestSloppyMath.java
@@ -150,6 +150,10 @@ public class TestSloppyMath extends LuceneTestCase {
}
}
+ public void testHaversinFromSortKey() {
+ assertEquals(0.0, haversinMeters(0), 0.0D);
+ }
+
public void testAgainstSlowVersion() {
for (int i = 0; i < 100_000; i++) {
double lat1 = GeoTestUtil.nextLatitude();
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/2335a458/lucene/sandbox/src/java/org/apache/lucene/document/LatLonPointDistanceQuery.java
----------------------------------------------------------------------
diff --git a/lucene/sandbox/src/java/org/apache/lucene/document/LatLonPointDistanceQuery.java b/lucene/sandbox/src/java/org/apache/lucene/document/LatLonPointDistanceQuery.java
index 604886b..9bd78fe 100644
--- a/lucene/sandbox/src/java/org/apache/lucene/document/LatLonPointDistanceQuery.java
+++ b/lucene/sandbox/src/java/org/apache/lucene/document/LatLonPointDistanceQuery.java
@@ -97,15 +97,8 @@ final class LatLonPointDistanceQuery extends Query {
NumericUtils.intToSortableBytes(Integer.MAX_VALUE, minLon2, 0);
}
- // compute a maximum partial haversin: unless our box is crazy, we can use this bound
- // to reject edge cases faster in visit()
- final double maxPartialDistance;
- if (box.maxLon - longitude < 90 && longitude - box.minLon < 90) {
- maxPartialDistance = Math.max(SloppyMath.haversinSortKey(latitude, longitude, latitude, box.maxLon),
- SloppyMath.haversinSortKey(latitude, longitude, box.maxLat, longitude));
- } else {
- maxPartialDistance = Double.POSITIVE_INFINITY;
- }
+ // compute exact sort key: avoid any asin() computations
+ final double sortKey = sortKey(radiusMeters);
final double axisLat = Rectangle.axisLat(latitude, radiusMeters);
@@ -160,13 +153,9 @@ final class LatLonPointDistanceQuery extends Query {
double docLatitude = decodeLatitude(packedValue, 0);
double docLongitude = decodeLongitude(packedValue, Integer.BYTES);
- // first check the partial distance, if its more than that, it can't be <= radiusMeters
- double h1 = SloppyMath.haversinSortKey(latitude, longitude, docLatitude, docLongitude);
- if (h1 <= maxPartialDistance) {
- // fully confirm with part 2:
- if (SloppyMath.haversinMeters(h1) <= radiusMeters) {
- result.add(docID);
- }
+ // its a match only if its sortKey <= our sortKey
+ if (SloppyMath.haversinSortKey(latitude, longitude, docLatitude, docLongitude) <= sortKey) {
+ result.add(docID);
}
}
@@ -197,20 +186,20 @@ final class LatLonPointDistanceQuery extends Query {
if ((longitude < lonMin || longitude > lonMax) && (axisLat+ Rectangle.AXISLAT_ERROR < latMin || axisLat- Rectangle.AXISLAT_ERROR > latMax)) {
// circle not fully inside / crossing axis
- if (SloppyMath.haversinMeters(latitude, longitude, latMin, lonMin) > radiusMeters &&
- SloppyMath.haversinMeters(latitude, longitude, latMin, lonMax) > radiusMeters &&
- SloppyMath.haversinMeters(latitude, longitude, latMax, lonMin) > radiusMeters &&
- SloppyMath.haversinMeters(latitude, longitude, latMax, lonMax) > radiusMeters) {
+ if (SloppyMath.haversinSortKey(latitude, longitude, latMin, lonMin) > sortKey &&
+ SloppyMath.haversinSortKey(latitude, longitude, latMin, lonMax) > sortKey &&
+ SloppyMath.haversinSortKey(latitude, longitude, latMax, lonMin) > sortKey &&
+ SloppyMath.haversinSortKey(latitude, longitude, latMax, lonMax) > sortKey) {
// no points inside
return Relation.CELL_OUTSIDE_QUERY;
}
}
if (lonMax - longitude < 90 && longitude - lonMin < 90 &&
- SloppyMath.haversinMeters(latitude, longitude, latMin, lonMin) <= radiusMeters &&
- SloppyMath.haversinMeters(latitude, longitude, latMin, lonMax) <= radiusMeters &&
- SloppyMath.haversinMeters(latitude, longitude, latMax, lonMin) <= radiusMeters &&
- SloppyMath.haversinMeters(latitude, longitude, latMax, lonMax) <= radiusMeters) {
+ SloppyMath.haversinSortKey(latitude, longitude, latMin, lonMin) <= sortKey &&
+ SloppyMath.haversinSortKey(latitude, longitude, latMin, lonMax) <= sortKey &&
+ SloppyMath.haversinSortKey(latitude, longitude, latMax, lonMin) <= sortKey &&
+ SloppyMath.haversinSortKey(latitude, longitude, latMax, lonMax) <= sortKey) {
// we are fully enclosed, collect everything within this subtree
return Relation.CELL_INSIDE_QUERY;
} else {
@@ -230,6 +219,39 @@ final class LatLonPointDistanceQuery extends Query {
};
}
+ /**
+ * binary search to find the exact sortKey needed to match the specified radius
+ * any sort key <= this is a query match.
+ */
+ static double sortKey(double radius) {
+ // effectively infinite
+ if (radius >= SloppyMath.haversinMeters(Double.MAX_VALUE)) {
+ return SloppyMath.haversinMeters(Double.MAX_VALUE);
+ }
+
+ // this is a search through non-negative long space only
+ long lo = 0;
+ long hi = Double.doubleToRawLongBits(Double.MAX_VALUE);
+ while (lo <= hi) {
+ long mid = (lo + hi) >>> 1;
+ double sortKey = Double.longBitsToDouble(mid);
+ double midRadius = SloppyMath.haversinMeters(sortKey);
+ if (midRadius == radius) {
+ return sortKey;
+ } else if (midRadius > radius) {
+ hi = mid - 1;
+ } else {
+ lo = mid + 1;
+ }
+ }
+
+ // not found: this is because a user can supply an arbitrary radius, one that we will never
+ // calculate exactly via our haversin method.
+ double ceil = Double.longBitsToDouble(lo);
+ assert SloppyMath.haversinMeters(ceil) > radius;
+ return ceil;
+ }
+
public String getField() {
return field;
}
[34/50] lucene-solr:jira/SOLR-8908: LUCENE-7196: Add dependency on
grouping and misc modules to avoid compile failures in IntelliJ IDEA
Posted by th...@apache.org.
LUCENE-7196: Add dependency on grouping and misc modules to avoid compile failures in IntelliJ IDEA
Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/67f6283c
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/67f6283c
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/67f6283c
Branch: refs/heads/jira/SOLR-8908
Commit: 67f6283ce418357938fc12d82783a3504ba700d7
Parents: 69f3d1f
Author: Shalin Shekhar Mangar <sh...@apache.org>
Authored: Wed Apr 13 12:45:33 2016 +0530
Committer: Shalin Shekhar Mangar <sh...@apache.org>
Committed: Wed Apr 13 12:45:33 2016 +0530
----------------------------------------------------------------------
dev-tools/idea/lucene/classification/classification.iml | 2 ++
1 file changed, 2 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/67f6283c/dev-tools/idea/lucene/classification/classification.iml
----------------------------------------------------------------------
diff --git a/dev-tools/idea/lucene/classification/classification.iml b/dev-tools/idea/lucene/classification/classification.iml
index 20105b6..0f20274 100644
--- a/dev-tools/idea/lucene/classification/classification.iml
+++ b/dev-tools/idea/lucene/classification/classification.iml
@@ -17,5 +17,7 @@
<orderEntry type="module" module-name="lucene-core" />
<orderEntry type="module" module-name="queries" />
<orderEntry type="module" scope="TEST" module-name="analysis-common" />
+ <orderEntry type="module" module-name="grouping" />
+ <orderEntry type="module" module-name="misc" />
</component>
</module>
[11/50] lucene-solr:jira/SOLR-8908: fix failing test: 6.0 has back
compat support in 7.0 ; )
Posted by th...@apache.org.
fix failing test: 6.0 has back compat support in 7.0 ;)
Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/dd8c199c
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/dd8c199c
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/dd8c199c
Branch: refs/heads/jira/SOLR-8908
Commit: dd8c199c0b36b0a1a18af774b13ef7aa15ca027b
Parents: 22ccccf
Author: Mike McCandless <mi...@apache.org>
Authored: Sun Apr 10 11:03:35 2016 -0400
Committer: Mike McCandless <mi...@apache.org>
Committed: Sun Apr 10 11:03:35 2016 -0400
----------------------------------------------------------------------
.../org/apache/lucene/index/TestBackwardsCompatibility.java | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/dd8c199c/lucene/backward-codecs/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java
----------------------------------------------------------------------
diff --git a/lucene/backward-codecs/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java b/lucene/backward-codecs/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java
index 6c14efe..f979c30 100644
--- a/lucene/backward-codecs/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java
+++ b/lucene/backward-codecs/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java
@@ -215,8 +215,9 @@ public class TestBackwardsCompatibility extends LuceneTestCase {
dir.close();
}
- // TODO: on 6.0.0 release, gen the indices and add here:
final static String[] oldNames = {
+ "6.0.0-cfs",
+ "6.0.0-nocfs"
};
final String[] unsupportedNames = {
@@ -342,8 +343,6 @@ public class TestBackwardsCompatibility extends LuceneTestCase {
"5.4.1-nocfs",
"5.5.0-cfs",
"5.5.0-nocfs",
- "6.0.0-cfs",
- "6.0.0-nocfs"
};
// TODO: on 6.0.0 release, gen the single segment indices and add here:
[33/50] lucene-solr:jira/SOLR-8908: LUCENE-7204: Add a test for (and
make a fix for) legitimately coplanar polygon points.
Posted by th...@apache.org.
LUCENE-7204: Add a test for (and make a fix for) legitimately coplanar polygon points.
Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/69f3d1fe
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/69f3d1fe
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/69f3d1fe
Branch: refs/heads/jira/SOLR-8908
Commit: 69f3d1fe5ff6c0e19a64ac56c4407d7213f28cce
Parents: 9a15092
Author: Karl Wright <Da...@gmail.com>
Authored: Wed Apr 13 02:51:25 2016 -0400
Committer: Karl Wright <Da...@gmail.com>
Committed: Wed Apr 13 02:51:25 2016 -0400
----------------------------------------------------------------------
.../apache/lucene/spatial3d/geom/GeoPolygonFactory.java | 10 ++++++----
.../org/apache/lucene/spatial3d/geom/GeoPolygonTest.java | 8 ++++++++
2 files changed, 14 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/69f3d1fe/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoPolygonFactory.java
----------------------------------------------------------------------
diff --git a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoPolygonFactory.java b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoPolygonFactory.java
index 9865ac0..6bf8766 100755
--- a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoPolygonFactory.java
+++ b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoPolygonFactory.java
@@ -1094,10 +1094,10 @@ public class GeoPolygonFactory {
final boolean isNewPointWithin;
final GeoPoint pointToPresent;
if (currentEdge.plane.evaluateIsZero(newPoint)) {
- // The new point is colinear with the current edge. We'll have to look for the first point that isn't.
+ // The new point is colinear with the current edge. We'll have to look backwards for the first point that isn't.
int checkPointIndex = -1;
- // Compute the arc distance before we try to extend
- double accumulatedDistance = 0.0;
+ // Compute the arc distance before we try to extend, so that we note backtracking when we see it
+ double accumulatedDistance = newPoint.arcDistance(pointList.get(startIndex));
final Plane checkPlane = new Plane(pointList.get(startIndex), newPoint);
for (int i = 0; i < pointList.size(); i++) {
final int index = getLegalIndex(startIndex - 1 - i, pointList.size());
@@ -1106,11 +1106,13 @@ public class GeoPolygonFactory {
break;
} else {
accumulatedDistance += pointList.get(getLegalIndex(index+1, pointList.size())).arcDistance(pointList.get(index));
- final double actualDistance = pointList.get(getLegalIndex(startIndex-1, pointList.size())).arcDistance(pointList.get(index));
+ final double actualDistance = newPoint.arcDistance(pointList.get(index));
if (Math.abs(actualDistance - accumulatedDistance) >= Vector.MINIMUM_RESOLUTION) {
throw new IllegalArgumentException("polygon backtracks over itself");
}
}
+ }
+ if (checkPointIndex == -1) {
throw new IllegalArgumentException("polygon is illegal (linear)");
}
pointToPresent = pointList.get(checkPointIndex);
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/69f3d1fe/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 2da93cf..e721299 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
@@ -416,6 +416,14 @@ shape:
}
assertTrue(backtracks);
+ // Now make sure a legit poly with coplanar points works.
+ polyPoints.clear();
+ polyPoints.add(new GeoPoint(pm, -0.5516194571595735, 0.0));
+ polyPoints.add(new GeoPoint(pm, -1.5707963267948966, -2.2780601241431375));
+ polyPoints.add(new GeoPoint(pm, 0.2669499069140678, -0.31249902828113546));
+ polyPoints.add(new GeoPoint(pm, 1.538559019421765, 0.0));
+ GeoPolygonFactory.makeGeoPolygon(pm, polyPoints, 3, null);
+
}
}
[48/50] lucene-solr:jira/SOLR-8908: LUCENE-7213: fix test bug when
LatLonPoint.newBoxQuery returns MatchNoDocsQuery.
Posted by th...@apache.org.
LUCENE-7213: fix test bug when LatLonPoint.newBoxQuery returns MatchNoDocsQuery.
Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/1a1c8dbf
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/1a1c8dbf
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/1a1c8dbf
Branch: refs/heads/jira/SOLR-8908
Commit: 1a1c8dbfb325176ab471fcec8e739f488945ba9d
Parents: e4dcf42
Author: Robert Muir <rm...@apache.org>
Authored: Wed Apr 13 18:52:32 2016 -0400
Committer: Robert Muir <rm...@apache.org>
Committed: Wed Apr 13 18:52:32 2016 -0400
----------------------------------------------------------------------
.../org/apache/lucene/spatial/util/BaseGeoPointTestCase.java | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/1a1c8dbf/lucene/spatial/src/test/org/apache/lucene/spatial/util/BaseGeoPointTestCase.java
----------------------------------------------------------------------
diff --git a/lucene/spatial/src/test/org/apache/lucene/spatial/util/BaseGeoPointTestCase.java b/lucene/spatial/src/test/org/apache/lucene/spatial/util/BaseGeoPointTestCase.java
index 8daf83f..daf3cbd 100644
--- a/lucene/spatial/src/test/org/apache/lucene/spatial/util/BaseGeoPointTestCase.java
+++ b/lucene/spatial/src/test/org/apache/lucene/spatial/util/BaseGeoPointTestCase.java
@@ -54,6 +54,7 @@ import org.apache.lucene.index.SegmentWriteState;
import org.apache.lucene.index.SerialMergeScheduler;
import org.apache.lucene.index.Term;
import org.apache.lucene.search.IndexSearcher;
+import org.apache.lucene.search.MatchNoDocsQuery;
import org.apache.lucene.search.Query;
import org.apache.lucene.search.ScoreDoc;
import org.apache.lucene.search.SimpleCollector;
@@ -1387,7 +1388,11 @@ public abstract class BaseGeoPointTestCase extends LuceneTestCase {
q1 = newRectQuery("field", rect.minLat, rect.maxLat, rect.minLon, rect.maxLon);
q2 = newRectQuery("field", rect.minLat, rect.maxLat, rect.minLon, rect.maxLon);
assertEquals(q1, q2);
- assertFalse(q1.equals(newRectQuery("field2", rect.minLat, rect.maxLat, rect.minLon, rect.maxLon)));
+ // for "impossible" ranges LatLonPoint.newBoxQuery will return MatchNoDocsQuery
+ // changing the field is unrelated to that.
+ if (q1 instanceof MatchNoDocsQuery == false) {
+ assertFalse(q1.equals(newRectQuery("field2", rect.minLat, rect.maxLat, rect.minLon, rect.maxLon)));
+ }
double lat = randomLat(false);
double lon = randomLon(false);
[27/50] lucene-solr:jira/SOLR-8908: Merge branch 'master' of
https://git-wip-us.apache.org/repos/asf/lucene-solr
Posted by th...@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/91f74ee2
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/91f74ee2
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/91f74ee2
Branch: refs/heads/jira/SOLR-8908
Commit: 91f74ee2545aeae08bd5c610149d1cbc47f88aa4
Parents: aa4236a c1a70f3
Author: Karl Wright <Da...@gmail.com>
Authored: Tue Apr 12 06:03:24 2016 -0400
Committer: Karl Wright <Da...@gmail.com>
Committed: Tue Apr 12 06:03:24 2016 -0400
----------------------------------------------------------------------
dev-tools/scripts/addVersion.py | 19 +++++++++++--------
dev-tools/scripts/scriptutil.py | 16 ++++++++++------
lucene/CHANGES.txt | 4 ++++
.../apache/lucene/store/NRTCachingDirectory.java | 5 +----
4 files changed, 26 insertions(+), 18 deletions(-)
----------------------------------------------------------------------
[39/50] lucene-solr:jira/SOLR-8908: LUCENE-7185: add proper tests for
grid bugs found here, and fix related bugs still lurking
Posted by th...@apache.org.
LUCENE-7185: add proper tests for grid bugs found here, and fix related bugs still lurking
Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/cd673ebe
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/cd673ebe
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/cd673ebe
Branch: refs/heads/jira/SOLR-8908
Commit: cd673ebec93cbdf37d14b3984552cec4388cea0f
Parents: 744b419
Author: Robert Muir <rm...@apache.org>
Authored: Wed Apr 13 10:32:42 2016 -0400
Committer: Robert Muir <rm...@apache.org>
Committed: Wed Apr 13 10:33:26 2016 -0400
----------------------------------------------------------------------
.../org/apache/lucene/document/LatLonGrid.java | 10 ++--
.../apache/lucene/document/TestLatLonGrid.java | 53 +++++++++++++++++++-
2 files changed, 58 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/cd673ebe/lucene/sandbox/src/java/org/apache/lucene/document/LatLonGrid.java
----------------------------------------------------------------------
diff --git a/lucene/sandbox/src/java/org/apache/lucene/document/LatLonGrid.java b/lucene/sandbox/src/java/org/apache/lucene/document/LatLonGrid.java
index 7cb047a..e5718e2 100644
--- a/lucene/sandbox/src/java/org/apache/lucene/document/LatLonGrid.java
+++ b/lucene/sandbox/src/java/org/apache/lucene/document/LatLonGrid.java
@@ -22,8 +22,6 @@ import org.apache.lucene.util.FixedBitSet;
import static org.apache.lucene.geo.GeoEncodingUtils.decodeLatitude;
import static org.apache.lucene.geo.GeoEncodingUtils.decodeLongitude;
-import static org.apache.lucene.geo.GeoEncodingUtils.encodeLatitude;
-import static org.apache.lucene.geo.GeoEncodingUtils.encodeLongitude;
/**
* This is a temporary hack, until some polygon methods have better performance!
@@ -80,8 +78,10 @@ final class LatLonGrid {
long latitudeRange = maxLat - (long) minLat;
long longitudeRange = maxLon - (long) minLon;
- if (latitudeRange < GRID_SIZE || longitudeRange < GRID_SIZE) {
- // don't complicate fill right now if you pass e.g. emptyish stuff: make an "empty grid"
+ // if the range is too small, we can't divide it up in our grid nicely.
+ // in this case of a tiny polygon, we just make an empty grid instead of complicating/slowing down code.
+ final long minRange = (GRID_SIZE - 1) * (GRID_SIZE - 1);
+ if (latitudeRange < minRange || longitudeRange < minRange) {
latPerCell = lonPerCell = Long.MAX_VALUE;
} else {
// we spill over the edge of the bounding box in each direction a bit,
@@ -160,7 +160,9 @@ final class LatLonGrid {
long lonRel = longitude - (long) minLon;
int latIndex = (int) (latRel / latPerCell);
+ assert latIndex < GRID_SIZE;
int lonIndex = (int) (lonRel / lonPerCell);
+ assert lonIndex < GRID_SIZE;
return latIndex * GRID_SIZE + lonIndex;
}
}
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/cd673ebe/lucene/sandbox/src/test/org/apache/lucene/document/TestLatLonGrid.java
----------------------------------------------------------------------
diff --git a/lucene/sandbox/src/test/org/apache/lucene/document/TestLatLonGrid.java b/lucene/sandbox/src/test/org/apache/lucene/document/TestLatLonGrid.java
index 0b739ae..891e3d5 100644
--- a/lucene/sandbox/src/test/org/apache/lucene/document/TestLatLonGrid.java
+++ b/lucene/sandbox/src/test/org/apache/lucene/document/TestLatLonGrid.java
@@ -17,6 +17,7 @@
package org.apache.lucene.document;
import org.apache.lucene.geo.GeoTestUtil;
+import org.apache.lucene.geo.GeoUtils;
import org.apache.lucene.geo.Polygon;
import org.apache.lucene.geo.Rectangle;
import org.apache.lucene.util.LuceneTestCase;
@@ -32,7 +33,7 @@ public class TestLatLonGrid extends LuceneTestCase {
/** If the grid returns true, then any point in that cell should return true as well */
public void testRandom() throws Exception {
- for (int i = 0; i < 100; i++) {
+ for (int i = 0; i < 1000; i++) {
Polygon polygon = GeoTestUtil.nextPolygon();
Rectangle box = Rectangle.fromPolygon(new Polygon[] { polygon });
int minLat = encodeLatitude(box.minLat);
@@ -52,4 +53,54 @@ public class TestLatLonGrid extends LuceneTestCase {
}
}
}
+
+ public void testGrowingPolygon() {
+ double centerLat = -80.0 + random().nextDouble() * 160.0;
+ double centerLon = -170.0 + random().nextDouble() * 340.0;
+ double radiusMeters = 0.0;
+ for(int i=0;i<10;i++) {
+ radiusMeters = Math.nextUp(radiusMeters);
+ }
+
+ // Start with a miniscule polygon, and grow it:
+ int gons = TestUtil.nextInt(random(), 4, 10);
+ while (radiusMeters < GeoUtils.EARTH_MEAN_RADIUS_METERS * Math.PI / 2.0 + 1.0) {
+ Polygon polygon;
+ try {
+ polygon = GeoTestUtil.createRegularPolygon(centerLat, centerLon, radiusMeters, gons);
+ } catch (IllegalArgumentException iae) {
+ // OK: we made a too-big poly and it crossed a pole or dateline
+ break;
+ }
+ radiusMeters *= 1.1;
+
+ Rectangle box = Rectangle.fromPolygon(new Polygon[] { polygon });
+ int minLat = encodeLatitude(box.minLat);
+ int maxLat = encodeLatitude(box.maxLat);
+ int minLon = encodeLongitude(box.minLon);
+ int maxLon = encodeLongitude(box.maxLon);
+ LatLonGrid grid = new LatLonGrid(minLat, maxLat, minLon, maxLon, polygon);
+ // we are in integer space... but exhaustive testing is slow!
+ for (int j = 0; j < 1000; j++) {
+ int lat = TestUtil.nextInt(random(), minLat, maxLat);
+ int lon = TestUtil.nextInt(random(), minLon, maxLon);
+
+ boolean expected = polygon.contains(decodeLatitude(lat),
+ decodeLongitude(lon));
+ boolean actual = grid.contains(lat, lon);
+ assertEquals(expected, actual);
+ }
+ }
+ }
+
+ /** create ever-increasing grids and check that too-small polygons don't blow it up */
+ public void testTinyGrids() {
+ double ZERO = decodeLatitude(0);
+ double ONE = decodeLatitude(1);
+ Polygon tiny = new Polygon(new double[] { ZERO, ZERO, ONE, ONE, ZERO }, new double[] { ZERO, ONE, ONE, ZERO, ZERO });
+ for (int max = 1; max < 500000; max++) {
+ LatLonGrid grid = new LatLonGrid(0, max, 0, max, tiny);
+ assertEquals(tiny.contains(decodeLatitude(max), decodeLongitude(max)), grid.contains(max, max));
+ }
+ }
}
[17/50] lucene-solr:jira/SOLR-8908: LUCENE-7189: use fewer sampling
points for small earth-surface rectangles
Posted by th...@apache.org.
LUCENE-7189: use fewer sampling points for small earth-surface rectangles
Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/739c752c
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/739c752c
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/739c752c
Branch: refs/heads/jira/SOLR-8908
Commit: 739c752cd30b73713a1334d67da4e3b4fc83f9c9
Parents: 38bf7dd
Author: Mike McCandless <mi...@apache.org>
Authored: Mon Apr 11 05:45:42 2016 -0400
Committer: Mike McCandless <mi...@apache.org>
Committed: Mon Apr 11 05:45:42 2016 -0400
----------------------------------------------------------------------
.../src/java/org/apache/lucene/geo/EarthDebugger.java | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/739c752c/lucene/test-framework/src/java/org/apache/lucene/geo/EarthDebugger.java
----------------------------------------------------------------------
diff --git a/lucene/test-framework/src/java/org/apache/lucene/geo/EarthDebugger.java b/lucene/test-framework/src/java/org/apache/lucene/geo/EarthDebugger.java
index 14956f2..6c06c94 100644
--- a/lucene/test-framework/src/java/org/apache/lucene/geo/EarthDebugger.java
+++ b/lucene/test-framework/src/java/org/apache/lucene/geo/EarthDebugger.java
@@ -62,9 +62,14 @@ public class EarthDebugger {
}
}
+ private static double MAX_LAT_LON_PER_STEP = 5.0;
+
// first point is inclusive, last point is exclusive!
private void drawSegment(double minLat, double maxLat, double minLon, double maxLon) {
- int steps = 20;
+ int steps = (int) Math.round(Math.max(Math.abs(maxLat-minLat)/MAX_LAT_LON_PER_STEP, Math.abs(maxLon-minLon)/MAX_LAT_LON_PER_STEP));
+ if (steps < 1) {
+ steps = 1;
+ }
for(int i=0;i<steps;i++) {
b.append(" [" + (minLat + (maxLat - minLat) * i / steps) + ", " + (minLon + (maxLon - minLon) * i / steps) + "],\n");
}
@@ -75,6 +80,7 @@ public class EarthDebugger {
String name = "rect" + nextShape;
nextShape++;
+ b.append(" // lat: " + minLat + " TO " + maxLat + "; lon: " + minLon + " TO " + maxLon + "\n");
b.append(" var " + name + " = WE.polygon([\n");
b.append(" // min -> max lat, min lon\n");
[45/50] lucene-solr:jira/SOLR-8908: LUCENE-7214: Remove two-phase
iteration from LatLonPoint.newDistanceQuery
Posted by th...@apache.org.
LUCENE-7214: Remove two-phase iteration from LatLonPoint.newDistanceQuery
Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/fc19c99e
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/fc19c99e
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/fc19c99e
Branch: refs/heads/jira/SOLR-8908
Commit: fc19c99e0efc4cf7a0015974de118b2ae220e9cf
Parents: 689e966
Author: Robert Muir <rm...@apache.org>
Authored: Wed Apr 13 15:56:32 2016 -0400
Committer: Robert Muir <rm...@apache.org>
Committed: Wed Apr 13 15:57:04 2016 -0400
----------------------------------------------------------------------
lucene/CHANGES.txt | 3 -
.../document/LatLonPointDistanceQuery.java | 79 +++++---------------
2 files changed, 18 insertions(+), 64 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/fc19c99e/lucene/CHANGES.txt
----------------------------------------------------------------------
diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txt
index 58eee6a..ac68f78 100644
--- a/lucene/CHANGES.txt
+++ b/lucene/CHANGES.txt
@@ -39,9 +39,6 @@ Optimizations
* LUCENE-7071: Reduce bytes copying in OfflineSorter, giving ~10%
speedup on merging 2D LatLonPoint values (Mike McCandless)
-* LUCENE-7099: LatLonPoint's newDistanceQuery supports two-phase
- iteration. (Robert Muir)
-
* LUCENE-7105: Optimize LatLonPoint's newDistanceQuery. (Robert Muir)
* LUCENE-7109: LatLonPoint's newPolygonQuery supports two-phase
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/fc19c99e/lucene/sandbox/src/java/org/apache/lucene/document/LatLonPointDistanceQuery.java
----------------------------------------------------------------------
diff --git a/lucene/sandbox/src/java/org/apache/lucene/document/LatLonPointDistanceQuery.java b/lucene/sandbox/src/java/org/apache/lucene/document/LatLonPointDistanceQuery.java
index 843421b..604886b 100644
--- a/lucene/sandbox/src/java/org/apache/lucene/document/LatLonPointDistanceQuery.java
+++ b/lucene/sandbox/src/java/org/apache/lucene/document/LatLonPointDistanceQuery.java
@@ -18,13 +18,12 @@ package org.apache.lucene.document;
import java.io.IOException;
+import org.apache.lucene.geo.GeoUtils;
import org.apache.lucene.geo.Rectangle;
-import org.apache.lucene.index.DocValues;
import org.apache.lucene.index.FieldInfo;
import org.apache.lucene.index.LeafReader;
import org.apache.lucene.index.LeafReaderContext;
import org.apache.lucene.index.PointValues;
-import org.apache.lucene.index.SortedNumericDocValues;
import org.apache.lucene.index.PointValues.IntersectVisitor;
import org.apache.lucene.index.PointValues.Relation;
import org.apache.lucene.search.ConstantScoreScorer;
@@ -34,15 +33,10 @@ import org.apache.lucene.search.DocIdSetIterator;
import org.apache.lucene.search.IndexSearcher;
import org.apache.lucene.search.Query;
import org.apache.lucene.search.Scorer;
-import org.apache.lucene.search.TwoPhaseIterator;
import org.apache.lucene.search.Weight;
-import org.apache.lucene.geo.GeoUtils;
-import org.apache.lucene.util.BitSet;
import org.apache.lucene.util.DocIdSetBuilder;
-import org.apache.lucene.util.FixedBitSet;
import org.apache.lucene.util.NumericUtils;
import org.apache.lucene.util.SloppyMath;
-import org.apache.lucene.util.SparseFixedBitSet;
import org.apache.lucene.util.StringHelper;
import static org.apache.lucene.geo.GeoEncodingUtils.decodeLatitude;
@@ -104,7 +98,7 @@ final class LatLonPointDistanceQuery extends Query {
}
// compute a maximum partial haversin: unless our box is crazy, we can use this bound
- // to reject edge cases faster in matches()
+ // to reject edge cases faster in visit()
final double maxPartialDistance;
if (box.maxLon - longitude < 90 && longitude - box.minLon < 90) {
maxPartialDistance = Math.max(SloppyMath.haversinSortKey(latitude, longitude, latitude, box.maxLon),
@@ -132,16 +126,9 @@ final class LatLonPointDistanceQuery extends Query {
}
LatLonPoint.checkCompatible(fieldInfo);
- // approximation (postfiltering has not yet been applied)
+ // matching docids
DocIdSetBuilder result = new DocIdSetBuilder(reader.maxDoc());
- // subset of documents that need no postfiltering, this is purely an optimization
- final BitSet preApproved;
- // dumb heuristic: if the field is really sparse, use a sparse impl
- if (values.getDocCount(field) * 100L < reader.maxDoc()) {
- preApproved = new SparseFixedBitSet(reader.maxDoc());
- } else {
- preApproved = new FixedBitSet(reader.maxDoc());
- }
+
values.intersect(field,
new IntersectVisitor() {
@Override
@@ -152,14 +139,11 @@ final class LatLonPointDistanceQuery extends Query {
@Override
public void visit(int docID) {
result.add(docID);
- preApproved.set(docID);
}
@Override
public void visit(int docID, byte[] packedValue) {
- // we bounds check individual values, as subtrees may cross, but we are being sent the values anyway:
- // this reduces the amount of docvalues fetches (improves approximation)
-
+ // bounding box check
if (StringHelper.compare(Integer.BYTES, packedValue, 0, maxLat, 0) > 0 ||
StringHelper.compare(Integer.BYTES, packedValue, 0, minLat, 0) < 0) {
// latitude out of bounding box range
@@ -173,13 +157,23 @@ final class LatLonPointDistanceQuery extends Query {
return;
}
- result.add(docID);
+ double docLatitude = decodeLatitude(packedValue, 0);
+ double docLongitude = decodeLongitude(packedValue, Integer.BYTES);
+
+ // first check the partial distance, if its more than that, it can't be <= radiusMeters
+ double h1 = SloppyMath.haversinSortKey(latitude, longitude, docLatitude, docLongitude);
+ if (h1 <= maxPartialDistance) {
+ // fully confirm with part 2:
+ if (SloppyMath.haversinMeters(h1) <= radiusMeters) {
+ result.add(docID);
+ }
+ }
}
// algorithm: we create a bounding box (two bounding boxes if we cross the dateline).
// 1. check our bounding box(es) first. if the subtree is entirely outside of those, bail.
// 2. check if the subtree is disjoint. it may cross the bounding box but not intersect with circle
- // 3. see if the subtree is fully contained. if the subtree is enormous along the x axis, wrapping half way around the world, etc: then this can't work, just go to step 3.
+ // 3. see if the subtree is fully contained. if the subtree is enormous along the x axis, wrapping half way around the world, etc: then this can't work, just go to step 4.
// 4. recurse naively (subtrees crossing over circle edge)
@Override
public Relation compare(byte[] minPackedValue, byte[] maxPackedValue) {
@@ -231,44 +225,7 @@ final class LatLonPointDistanceQuery extends Query {
if (disi == null) {
return null;
}
-
- // return two-phase iterator using docvalues to postfilter candidates
- SortedNumericDocValues docValues = DocValues.getSortedNumeric(reader, field);
- TwoPhaseIterator iterator = new TwoPhaseIterator(disi) {
- @Override
- public boolean matches() throws IOException {
- int docId = disi.docID();
- if (preApproved.get(docId)) {
- return true;
- } else {
- docValues.setDocument(docId);
- int count = docValues.count();
- for (int i = 0; i < count; i++) {
- long encoded = docValues.valueAt(i);
- double docLatitude = decodeLatitude((int)(encoded >> 32));
- double docLongitude = decodeLongitude((int)(encoded & 0xFFFFFFFF));
-
- // first check the partial distance, if its more than that, it can't be <= radiusMeters
- double h1 = SloppyMath.haversinSortKey(latitude, longitude, docLatitude, docLongitude);
- if (h1 > maxPartialDistance) {
- continue;
- }
-
- // fully confirm with part 2:
- if (SloppyMath.haversinMeters(h1) <= radiusMeters) {
- return true;
- }
- }
- return false;
- }
- }
-
- @Override
- public float matchCost() {
- return 20; // TODO: make this fancier
- }
- };
- return new ConstantScoreScorer(this, score(), iterator);
+ return new ConstantScoreScorer(this, score(), disi);
}
};
}
[47/50] lucene-solr:jira/SOLR-8908: Merge branch 'master' of
https://git-wip-us.apache.org/repos/asf/lucene-solr
Posted by th...@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/e4dcf423
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/e4dcf423
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/e4dcf423
Branch: refs/heads/jira/SOLR-8908
Commit: e4dcf423e33b0bc139bfad9e2490bf8b33997d30
Parents: 6e5ec3b fc19c99
Author: Karl Wright <Da...@gmail.com>
Authored: Wed Apr 13 16:15:53 2016 -0400
Committer: Karl Wright <Da...@gmail.com>
Committed: Wed Apr 13 16:15:53 2016 -0400
----------------------------------------------------------------------
.../lucene/classification/classification.iml | 2 +
lucene/CHANGES.txt | 9 +-
.../xml/builders/BooleanQueryBuilder.java | 3 +-
.../builders/DisjunctionMaxQueryBuilder.java | 3 +-
.../xml/builders/FuzzyLikeThisQueryBuilder.java | 3 +-
.../org/apache/lucene/document/LatLonGrid.java | 10 +-
.../document/LatLonPointDistanceQuery.java | 79 ++----
.../apache/lucene/document/TestLatLonGrid.java | 53 +++-
.../prefix/IntersectsPrefixTreeQuery.java | 13 +-
.../java/org/apache/lucene/geo/GeoTestUtil.java | 85 +++++++
solr/CHANGES.txt | 10 +-
.../apache/solr/cloud/TestRebalanceLeaders.java | 18 +-
.../apache/solr/cloud/TestStressLiveNodes.java | 252 +++++++++++++++++++
.../solr/cloud/overseer/ZkStateReaderTest.java | 4 +-
.../solr/search/AnalyticsMergeStrategyTest.java | 5 +-
.../solrj/impl/ConcurrentUpdateSolrClient.java | 65 ++++-
.../solrj/request/CollectionAdminRequest.java | 61 +++++
.../apache/solr/common/cloud/ZkStateReader.java | 85 ++++---
.../impl/ConcurrentUpdateSolrClientTest.java | 78 +++++-
19 files changed, 711 insertions(+), 127 deletions(-)
----------------------------------------------------------------------
[23/50] lucene-solr:jira/SOLR-8908: Merge branch 'master' of
https://git-wip-us.apache.org/repos/asf/lucene-solr
Posted by th...@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/61e3c402
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/61e3c402
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/61e3c402
Branch: refs/heads/jira/SOLR-8908
Commit: 61e3c4020c10daa2892deb1090974b0ab9077bf6
Parents: 83bde55 88965a0
Author: Karl Wright <Da...@gmail.com>
Authored: Mon Apr 11 12:55:38 2016 -0400
Committer: Karl Wright <Da...@gmail.com>
Committed: Mon Apr 11 12:55:38 2016 -0400
----------------------------------------------------------------------
lucene/classification/build.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
[50/50] lucene-solr:jira/SOLR-8908: Merge branch 'master' into
jira/SOLR-8908
Posted by th...@apache.org.
Merge branch 'master' into jira/SOLR-8908
Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/c948a905
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/c948a905
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/c948a905
Branch: refs/heads/jira/SOLR-8908
Commit: c948a9058336b20e7eac60669683661bcdf49161
Parents: 146f00c 2335a45
Author: Timothy Potter <th...@gmail.com>
Authored: Wed Apr 13 16:20:36 2016 -0700
Committer: Timothy Potter <th...@gmail.com>
Committed: Wed Apr 13 16:20:36 2016 -0700
----------------------------------------------------------------------
dev-tools/idea/.idea/libraries/JUnit.xml | 4 +-
.../lucene/classification/classification.iml | 2 +
dev-tools/scripts/addVersion.py | 19 +-
dev-tools/scripts/buildAndPushRelease.py | 6 +-
dev-tools/scripts/scriptutil.py | 20 +-
lucene/CHANGES.txt | 65 +-
.../DictionaryCompoundWordTokenFilter.java | 4 +-
.../payloads/NumericPayloadTokenFilter.java | 2 +-
.../index/TestBackwardsCompatibility.java | 5 +-
.../org/apache/lucene/index/index.6.0.0-cfs.zip | Bin 0 -> 13744 bytes
.../apache/lucene/index/index.6.0.0-nocfs.zip | Bin 0 -> 13749 bytes
lucene/classification/build.xml | 8 +-
.../utils/ConfusionMatrixGenerator.java | 80 +-
.../classification/utils/DatasetSplitter.java | 126 +-
.../BooleanPerceptronClassifierTest.java | 2 +-
.../CachingNaiveBayesClassifierTest.java | 2 +-
.../KNearestNeighborClassifierTest.java | 2 +-
.../SimpleNaiveBayesClassifierTest.java | 2 +-
.../utils/ConfusionMatrixGeneratorTest.java | 105 +-
.../classification/utils/DataSplitterTest.java | 33 +-
.../org/apache/lucene/codecs/package-info.java | 1 +
.../org/apache/lucene/document/BinaryPoint.java | 16 +-
.../org/apache/lucene/document/DoublePoint.java | 4 +-
.../java/org/apache/lucene/document/Field.java | 26 +-
.../org/apache/lucene/document/FieldType.java | 4 +-
.../org/apache/lucene/document/FloatPoint.java | 4 +-
.../org/apache/lucene/document/IntPoint.java | 4 +-
.../org/apache/lucene/document/LongPoint.java | 4 +-
.../org/apache/lucene/geo/GeoEncodingUtils.java | 147 ++
.../java/org/apache/lucene/geo/GeoUtils.java | 94 ++
.../src/java/org/apache/lucene/geo/Polygon.java | 358 +++++
.../java/org/apache/lucene/geo/Rectangle.java | 189 +++
.../org/apache/lucene/geo/package-info.java | 21 +
.../lucene/index/DefaultIndexingChain.java | 2 +-
.../lucene/index/DocValuesFieldUpdates.java | 2 +-
.../java/org/apache/lucene/index/FieldInfo.java | 8 +-
.../org/apache/lucene/index/FieldInfos.java | 2 +-
.../apache/lucene/index/FilterLeafReader.java | 10 +-
.../org/apache/lucene/index/IndexWriter.java | 2 +-
.../apache/lucene/index/IndexWriterConfig.java | 6 +-
.../apache/lucene/index/PointValuesWriter.java | 2 +-
.../org/apache/lucene/search/PrefixQuery.java | 2 +-
.../apache/lucene/search/ReferenceManager.java | 4 +-
.../org/apache/lucene/store/BaseDirectory.java | 2 +-
.../lucene/store/NRTCachingDirectory.java | 5 +-
.../org/apache/lucene/util/BytesRefArray.java | 15 +-
.../org/apache/lucene/util/CommandLineUtil.java | 2 +-
.../lucene/util/FixedLengthBytesRefArray.java | 189 +++
.../org/apache/lucene/util/OfflineSorter.java | 75 +-
.../java/org/apache/lucene/util/SloppyMath.java | 14 +-
.../lucene/util/SortableBytesRefArray.java | 31 +
.../org/apache/lucene/util/UnicodeUtil.java | 2 +-
.../org/apache/lucene/util/bkd/BKDWriter.java | 17 +-
.../lucene/util/bkd/OfflinePointWriter.java | 15 +-
.../apache/lucene/geo/TestGeoEncodingUtils.java | 151 ++
.../org/apache/lucene/geo/TestGeoUtils.java | 341 +++++
.../test/org/apache/lucene/geo/TestPolygon.java | 248 ++++
.../search/spans/TestFieldMaskingSpanQuery.java | 2 +-
.../apache/lucene/store/TestRateLimiter.java | 2 +-
.../util/TestFixedLengthBytesRefArray.java | 84 ++
.../apache/lucene/util/TestOfflineSorter.java | 68 +-
.../org/apache/lucene/util/TestSloppyMath.java | 65 +-
.../demo/facet/DistanceFacetsExample.java | 5 +-
lucene/demo/src/java/overview.html | 2 +-
.../lucene/expressions/TestDemoExpressions.java | 6 +-
.../expressions/js/TestJavascriptFunction.java | 2 +-
.../org/apache/lucene/facet/range/Range.java | 2 +-
.../directory/DirectoryTaxonomyReader.java | 2 +-
.../facet/range/TestRangeFacetCounts.java | 13 +-
.../postingshighlight/PostingsHighlighter.java | 4 +-
lucene/ivy-versions.properties | 2 +-
.../search/join/ToChildBlockJoinQuery.java | 4 +-
.../search/join/ToParentBlockJoinQuery.java | 6 +-
.../lucene/search/join/TestBlockJoin.java | 32 +-
.../randomizedtesting-runner-2.3.2.jar.sha1 | 1 -
.../randomizedtesting-runner-2.3.4.jar.sha1 | 1 +
.../apache/lucene/store/WindowsDirectory.cpp | 4 +-
.../apache/lucene/queries/mlt/MoreLikeThis.java | 129 +-
.../lucene/queries/mlt/TestMoreLikeThis.java | 82 ++
.../queryparser/classic/QueryParserBase.java | 4 +-
.../core/config/AbstractQueryConfig.java | 8 +-
.../flexible/core/config/FieldConfig.java | 4 +-
.../standard/config/LegacyNumericConfig.java | 6 +-
.../LegacyNumericFieldConfigListener.java | 2 +-
.../flexible/standard/config/PointsConfig.java | 6 +-
.../standard/config/PointsConfigListener.java | 2 +-
.../nodes/LegacyNumericRangeQueryNode.java | 2 +-
.../standard/nodes/PointRangeQueryNode.java | 2 +-
.../xml/builders/BooleanQueryBuilder.java | 3 +-
.../builders/DisjunctionMaxQueryBuilder.java | 3 +-
.../xml/builders/FuzzyLikeThisQueryBuilder.java | 3 +-
.../lucene/queryparser/xml/TestCoreParser.java | 15 +-
.../apache/lucene/replicator/RevisionFile.java | 2 +-
lucene/sandbox/build.xml | 10 +
.../apache/lucene/document/BigIntegerPoint.java | 4 +-
.../lucene/document/InetAddressPoint.java | 4 +-
.../org/apache/lucene/document/LatLonGrid.java | 168 +++
.../org/apache/lucene/document/LatLonPoint.java | 151 +-
.../document/LatLonPointDistanceComparator.java | 30 +-
.../document/LatLonPointDistanceQuery.java | 172 ++-
.../document/LatLonPointInPolygonQuery.java | 221 ++-
.../lucene/document/LatLonPointSortField.java | 4 +-
.../lucene/search/DocValuesRangeQuery.java | 2 +-
.../apache/lucene/document/TestLatLonGrid.java | 106 ++
.../apache/lucene/document/TestLatLonPoint.java | 60 +-
.../document/TestLatLonPointDistanceSort.java | 35 +-
.../lucene/search/TestLatLonPointQueries.java | 15 +-
.../lucene/spatial/bbox/BBoxStrategy.java | 318 +++--
.../prefix/IntersectsPrefixTreeQuery.java | 13 +-
.../spatial/vector/PointVectorStrategy.java | 177 ++-
.../lucene/spatial/DistanceStrategyTest.java | 40 +-
.../apache/lucene/spatial/PortedSolr3Test.java | 13 +-
.../lucene/spatial/QueryEqualsHashCodeTest.java | 10 +-
.../apache/lucene/spatial/SpatialTestCase.java | 42 +-
.../lucene/spatial/bbox/TestBBoxStrategy.java | 68 +-
.../composite/CompositeStrategyTest.java | 17 +-
.../serialized/SerializedStrategyTest.java | 7 +-
.../lucene/spatial/spatial4j/Geo3dRptTest.java | 43 +-
.../Geo3dShapeRectRelationTestCase.java | 22 +-
.../Geo3dShapeSphereModelRectRelationTest.java | 4 +-
.../Geo3dShapeWGS84ModelRectRelationTest.java | 19 +-
.../spatial/vector/TestPointVectorStrategy.java | 55 +-
.../geopoint/document/GeoPointField.java | 2 +-
.../geopoint/search/GeoPointDistanceQuery.java | 19 +-
.../search/GeoPointDistanceQueryImpl.java | 19 +-
.../search/GeoPointDistanceRangeQuery.java | 122 --
.../geopoint/search/GeoPointInBBoxQuery.java | 8 +-
.../geopoint/search/GeoPointInPolygonQuery.java | 125 +-
.../search/GeoPointInPolygonQueryImpl.java | 46 +-
.../geopoint/search/GeoPointMultiTermQuery.java | 14 +-
.../lucene/spatial/util/GeoEncodingUtils.java | 24 +-
.../org/apache/lucene/spatial/util/GeoRect.java | 70 -
.../lucene/spatial/util/GeoRelationUtils.java | 203 ---
.../apache/lucene/spatial/util/GeoUtils.java | 155 ---
.../geopoint/search/GeoPointTestUtil.java | 287 ++++
.../geopoint/search/TestGeoPointQuery.java | 48 +-
.../search/TestLegacyGeoPointQuery.java | 60 +-
.../spatial/util/BaseGeoPointTestCase.java | 877 +++++++-----
.../spatial/util/TestGeoEncodingUtils.java | 102 ++
.../lucene/spatial/util/TestGeoUtils.java | 324 -----
.../org/apache/lucene/spatial3d/Geo3DPoint.java | 169 ++-
.../org/apache/lucene/spatial3d/Geo3DUtil.java | 64 +-
.../spatial3d/PointInGeo3DShapeQuery.java | 71 +-
.../spatial3d/PointInShapeIntersectVisitor.java | 97 ++
.../lucene/spatial3d/geom/BaseXYZSolid.java | 2 +-
.../lucene/spatial3d/geom/GeoBBoxFactory.java | 3 +-
.../lucene/spatial3d/geom/GeoBaseBBox.java | 2 +-
.../lucene/spatial3d/geom/GeoBaseCircle.java | 4 +-
.../lucene/spatial3d/geom/GeoBasePath.java | 34 +
.../lucene/spatial3d/geom/GeoBasePolygon.java | 4 +-
.../spatial3d/geom/GeoConcavePolygon.java | 411 ++++++
.../lucene/spatial3d/geom/GeoConvexPolygon.java | 209 ++-
.../geom/GeoDegenerateHorizontalLine.java | 2 +-
.../geom/GeoDegenerateLatitudeZone.java | 2 +-
.../geom/GeoDegenerateLongitudeSlice.java | 2 +-
.../spatial3d/geom/GeoDegeneratePoint.java | 2 +-
.../lucene/spatial3d/geom/GeoLatitudeZone.java | 2 +-
.../spatial3d/geom/GeoLongitudeSlice.java | 2 +-
.../spatial3d/geom/GeoNorthLatitudeZone.java | 2 +-
.../spatial3d/geom/GeoNorthRectangle.java | 2 +-
.../apache/lucene/spatial3d/geom/GeoPath.java | 776 +----------
.../lucene/spatial3d/geom/GeoPathFactory.java | 39 +
.../apache/lucene/spatial3d/geom/GeoPoint.java | 2 +-
.../spatial3d/geom/GeoPolygonFactory.java | 1295 ++++++++++++++++--
.../lucene/spatial3d/geom/GeoRectangle.java | 2 +-
.../spatial3d/geom/GeoSouthLatitudeZone.java | 2 +-
.../spatial3d/geom/GeoSouthRectangle.java | 2 +-
.../spatial3d/geom/GeoStandardCircle.java | 2 +-
.../lucene/spatial3d/geom/GeoStandardPath.java | 797 +++++++++++
.../geom/GeoWideDegenerateHorizontalLine.java | 2 +-
.../spatial3d/geom/GeoWideLongitudeSlice.java | 2 +-
.../spatial3d/geom/GeoWideNorthRectangle.java | 2 +-
.../lucene/spatial3d/geom/GeoWideRectangle.java | 2 +-
.../spatial3d/geom/GeoWideSouthRectangle.java | 2 +-
.../apache/lucene/spatial3d/geom/GeoWorld.java | 2 +-
.../lucene/spatial3d/geom/LatLonBounds.java | 18 +-
.../org/apache/lucene/spatial3d/geom/Plane.java | 44 +-
.../lucene/spatial3d/geom/PlanetModel.java | 28 +-
.../lucene/spatial3d/geom/SidedPlane.java | 20 +-
.../lucene/spatial3d/geom/StandardXYZSolid.java | 20 +-
.../apache/lucene/spatial3d/geom/XYZBounds.java | 20 +-
.../apache/lucene/spatial3d/geom/XYdZSolid.java | 2 +-
.../apache/lucene/spatial3d/geom/XdYZSolid.java | 2 +-
.../lucene/spatial3d/geom/XdYdZSolid.java | 2 +-
.../apache/lucene/spatial3d/geom/dXYZSolid.java | 2 +-
.../lucene/spatial3d/geom/dXYdZSolid.java | 2 +-
.../lucene/spatial3d/geom/dXdYZSolid.java | 2 +-
.../lucene/spatial3d/geom/dXdYdZSolid.java | 2 +-
.../apache/lucene/spatial3d/TestGeo3DPoint.java | 995 +++++++++++---
.../lucene/spatial3d/geom/GeoCircleTest.java | 15 -
.../lucene/spatial3d/geom/GeoPathTest.java | 36 +-
.../lucene/spatial3d/geom/GeoPolygonTest.java | 266 +++-
.../org/apache/lucene/geo/EarthDebugger.java | 288 ++++
.../java/org/apache/lucene/geo/GeoTestUtil.java | 407 ++++++
.../src/java/org/apache/lucene/geo/package.html | 26 +
.../apache/lucene/index/PointsStackTracker.java | 79 ++
solr/CHANGES.txt | 81 +-
.../analytics/accumulator/BasicAccumulator.java | 6 +-
.../accumulator/FacetingAccumulator.java | 8 +-
.../solr/analytics/expression/Expression.java | 14 +-
.../analytics/expression/ExpressionFactory.java | 9 +-
.../StatsCollectorSupplierFactory.java | 21 +-
.../solr/analytics/util/AnalyticsParsers.java | 7 +-
.../analytics/util/RangeEndpointCalculator.java | 5 +-
.../util/valuesource/ConstDateSource.java | 9 +-
.../util/valuesource/DateFieldSource.java | 6 +-
.../util/valuesource/FilterFieldSource.java | 3 +-
.../analytics/expression/ExpressionTest.java | 27 +-
.../handler/dataimport/SolrEntityProcessor.java | 10 +-
.../dataimport/TestContentStreamDataSource.java | 4 +-
.../TestSolrEntityProcessorEndToEnd.java | 2 +-
.../extraction/ExtractingRequestHandler.java | 23 +-
.../handler/extraction/ExtractionDateUtil.java | 178 +++
.../handler/extraction/SolrContentHandler.java | 12 +-
.../extraction/TestExtractionDateUtil.java | 61 +
.../src/java/org/apache/solr/hadoop/GoLive.java | 31 +-
.../solr/hadoop/MapReduceIndexerTool.java | 7 +-
.../apache/solr/hadoop/ZooKeeperInspector.java | 9 +-
.../solr/hadoop/MorphlineGoLiveMiniMRTest.java | 4 +-
.../solr/morphlines/cell/SolrCellBuilder.java | 18 +-
.../morphlines/cell/SolrCellMorphlineTest.java | 4 +-
.../solr/SafeConcurrentUpdateSolrClient.java | 2 +-
.../solr/morphlines/solr/SolrLocator.java | 5 +-
.../solr/AbstractSolrMorphlineTestBase.java | 2 +-
.../solr/SolrMorphlineZkAvroTest.java | 14 +-
.../client/solrj/embedded/JettySolrRunner.java | 25 +-
.../cloud/LeaderInitiatedRecoveryThread.java | 2 +-
.../java/org/apache/solr/cloud/Overseer.java | 1 +
.../OverseerAutoReplicaFailoverThread.java | 40 +-
.../cloud/OverseerCollectionMessageHandler.java | 2 +-
.../apache/solr/cloud/OverseerTaskQueue.java | 21 +-
.../org/apache/solr/cloud/RecoveryStrategy.java | 5 +-
.../org/apache/solr/cloud/SyncStrategy.java | 2 +-
.../src/java/org/apache/solr/cloud/ZkCLI.java | 13 +-
.../org/apache/solr/cloud/ZkController.java | 3 +-
.../solr/cloud/overseer/ZkStateWriter.java | 4 +-
.../apache/solr/cloud/rule/SnitchContext.java | 3 +-
.../org/apache/solr/core/BlobRepository.java | 3 +-
.../org/apache/solr/core/ConfigSetService.java | 9 +-
.../org/apache/solr/core/CoreContainer.java | 113 +-
.../apache/solr/core/HdfsDirectoryFactory.java | 21 +-
.../org/apache/solr/core/JmxMonitoredMap.java | 23 +-
.../src/java/org/apache/solr/core/SolrCore.java | 83 +-
.../java/org/apache/solr/core/SolrCores.java | 25 +-
.../apache/solr/core/SolrDeletionPolicy.java | 16 +-
.../apache/solr/core/SolrInfoMBeanWrapper.java | 62 +
.../solr/handler/CdcrReplicatorManager.java | 18 +-
.../solr/handler/CdcrReplicatorScheduler.java | 19 +-
.../solr/handler/CdcrReplicatorState.java | 21 +-
.../apache/solr/handler/CdcrRequestHandler.java | 2 +-
.../solr/handler/CdcrUpdateLogSynchronizer.java | 2 +-
.../org/apache/solr/handler/IndexFetcher.java | 56 +-
.../solr/handler/MoreLikeThisHandler.java | 12 +-
.../apache/solr/handler/PingRequestHandler.java | 6 +-
.../apache/solr/handler/ReplicationHandler.java | 23 +-
.../apache/solr/handler/SolrConfigHandler.java | 3 +-
.../org/apache/solr/handler/StreamHandler.java | 2 +
.../solr/handler/admin/CollectionsHandler.java | 3 +-
.../handler/component/HttpShardHandler.java | 100 +-
.../component/HttpShardHandlerFactory.java | 48 +-
.../component/IterativeMergeStrategy.java | 10 +-
.../solr/handler/component/PivotFacetValue.java | 3 +-
.../handler/component/RangeFacetRequest.java | 50 +-
.../request/PerSegmentSingleValuedFaceting.java | 9 +-
.../org/apache/solr/request/SimpleFacets.java | 35 +-
.../apache/solr/response/CSVResponseWriter.java | 10 +-
.../solr/response/TextResponseWriter.java | 3 +-
.../transform/ValueAugmenterFactory.java | 4 +-
.../org/apache/solr/rest/ManagedResource.java | 24 +-
.../solr/schema/AbstractSpatialFieldType.java | 7 +-
.../java/org/apache/solr/schema/BBoxField.java | 6 +-
.../org/apache/solr/schema/DateRangeField.java | 15 +-
.../apache/solr/schema/ManagedIndexSchema.java | 2 +-
.../schema/SpatialPointVectorFieldType.java | 23 +-
.../org/apache/solr/schema/TrieDateField.java | 5 +-
.../java/org/apache/solr/schema/TrieField.java | 32 +-
.../org/apache/solr/search/DocSetCollector.java | 84 +-
.../apache/solr/search/SolrFieldCacheMBean.java | 15 +-
.../apache/solr/search/ValueSourceParser.java | 37 +-
.../apache/solr/search/facet/FacetRange.java | 5 +-
.../solr/security/AuthenticationPlugin.java | 3 -
.../solr/security/HttpClientBuilderPlugin.java | 37 +
.../security/HttpClientInterceptorPlugin.java | 30 -
.../apache/solr/security/KerberosPlugin.java | 17 +-
.../solr/security/PKIAuthenticationPlugin.java | 45 +-
.../org/apache/solr/servlet/HttpSolrCall.java | 3 +-
.../apache/solr/update/SolrCmdDistributor.java | 14 +-
.../solr/update/StreamingSolrClients.java | 66 +-
.../apache/solr/update/UpdateShardHandler.java | 57 +-
.../DocExpirationUpdateProcessorFactory.java | 42 +-
.../org/apache/solr/util/DateFormatUtil.java | 245 ----
.../org/apache/solr/util/DateMathParser.java | 88 +-
.../src/java/org/apache/solr/util/SolrCLI.java | 44 +-
solr/core/src/test-files/log4j.properties | 4 +-
.../org/apache/solr/BasicFunctionalityTest.java | 29 +-
.../org/apache/solr/TestDistributedSearch.java | 12 +-
.../org/apache/solr/TestTolerantSearch.java | 6 +-
.../core/src/test/org/apache/solr/TestTrie.java | 13 +-
.../solr/client/solrj/ConnectionReuseTest.java | 195 +--
.../solrj/embedded/TestJettySolrRunner.java | 13 +-
.../apache/solr/cloud/AliasIntegrationTest.java | 14 +-
.../solr/cloud/AsyncMigrateRouteKeyTest.java | 2 +-
.../solr/cloud/BaseCdcrDistributedZkTest.java | 13 +-
.../solr/cloud/BasicDistributedZk2Test.java | 6 +-
.../solr/cloud/BasicDistributedZkTest.java | 115 +-
.../cloud/ChaosMonkeyNothingIsSafeTest.java | 54 +-
.../apache/solr/cloud/CollectionReloadTest.java | 2 +-
.../cloud/CollectionsAPIDistributedZkTest.java | 22 +-
.../solr/cloud/CollectionsAPISolrJTest.java | 2 +-
...ConcurrentDeleteAndCreateCollectionTest.java | 6 +-
.../apache/solr/cloud/CustomCollectionTest.java | 12 +-
.../solr/cloud/DeleteInactiveReplicaTest.java | 2 +-
.../apache/solr/cloud/DeleteReplicaTest.java | 4 +-
.../org/apache/solr/cloud/DeleteShardTest.java | 6 +-
.../solr/cloud/DistributedVersionInfoTest.java | 8 +-
.../org/apache/solr/cloud/ForceLeaderTest.java | 2 +-
.../cloud/FullSolrCloudDistribCmdsTest.java | 2 +-
.../apache/solr/cloud/HttpPartitionTest.java | 12 +-
.../cloud/LeaderFailoverAfterPartitionTest.java | 9 +-
.../LeaderInitiatedRecoveryOnCommitTest.java | 2 +-
...aderInitiatedRecoveryOnShardRestartTest.java | 2 +-
.../apache/solr/cloud/MigrateRouteKeyTest.java | 4 +-
.../solr/cloud/OverseerTaskQueueTest.java | 67 +
.../solr/cloud/ReplicationFactorTest.java | 2 +-
.../org/apache/solr/cloud/SSLMigrationTest.java | 4 +-
.../cloud/SegmentTerminateEarlyTestState.java | 6 +-
.../org/apache/solr/cloud/ShardSplitTest.java | 34 +-
.../org/apache/solr/cloud/SyncSliceTest.java | 2 +-
.../solr/cloud/TestAuthenticationFramework.java | 52 +-
.../solr/cloud/TestCloudDeleteByQuery.java | 22 +-
.../apache/solr/cloud/TestCloudPivotFacet.java | 23 +-
.../apache/solr/cloud/TestConfigSetsAPI.java | 20 +-
.../cloud/TestConfigSetsAPIExclusivity.java | 4 +-
.../solr/cloud/TestConfigSetsAPIZkFailure.java | 4 +-
.../org/apache/solr/cloud/TestCryptoKeys.java | 2 +-
.../cloud/TestMiniSolrCloudClusterBase.java | 2 +-
.../solr/cloud/TestMiniSolrCloudClusterSSL.java | 2 +-
.../cloud/TestRandomRequestDistribution.java | 104 +-
.../apache/solr/cloud/TestRebalanceLeaders.java | 18 +-
.../cloud/TestRequestStatusCollectionAPI.java | 2 +-
.../cloud/TestSolrCloudWithKerberosAlt.java | 13 +-
.../apache/solr/cloud/TestStressLiveNodes.java | 252 ++++
.../cloud/TestTolerantUpdateProcessorCloud.java | 28 +-
.../TestTolerantUpdateProcessorRandomCloud.java | 65 +-
.../solr/cloud/UnloadDistributedZkTest.java | 30 +-
.../test/org/apache/solr/cloud/ZkCLITest.java | 41 +-
.../org/apache/solr/cloud/ZkControllerTest.java | 9 +-
.../HdfsWriteToMultipleCollectionsTest.java | 2 +-
.../apache/solr/cloud/hdfs/StressHdfsTest.java | 2 +-
.../solr/cloud/overseer/ZkStateReaderTest.java | 5 +-
.../solr/core/OpenCloseCoreStressTest.java | 6 +-
.../org/apache/solr/core/TestCoreContainer.java | 1 -
.../apache/solr/core/TestDynamicLoading.java | 2 +-
.../apache/solr/core/TestJmxMonitoredMap.java | 37 +
.../solr/handler/TestReplicationHandler.java | 7 +-
.../handler/TestReplicationHandlerBackup.java | 5 +-
.../apache/solr/handler/TestRestoreCore.java | 5 +-
.../handler/admin/CoreAdminHandlerTest.java | 4 +-
.../DistributedDebugComponentTest.java | 6 +-
.../DistributedFacetPivotLargeTest.java | 3 +-
.../DistributedQueryElevationComponentTest.java | 4 +-
.../apache/solr/request/SimpleFacetsTest.java | 9 +-
.../solr/response/TestCSVResponseWriter.java | 14 +-
.../org/apache/solr/schema/DateFieldTest.java | 148 +-
.../solr/schema/TestUseDocValuesAsStored.java | 9 +-
.../solr/search/AnalyticsMergeStrategyTest.java | 7 +-
.../test/org/apache/solr/search/TestDocSet.java | 27 +-
.../org/apache/solr/search/TestRecovery.java | 7 +-
.../apache/solr/search/TestRecoveryHdfs.java | 13 +-
.../solr/search/TestSolrFieldCacheMBean.java | 36 +-
.../test/org/apache/solr/search/TestSolrJ.java | 4 +-
.../solr/search/stats/TestDistribIDF.java | 82 +-
.../solr/security/BasicAuthIntegrationTest.java | 42 +-
.../PKIAuthenticationIntegrationTest.java | 2 -
.../security/TestAuthorizationFramework.java | 3 +-
.../apache/solr/update/AddBlockUpdateTest.java | 20 +-
.../org/apache/solr/update/AutoCommitTest.java | 2 +-
.../test/org/apache/solr/update/TestUpdate.java | 16 +-
.../update/processor/AtomicUpdatesTest.java | 48 +-
.../processor/TestNamedUpdateProcessors.java | 3 +-
.../apache/solr/util/DateMathParserTest.java | 125 +-
.../apache/solr/util/TestSolrCLIRunExample.java | 4 +-
.../org/apache/solr/util/TestTestInjection.java | 2 +-
solr/licenses/junit4-ant-2.3.2.jar.sha1 | 1 -
solr/licenses/junit4-ant-2.3.4.jar.sha1 | 1 +
.../randomizedtesting-runner-2.3.2.jar.sha1 | 1 -
.../randomizedtesting-runner-2.3.4.jar.sha1 | 1 +
solr/server/etc/jetty-http.xml | 2 +-
solr/server/etc/jetty-https.xml | 2 +-
solr/server/etc/jetty.xml | 2 +-
.../org/apache/solr/client/solrj/SolrQuery.java | 21 +-
.../solr/client/solrj/impl/CloudSolrClient.java | 244 +++-
.../solrj/impl/ConcurrentUpdateSolrClient.java | 229 +++-
.../client/solrj/impl/HttpClientConfigurer.java | 100 --
.../solr/client/solrj/impl/HttpClientUtil.java | 438 +++---
.../solr/client/solrj/impl/HttpSolrClient.java | 196 +--
.../solrj/impl/Krb5HttpClientBuilder.java | 178 +++
.../solrj/impl/Krb5HttpClientConfigurer.java | 153 ---
.../client/solrj/impl/LBHttpSolrClient.java | 159 ++-
.../solrj/impl/SolrHttpClientBuilder.java | 91 ++
.../impl/SolrHttpClientContextBuilder.java | 96 ++
.../client/solrj/impl/XMLResponseParser.java | 27 +-
.../solr/client/solrj/io/SolrClientCache.java | 9 +-
.../client/solrj/io/comp/FieldComparator.java | 42 +-
.../solrj/io/graph/ShortestPathStream.java | 490 +++++++
.../client/solrj/io/graph/package-info.java | 22 +
.../solrj/io/sql/DatabaseMetaDataImpl.java | 4 +-
.../client/solrj/io/stream/CloudSolrStream.java | 7 +-
.../client/solrj/io/stream/FacetStream.java | 8 +-
.../solr/client/solrj/io/stream/SolrStream.java | 4 +-
.../client/solrj/io/stream/StatsStream.java | 7 +-
.../client/solrj/io/stream/TopicStream.java | 8 +-
.../client/solrj/io/stream/UpdateStream.java | 5 +-
.../client/solrj/io/stream/metrics/Bucket.java | 11 +-
.../solrj/request/CollectionAdminRequest.java | 61 +
.../solr/client/solrj/util/ClientUtils.java | 20 +-
.../solr/common/cloud/ZkConfigManager.java | 27 +-
.../apache/solr/common/cloud/ZkStateReader.java | 85 +-
.../org/apache/solr/common/util/DateUtil.java | 259 ----
solr/solrj/src/test-files/log4j.properties | 2 +
.../client/solrj/SolrExampleBinaryTest.java | 4 +-
.../solr/client/solrj/SolrExampleTests.java | 2 +-
.../solr/client/solrj/SolrExampleXMLTest.java | 4 +-
.../solr/client/solrj/SolrExceptionTest.java | 11 +-
.../apache/solr/client/solrj/SolrQueryTest.java | 18 +-
.../client/solrj/SolrSchemalessExampleTest.java | 9 +-
.../solr/client/solrj/TestLBHttpSolrClient.java | 23 +-
.../client/solrj/embedded/JettyWebappTest.java | 3 +-
.../solrj/embedded/SolrExampleJettyTest.java | 5 +-
.../embedded/SolrExampleStreamingTest.java | 23 +-
.../solrj/impl/BasicHttpSolrClientTest.java | 112 +-
.../solrj/impl/CloudSolrClientBuilderTest.java | 90 ++
.../client/solrj/impl/CloudSolrClientTest.java | 29 +-
.../ConcurrentUpdateSolrClientBuilderTest.java | 33 +
.../impl/ConcurrentUpdateSolrClientTest.java | 115 +-
.../solrj/impl/ExternalHttpClientTest.java | 75 -
.../client/solrj/impl/HttpClientUtilTest.java | 162 ---
.../solrj/impl/HttpSolrClientBuilderTest.java | 76 +
.../solrj/impl/LBHttpSolrClientBuilderTest.java | 65 +
.../client/solrj/impl/LBHttpSolrClientTest.java | 17 +-
.../solrj/io/graph/GraphExpressionTest.java | 404 ++++++
.../solr/client/solrj/io/graph/GraphTest.java | 387 ++++++
.../client/solrj/io/stream/StreamingTest.java | 48 +-
.../solr/client/solrj/request/SchemaTest.java | 9 +-
.../solrj/response/QueryResponseTest.java | 7 +-
.../solr/common/cloud/TestZkConfigManager.java | 7 +
.../apache/solr/common/util/TestDateUtil.java | 35 -
.../solr/BaseDistributedSearchTestCase.java | 63 +-
.../java/org/apache/solr/SolrJettyTestBase.java | 20 +-
.../java/org/apache/solr/SolrTestCaseHS.java | 40 +-
.../java/org/apache/solr/SolrTestCaseJ4.java | 165 ++-
.../cloud/AbstractFullDistribZkTestBase.java | 22 +-
.../apache/solr/cloud/MiniSolrCloudCluster.java | 19 +-
.../org/apache/solr/util/RestTestHarness.java | 4 +-
.../org/apache/solr/util/SSLTestConfig.java | 79 +-
solr/webapp/web/index.html | 2 +-
solr/webapp/web/js/angular/controllers/query.js | 9 +-
solr/webapp/web/js/angular/services.js | 4 +-
458 files changed, 16079 insertions(+), 7382 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/c948a905/solr/core/src/java/org/apache/solr/cloud/ZkController.java
----------------------------------------------------------------------
[37/50] lucene-solr:jira/SOLR-8908: tests: raise wait time
Posted by th...@apache.org.
tests: raise wait time
Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/6c9391df
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/6c9391df
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/6c9391df
Branch: refs/heads/jira/SOLR-8908
Commit: 6c9391df01bafe35b6e6f7d351f483b5242cb937
Parents: f2f4846
Author: markrmiller <ma...@apache.org>
Authored: Wed Apr 13 09:54:16 2016 -0400
Committer: markrmiller <ma...@apache.org>
Committed: Wed Apr 13 09:54:16 2016 -0400
----------------------------------------------------------------------
.../test/org/apache/solr/cloud/overseer/ZkStateReaderTest.java | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/6c9391df/solr/core/src/test/org/apache/solr/cloud/overseer/ZkStateReaderTest.java
----------------------------------------------------------------------
diff --git a/solr/core/src/test/org/apache/solr/cloud/overseer/ZkStateReaderTest.java b/solr/core/src/test/org/apache/solr/cloud/overseer/ZkStateReaderTest.java
index 3c45e23..8581995 100644
--- a/solr/core/src/test/org/apache/solr/cloud/overseer/ZkStateReaderTest.java
+++ b/solr/core/src/test/org/apache/solr/cloud/overseer/ZkStateReaderTest.java
@@ -95,7 +95,7 @@ public class ZkStateReaderTest extends SolrTestCaseJ4 {
if (explicitRefresh) {
reader.forceUpdateCollection("c1");
} else {
- for (int i = 0; i < 500; ++i) {
+ for (int i = 0; i < 1000; ++i) {
if (reader.getClusterState().hasCollection("c1")) {
break;
}
@@ -123,7 +123,7 @@ public class ZkStateReaderTest extends SolrTestCaseJ4 {
if (explicitRefresh) {
reader.forceUpdateCollection("c1");
} else {
- for (int i = 0; i < 500; ++i) {
+ for (int i = 0; i < 1000; ++i) {
if (reader.getClusterState().getCollection("c1").getStateFormat() == 2) {
break;
}
[22/50] lucene-solr:jira/SOLR-8908: LUCENE-7201: Handle illegal
rectangles during testing.
Posted by th...@apache.org.
LUCENE-7201: Handle illegal rectangles during testing.
Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/83bde558
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/83bde558
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/83bde558
Branch: refs/heads/jira/SOLR-8908
Commit: 83bde55865f56a5ffe660e0bde780b49b6adc4f8
Parents: 05dc902
Author: Karl Wright <Da...@gmail.com>
Authored: Mon Apr 11 12:55:21 2016 -0400
Committer: Karl Wright <Da...@gmail.com>
Committed: Mon Apr 11 12:55:21 2016 -0400
----------------------------------------------------------------------
.../src/test/org/apache/lucene/spatial3d/TestGeo3DPoint.java | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/83bde558/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 20302b4..deb3587 100644
--- a/lucene/spatial3d/src/test/org/apache/lucene/spatial3d/TestGeo3DPoint.java
+++ b/lucene/spatial3d/src/test/org/apache/lucene/spatial3d/TestGeo3DPoint.java
@@ -560,7 +560,11 @@ public class TestGeo3DPoint extends LuceneTestCase {
case 2: {
// Rectangles
final Rectangle r = GeoTestUtil.nextBox();
- return Geo3DPoint.newBoxQuery(field, r.minLat, r.maxLat, r.minLon, r.maxLon);
+ try {
+ return Geo3DPoint.newBoxQuery(field, r.minLat, r.maxLat, r.minLon, r.maxLon);
+ } catch (IllegalArgumentException e) {
+ continue;
+ }
}
case 3: {
[10/50] lucene-solr:jira/SOLR-8908: LUCENE-7199: Use a more refined
algorithm for picking the random pole used in clockwise/counterclockwise
determination.
Posted by th...@apache.org.
LUCENE-7199: Use a more refined algorithm for picking the random pole used in clockwise/counterclockwise determination.
Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/22ccccfc
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/22ccccfc
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/22ccccfc
Branch: refs/heads/jira/SOLR-8908
Commit: 22ccccfc3e945636106ad8450dc33bd5fb77f86d
Parents: 7441f88
Author: Karl Wright <Da...@gmail.com>
Authored: Sun Apr 10 08:58:19 2016 -0400
Committer: Karl Wright <Da...@gmail.com>
Committed: Sun Apr 10 08:58:19 2016 -0400
----------------------------------------------------------------------
.../spatial3d/geom/GeoPolygonFactory.java | 62 +++++++++++++++++++-
.../apache/lucene/spatial3d/TestGeo3DPoint.java | 11 +---
2 files changed, 61 insertions(+), 12 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/22ccccfc/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoPolygonFactory.java
----------------------------------------------------------------------
diff --git a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoPolygonFactory.java b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoPolygonFactory.java
index 7fc22dd..4b7f4f4 100755
--- a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoPolygonFactory.java
+++ b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoPolygonFactory.java
@@ -107,15 +107,16 @@ public class GeoPolygonFactory {
// Create a random number generator. Effectively this furnishes us with a repeatable sequence
// of points to use for poles.
final Random generator = new Random(1234);
+ //int counter = 0;
while (true) {
+ //counter++;
// Pick the next random pole
- final double poleLat = generator.nextDouble() * Math.PI - Math.PI * 0.5;
- final double poleLon = generator.nextDouble() * Math.PI * 2.0 - Math.PI;
- final GeoPoint pole = new GeoPoint(planetModel, poleLat, poleLon);
+ final GeoPoint pole = pickPole(generator, planetModel, pointList);
// Is it inside or outside?
final Boolean isPoleInside = isInsidePolygon(pole, pointList);
if (isPoleInside != null) {
// Legal pole
+ //System.out.println("Took "+counter+" iterations to find pole");
//System.out.println("Pole = "+pole+"; isInside="+isPoleInside+"; pointList = "+pointList);
return makeGeoPolygon(planetModel, pointList, holes, pole, isPoleInside);
}
@@ -169,6 +170,61 @@ public class GeoPolygonFactory {
}
}
+ /** The maximum distance from the close point to the trial pole: 2 degrees */
+ private final static double MAX_POLE_DISTANCE = Math.PI * 2.0 / 180.0;
+
+ /** Pick a random pole that has a good chance of being inside the polygon described by the points.
+ * @param generator is the random number generator to use.
+ * @param planetModel is the planet model to use.
+ * @param points is the list of points available.
+ * @return the randomly-determined pole selection.
+ */
+ private static GeoPoint pickPole(final Random generator, final PlanetModel planetModel, final List<GeoPoint> points) {
+ final int pointIndex = generator.nextInt(points.size());
+ final GeoPoint closePoint = points.get(pointIndex);
+ // We pick a random angle and random arc distance, then generate a point based on closePoint
+ final double angle = generator.nextDouble() * Math.PI * 2.0 - Math.PI;
+ final double arcDistance = MAX_POLE_DISTANCE - generator.nextDouble() * MAX_POLE_DISTANCE;
+ // We come up with a unit circle (x,y,z) coordinate given the random angle and arc distance. The point is centered around the positive x axis.
+ final double x = Math.cos(arcDistance);
+ final double sinArcDistance = Math.sin(arcDistance);
+ final double y = Math.cos(angle) * sinArcDistance;
+ final double z = Math.sin(angle) * sinArcDistance;
+ // Now, use closePoint for a rotation pole
+ final double sinLatitude = Math.sin(closePoint.getLatitude());
+ final double cosLatitude = Math.cos(closePoint.getLatitude());
+ final double sinLongitude = Math.sin(closePoint.getLongitude());
+ final double cosLongitude = Math.cos(closePoint.getLongitude());
+ // This transformation should take the point (1,0,0) and transform it to the closepoint's actual (x,y,z) coordinates.
+ // Coordinate rotation formula:
+ // x1 = x0 cos T - y0 sin T
+ // y1 = x0 sin T + y0 cos T
+ // We're in essence undoing the following transformation (from GeoPolygonFactory):
+ // x1 = x0 cos az + y0 sin az
+ // y1 = - x0 sin az + y0 cos az
+ // z1 = z0
+ // x2 = x1 cos al + z1 sin al
+ // y2 = y1
+ // z2 = - x1 sin al + z1 cos al
+ // So, we reverse the order of the transformations, AND we transform backwards.
+ // Transforming backwards means using these identities: sin(-angle) = -sin(angle), cos(-angle) = cos(angle)
+ // So:
+ // x1 = x0 cos al - z0 sin al
+ // y1 = y0
+ // z1 = x0 sin al + z0 cos al
+ // x2 = x1 cos az - y1 sin az
+ // y2 = x1 sin az + y1 cos az
+ // z2 = z1
+ final double x1 = x * cosLatitude - z * sinLatitude;
+ final double y1 = y;
+ final double z1 = x * sinLatitude + z * cosLatitude;
+ final double x2 = x1 * cosLongitude - y1 * sinLongitude;
+ final double y2 = x1 * sinLongitude + y1 * cosLongitude;
+ final double z2 = z1;
+ // Finally, scale to put the point on the surface
+ return planetModel.createSurfacePoint(x2, y2, z2);
+ }
+
/** For a specified point and a list of poly points, determine based on point order whether the
* point should be considered in or out of the polygon.
* @param point is the point to check.
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/22ccccfc/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 c80f3bb..9ec0e30 100644
--- a/lucene/spatial3d/src/test/org/apache/lucene/spatial3d/TestGeo3DPoint.java
+++ b/lucene/spatial3d/src/test/org/apache/lucene/spatial3d/TestGeo3DPoint.java
@@ -1023,15 +1023,8 @@ public class TestGeo3DPoint extends LuceneTestCase {
final double x2 = x1 * cosLongitude - y1 * sinLongitude;
final double y2 = x1 * sinLongitude + y1 * cosLongitude;
final double z2 = z1;
-
- // Scale final (x,y,z) to land on planet surface
- // Equation of ellipsoid: x^2 / a^2 + y^2 / b^2 + z^2 / c^2 - 1 = 0
- // Use a parameterization, e.g. x = t * x2, y = t * y2, z = t * z2, and find t.
- // t^2 ( x2^2 / a^2 + y2^2 / b^2 + z2^2 / c^2 ) = 1
- // t = +/- sqrt( 1 / ( x2^2 / a^2 + y2^2 / b^2 + z2^2 / c^2 ) )
- // We want the + variant because we're scaling in the same direction as the original vector.
- final double t = Math.sqrt( 1.0 / (x2 * x2 * pm.inverseAbSquared + y2 * y2 * pm.inverseAbSquared + z2 * z2 * pm.inverseCSquared));
- return new GeoPoint(x2 * t, y2 * t, z2 * t);
+ // Scale to put the point on the surface
+ return pm.createSurfacePoint(x2, y2, z2);
}
protected static boolean verifyPolygon(final PlanetModel pm, final Polygon polygon, final GeoPolygon outsidePolygon) {
[15/50] lucene-solr:jira/SOLR-8908: fix rare test bug
Posted by th...@apache.org.
fix rare test bug
Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/604fb28b
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/604fb28b
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/604fb28b
Branch: refs/heads/jira/SOLR-8908
Commit: 604fb28b586cdb7248fff29f8a181dd1c7b54483
Parents: 273d586
Author: Mike McCandless <mi...@apache.org>
Authored: Mon Apr 11 05:24:34 2016 -0400
Committer: Mike McCandless <mi...@apache.org>
Committed: Mon Apr 11 05:24:34 2016 -0400
----------------------------------------------------------------------
.../lucene/facet/range/TestRangeFacetCounts.java | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/604fb28b/lucene/facet/src/test/org/apache/lucene/facet/range/TestRangeFacetCounts.java
----------------------------------------------------------------------
diff --git a/lucene/facet/src/test/org/apache/lucene/facet/range/TestRangeFacetCounts.java b/lucene/facet/src/test/org/apache/lucene/facet/range/TestRangeFacetCounts.java
index 626d772..18645e7 100644
--- a/lucene/facet/src/test/org/apache/lucene/facet/range/TestRangeFacetCounts.java
+++ b/lucene/facet/src/test/org/apache/lucene/facet/range/TestRangeFacetCounts.java
@@ -22,14 +22,14 @@ import java.util.Map;
import java.util.Set;
import java.util.concurrent.atomic.AtomicBoolean;
-import org.apache.lucene.document.DoublePoint;
-import org.apache.lucene.document.LongPoint;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.DoubleDocValuesField;
+import org.apache.lucene.document.DoublePoint;
+import org.apache.lucene.document.LongPoint;
import org.apache.lucene.document.NumericDocValuesField;
import org.apache.lucene.facet.DrillDownQuery;
-import org.apache.lucene.facet.DrillSideways;
import org.apache.lucene.facet.DrillSideways.DrillSidewaysResult;
+import org.apache.lucene.facet.DrillSideways;
import org.apache.lucene.facet.FacetField;
import org.apache.lucene.facet.FacetResult;
import org.apache.lucene.facet.FacetTestCase;
@@ -59,6 +59,7 @@ import org.apache.lucene.search.Scorer;
import org.apache.lucene.search.Weight;
import org.apache.lucene.store.Directory;
import org.apache.lucene.util.IOUtils;
+import org.apache.lucene.util.NumericUtils;
import org.apache.lucene.util.TestUtil;
public class TestRangeFacetCounts extends FacetTestCase {
@@ -532,7 +533,11 @@ public class TestRangeFacetCounts extends FacetTestCase {
boolean minIncl;
boolean maxIncl;
- if (min == max) {
+
+ long minAsLong = NumericUtils.doubleToSortableLong(min);
+ long maxAsLong = NumericUtils.doubleToSortableLong(max);
+ // NOTE: maxAsLong - minAsLong >= 0 is here to handle the common overflow case!
+ if (maxAsLong - minAsLong >= 0 && maxAsLong - minAsLong < 2) {
minIncl = true;
maxIncl = true;
} else {
[35/50] lucene-solr:jira/SOLR-8908: improve randomized polygon
generation to sometimes include regular ngons
Posted by th...@apache.org.
improve randomized polygon generation to sometimes include regular ngons
Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/e076b4c5
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/e076b4c5
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/e076b4c5
Branch: refs/heads/jira/SOLR-8908
Commit: e076b4c5b485599941d15fe08683c54831e84564
Parents: 67f6283
Author: Mike McCandless <mi...@apache.org>
Authored: Wed Apr 13 05:51:38 2016 -0400
Committer: Mike McCandless <mi...@apache.org>
Committed: Wed Apr 13 05:51:38 2016 -0400
----------------------------------------------------------------------
.../java/org/apache/lucene/geo/GeoTestUtil.java | 85 ++++++++++++++++++++
1 file changed, 85 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/e076b4c5/lucene/test-framework/src/java/org/apache/lucene/geo/GeoTestUtil.java
----------------------------------------------------------------------
diff --git a/lucene/test-framework/src/java/org/apache/lucene/geo/GeoTestUtil.java b/lucene/test-framework/src/java/org/apache/lucene/geo/GeoTestUtil.java
index 9e719c0..f7d4eae 100644
--- a/lucene/test-framework/src/java/org/apache/lucene/geo/GeoTestUtil.java
+++ b/lucene/test-framework/src/java/org/apache/lucene/geo/GeoTestUtil.java
@@ -20,6 +20,7 @@ import java.util.ArrayList;
import java.util.Random;
import org.apache.lucene.util.NumericUtils;
+import org.apache.lucene.util.SloppyMath;
import org.apache.lucene.util.TestUtil;
import com.carrotsearch.randomizedtesting.RandomizedContext;
@@ -135,10 +136,94 @@ public class GeoTestUtil {
nextLongitudeNear(otherLongitude), nextLongitudeNear(otherLongitude), false);
}
+ /** Makes an n-gon, centered at the provided lat/lon, and each vertex approximately
+ * distanceMeters away from the center.
+ *
+ * Do not invoke me across the dateline or a pole!! */
+ public static Polygon createRegularPolygon(double centerLat, double centerLon, double radiusMeters, int gons) {
+
+ // System.out.println("MAKE POLY: centerLat=" + centerLat + " centerLon=" + centerLon + " radiusMeters=" + radiusMeters + " gons=" + gons);
+
+ double[][] result = new double[2][];
+ result[0] = new double[gons+1];
+ result[1] = new double[gons+1];
+ //System.out.println("make gon=" + gons);
+ for(int i=0;i<gons;i++) {
+ double angle = 360.0-i*(360.0/gons);
+ //System.out.println(" angle " + angle);
+ double x = Math.cos(Math.toRadians(angle));
+ double y = Math.sin(Math.toRadians(angle));
+ double factor = 2.0;
+ double step = 1.0;
+ int last = 0;
+
+ //System.out.println("angle " + angle + " slope=" + slope);
+ // Iterate out along one spoke until we hone in on the point that's nearly exactly radiusMeters from the center:
+ while (true) {
+
+ // TODO: we could in fact cross a pole? Just do what surpriseMePolygon does?
+ double lat = centerLat + y * factor;
+ GeoUtils.checkLatitude(lat);
+ double lon = centerLon + x * factor;
+ GeoUtils.checkLongitude(lon);
+ double distanceMeters = SloppyMath.haversinMeters(centerLat, centerLon, lat, lon);
+
+ //System.out.println(" iter lat=" + lat + " lon=" + lon + " distance=" + distanceMeters + " vs " + radiusMeters);
+ if (Math.abs(distanceMeters - radiusMeters) < 0.1) {
+ // Within 10 cm: close enough!
+ result[0][i] = lat;
+ result[1][i] = lon;
+ break;
+ }
+
+ if (distanceMeters > radiusMeters) {
+ // too big
+ //System.out.println(" smaller");
+ factor -= step;
+ if (last == 1) {
+ //System.out.println(" half-step");
+ step /= 2.0;
+ }
+ last = -1;
+ } else if (distanceMeters < radiusMeters) {
+ // too small
+ //System.out.println(" bigger");
+ factor += step;
+ if (last == -1) {
+ //System.out.println(" half-step");
+ step /= 2.0;
+ }
+ last = 1;
+ }
+ }
+ }
+
+ // close poly
+ result[0][gons] = result[0][0];
+ result[1][gons] = result[1][0];
+
+ //System.out.println(" polyLats=" + Arrays.toString(result[0]));
+ //System.out.println(" polyLons=" + Arrays.toString(result[1]));
+
+ return new Polygon(result[0], result[1]);
+ }
+
/** returns next pseudorandom polygon */
public static Polygon nextPolygon() {
if (random().nextBoolean()) {
return surpriseMePolygon(null, null);
+ } else if (random().nextInt(10) == 1) {
+ // this poly is slow to create ... only do it 10% of the time:
+ while (true) {
+ int gons = TestUtil.nextInt(random(), 4, 500);
+ // So the poly can cover at most 50% of the earth's surface:
+ double radiusMeters = random().nextDouble() * GeoUtils.EARTH_MEAN_RADIUS_METERS * Math.PI / 2.0 + 1.0;
+ try {
+ return createRegularPolygon(nextLatitude(), nextLongitude(), radiusMeters, gons);
+ } catch (IllegalArgumentException iae) {
+ // we tried to cross dateline or pole ... try again
+ }
+ }
}
Rectangle box = nextBoxInternal(nextLatitude(), nextLatitude(), nextLongitude(), nextLongitude(), false);
[19/50] lucene-solr:jira/SOLR-8908: LUCENE-7185: fix random number
generation used for spatial tests.
Posted by th...@apache.org.
LUCENE-7185: fix random number generation used for spatial tests.
Note that GeoPoint tests are still on the old RNG as we haven't get made them happy.
Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/901a3af3
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/901a3af3
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/901a3af3
Branch: refs/heads/jira/SOLR-8908
Commit: 901a3af301f81331459cddb87e4fbf1a4437303b
Parents: 812c8da
Author: Robert Muir <rm...@apache.org>
Authored: Mon Apr 11 10:36:10 2016 -0400
Committer: Robert Muir <rm...@apache.org>
Committed: Mon Apr 11 10:36:10 2016 -0400
----------------------------------------------------------------------
.../geopoint/search/GeoPointTestUtil.java | 287 +++++++++++++++++++
.../geopoint/search/TestGeoPointQuery.java | 42 +++
.../search/TestLegacyGeoPointQuery.java | 43 ++-
.../spatial/util/BaseGeoPointTestCase.java | 79 +++--
.../java/org/apache/lucene/geo/GeoTestUtil.java | 46 ++-
5 files changed, 469 insertions(+), 28 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/901a3af3/lucene/spatial/src/test/org/apache/lucene/spatial/geopoint/search/GeoPointTestUtil.java
----------------------------------------------------------------------
diff --git a/lucene/spatial/src/test/org/apache/lucene/spatial/geopoint/search/GeoPointTestUtil.java b/lucene/spatial/src/test/org/apache/lucene/spatial/geopoint/search/GeoPointTestUtil.java
new file mode 100644
index 0000000..a8c4271
--- /dev/null
+++ b/lucene/spatial/src/test/org/apache/lucene/spatial/geopoint/search/GeoPointTestUtil.java
@@ -0,0 +1,287 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.lucene.spatial.geopoint.search;
+
+import java.util.ArrayList;
+import java.util.Random;
+
+import org.apache.lucene.geo.GeoUtils;
+import org.apache.lucene.geo.Polygon;
+import org.apache.lucene.geo.Rectangle;
+
+import com.carrotsearch.randomizedtesting.RandomizedContext;
+
+// HACK: this is a wimpier version of GeoTestUtil used for now until we can
+// get all tests passing with new random number generator!
+
+final class GeoPointTestUtil {
+
+ /** returns next pseudorandom latitude (anywhere) */
+ public static double nextLatitude() {
+ return -90 + 180.0 * random().nextDouble();
+ }
+
+ /** returns next pseudorandom longitude (anywhere) */
+ public static double nextLongitude() {
+ return -180 + 360.0 * random().nextDouble();
+ }
+
+ /** returns next pseudorandom latitude, kinda close to {@code otherLatitude} */
+ public static double nextLatitudeNear(double otherLatitude) {
+ GeoUtils.checkLatitude(otherLatitude);
+ return normalizeLatitude(otherLatitude + random().nextDouble() - 0.5);
+ }
+
+ /** returns next pseudorandom longitude, kinda close to {@code otherLongitude} */
+ public static double nextLongitudeNear(double otherLongitude) {
+ GeoUtils.checkLongitude(otherLongitude);
+ return normalizeLongitude(otherLongitude + random().nextDouble() - 0.5);
+ }
+
+ /**
+ * returns next pseudorandom latitude, kinda close to {@code minLatitude/maxLatitude}
+ * <b>NOTE:</b>minLatitude/maxLatitude are merely guidelines. the returned value is sometimes
+ * outside of that range! this is to facilitate edge testing.
+ */
+ public static double nextLatitudeAround(double minLatitude, double maxLatitude) {
+ GeoUtils.checkLatitude(minLatitude);
+ GeoUtils.checkLatitude(maxLatitude);
+ return normalizeLatitude(randomRangeMaybeSlightlyOutside(minLatitude, maxLatitude));
+ }
+
+ /**
+ * returns next pseudorandom longitude, kinda close to {@code minLongitude/maxLongitude}
+ * <b>NOTE:</b>minLongitude/maxLongitude are merely guidelines. the returned value is sometimes
+ * outside of that range! this is to facilitate edge testing.
+ */
+ public static double nextLongitudeAround(double minLongitude, double maxLongitude) {
+ GeoUtils.checkLongitude(minLongitude);
+ GeoUtils.checkLongitude(maxLongitude);
+ return normalizeLongitude(randomRangeMaybeSlightlyOutside(minLongitude, maxLongitude));
+ }
+
+ /** returns next pseudorandom box: can cross the 180th meridian */
+ public static Rectangle nextBox() {
+ return nextBoxInternal(nextLatitude(), nextLatitude(), nextLongitude(), nextLongitude(), true);
+ }
+
+ /** returns next pseudorandom box: will not cross the 180th meridian */
+ public static Rectangle nextSimpleBox() {
+ return nextBoxInternal(nextLatitude(), nextLatitude(), nextLongitude(), nextLongitude(), false);
+ }
+
+ /** returns next pseudorandom box, can cross the 180th meridian, kinda close to {@code otherLatitude} and {@code otherLongitude} */
+ public static Rectangle nextBoxNear(double otherLatitude, double otherLongitude) {
+ GeoUtils.checkLongitude(otherLongitude);
+ GeoUtils.checkLongitude(otherLongitude);
+ return nextBoxInternal(nextLatitudeNear(otherLatitude), nextLatitudeNear(otherLatitude),
+ nextLongitudeNear(otherLongitude), nextLongitudeNear(otherLongitude), true);
+ }
+
+ /** returns next pseudorandom box, will not cross the 180th meridian, kinda close to {@code otherLatitude} and {@code otherLongitude} */
+ public static Rectangle nextSimpleBoxNear(double otherLatitude, double otherLongitude) {
+ GeoUtils.checkLongitude(otherLongitude);
+ GeoUtils.checkLongitude(otherLongitude);
+ return nextBoxInternal(nextLatitudeNear(otherLatitude), nextLatitudeNear(otherLatitude),
+ nextLongitudeNear(otherLongitude), nextLongitudeNear(otherLongitude), false);
+ }
+
+ /** returns next pseudorandom polygon */
+ public static Polygon nextPolygon() {
+ if (random().nextBoolean()) {
+ return surpriseMePolygon(null, null);
+ }
+
+ Rectangle box = nextBoxInternal(nextLatitude(), nextLatitude(), nextLongitude(), nextLongitude(), false);
+ if (random().nextBoolean()) {
+ // box
+ return boxPolygon(box);
+ } else {
+ // triangle
+ return trianglePolygon(box);
+ }
+ }
+
+ /** returns next pseudorandom polygon, kinda close to {@code otherLatitude} and {@code otherLongitude} */
+ public static Polygon nextPolygonNear(double otherLatitude, double otherLongitude) {
+ if (random().nextBoolean()) {
+ return surpriseMePolygon(otherLatitude, otherLongitude);
+ }
+
+ Rectangle box = nextBoxInternal(nextLatitudeNear(otherLatitude), nextLatitudeNear(otherLatitude),
+ nextLongitudeNear(otherLongitude), nextLongitudeNear(otherLongitude), false);
+ if (random().nextBoolean()) {
+ // box
+ return boxPolygon(box);
+ } else {
+ // triangle
+ return trianglePolygon(box);
+ }
+ }
+
+ private static Rectangle nextBoxInternal(double lat0, double lat1, double lon0, double lon1, boolean canCrossDateLine) {
+ if (lat1 < lat0) {
+ double x = lat0;
+ lat0 = lat1;
+ lat1 = x;
+ }
+
+ if (canCrossDateLine == false && lon1 < lon0) {
+ double x = lon0;
+ lon0 = lon1;
+ lon1 = x;
+ }
+
+ return new Rectangle(lat0, lat1, lon0, lon1);
+ }
+
+ private static Polygon boxPolygon(Rectangle box) {
+ assert box.crossesDateline() == false;
+ final double[] polyLats = new double[5];
+ final double[] polyLons = new double[5];
+ polyLats[0] = box.minLat;
+ polyLons[0] = box.minLon;
+ polyLats[1] = box.maxLat;
+ polyLons[1] = box.minLon;
+ polyLats[2] = box.maxLat;
+ polyLons[2] = box.maxLon;
+ polyLats[3] = box.minLat;
+ polyLons[3] = box.maxLon;
+ polyLats[4] = box.minLat;
+ polyLons[4] = box.minLon;
+ return new Polygon(polyLats, polyLons);
+ }
+
+ private static Polygon trianglePolygon(Rectangle box) {
+ assert box.crossesDateline() == false;
+ final double[] polyLats = new double[4];
+ final double[] polyLons = new double[4];
+ polyLats[0] = box.minLat;
+ polyLons[0] = box.minLon;
+ polyLats[1] = box.maxLat;
+ polyLons[1] = box.minLon;
+ polyLats[2] = box.maxLat;
+ polyLons[2] = box.maxLon;
+ polyLats[3] = box.minLat;
+ polyLons[3] = box.minLon;
+ return new Polygon(polyLats, polyLons);
+ }
+
+ private static Polygon surpriseMePolygon(Double otherLatitude, Double otherLongitude) {
+ // repeat until we get a poly that doesn't cross dateline:
+ newPoly:
+ while (true) {
+ //System.out.println("\nPOLY ITER");
+ final double centerLat;
+ final double centerLon;
+ if (otherLatitude == null) {
+ centerLat = nextLatitude();
+ centerLon = nextLongitude();
+ } else {
+ GeoUtils.checkLatitude(otherLatitude);
+ GeoUtils.checkLongitude(otherLongitude);
+ centerLat = nextLatitudeNear(otherLatitude);
+ centerLon = nextLongitudeNear(otherLongitude);
+ }
+
+ double radius = 0.1 + 20 * random().nextDouble();
+ double radiusDelta = random().nextDouble();
+
+ ArrayList<Double> lats = new ArrayList<>();
+ ArrayList<Double> lons = new ArrayList<>();
+ double angle = 0.0;
+ while (true) {
+ angle += random().nextDouble()*40.0;
+ //System.out.println(" angle " + angle);
+ if (angle > 360) {
+ break;
+ }
+ double len = radius * (1.0 - radiusDelta + radiusDelta * random().nextDouble());
+ //System.out.println(" len=" + len);
+ double lat = centerLat + len * Math.cos(Math.toRadians(angle));
+ double lon = centerLon + len * Math.sin(Math.toRadians(angle));
+ if (lon <= GeoUtils.MIN_LON_INCL || lon >= GeoUtils.MAX_LON_INCL) {
+ // cannot cross dateline: try again!
+ continue newPoly;
+ }
+ if (lat > 90) {
+ // cross the north pole
+ lat = 180 - lat;
+ lon = 180 - lon;
+ } else if (lat < -90) {
+ // cross the south pole
+ lat = -180 - lat;
+ lon = 180 - lon;
+ }
+ if (lon <= GeoUtils.MIN_LON_INCL || lon >= GeoUtils.MAX_LON_INCL) {
+ // cannot cross dateline: try again!
+ continue newPoly;
+ }
+ lats.add(lat);
+ lons.add(lon);
+
+ //System.out.println(" lat=" + lats.get(lats.size()-1) + " lon=" + lons.get(lons.size()-1));
+ }
+
+ // close it
+ lats.add(lats.get(0));
+ lons.add(lons.get(0));
+
+ double[] latsArray = new double[lats.size()];
+ double[] lonsArray = new double[lons.size()];
+ for(int i=0;i<lats.size();i++) {
+ latsArray[i] = lats.get(i);
+ lonsArray[i] = lons.get(i);
+ }
+ return new Polygon(latsArray, lonsArray);
+ }
+ }
+
+ /** Returns random double min to max or up to 1% outside of that range */
+ private static double randomRangeMaybeSlightlyOutside(double min, double max) {
+ return min + (random().nextDouble() + (0.5 - random().nextDouble()) * .02) * (max - min);
+ }
+
+ /** Puts latitude in range of -90 to 90. */
+ private static double normalizeLatitude(double latitude) {
+ if (latitude >= -90 && latitude <= 90) {
+ return latitude; //common case, and avoids slight double precision shifting
+ }
+ double off = Math.abs((latitude + 90) % 360);
+ return (off <= 180 ? off : 360-off) - 90;
+ }
+
+ /** Puts longitude in range of -180 to +180. */
+ private static double normalizeLongitude(double longitude) {
+ if (longitude >= -180 && longitude <= 180) {
+ return longitude; //common case, and avoids slight double precision shifting
+ }
+ double off = (longitude + 180) % 360;
+ if (off < 0) {
+ return 180 + off;
+ } else if (off == 0 && longitude > 0) {
+ return 180;
+ } else {
+ return -180 + off;
+ }
+ }
+
+ /** Keep it simple, we don't need to take arbitrary Random for geo tests */
+ private static Random random() {
+ return RandomizedContext.current().getRandom();
+ }
+}
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/901a3af3/lucene/spatial/src/test/org/apache/lucene/spatial/geopoint/search/TestGeoPointQuery.java
----------------------------------------------------------------------
diff --git a/lucene/spatial/src/test/org/apache/lucene/spatial/geopoint/search/TestGeoPointQuery.java b/lucene/spatial/src/test/org/apache/lucene/spatial/geopoint/search/TestGeoPointQuery.java
index ff8baca..7e64430 100644
--- a/lucene/spatial/src/test/org/apache/lucene/spatial/geopoint/search/TestGeoPointQuery.java
+++ b/lucene/spatial/src/test/org/apache/lucene/spatial/geopoint/search/TestGeoPointQuery.java
@@ -20,6 +20,7 @@ import org.apache.lucene.document.Document;
import org.apache.lucene.search.Query;
import org.apache.lucene.spatial.util.GeoEncodingUtils;
import org.apache.lucene.geo.Polygon;
+import org.apache.lucene.geo.Rectangle;
import org.apache.lucene.spatial.geopoint.document.GeoPointField;
import org.apache.lucene.spatial.geopoint.document.GeoPointField.TermEncoding;
import org.apache.lucene.spatial.util.BaseGeoPointTestCase;
@@ -61,4 +62,45 @@ public class TestGeoPointQuery extends BaseGeoPointTestCase {
return new GeoPointInPolygonQuery(field, TermEncoding.PREFIX, polygons);
}
+ // TODO: remove these once we get tests passing!
+
+ @Override
+ protected double nextLongitude() {
+ return GeoPointTestUtil.nextLongitude();
+ }
+
+ @Override
+ protected double nextLongitudeNear(double other) {
+ return GeoPointTestUtil.nextLongitudeNear(other);
+ }
+
+ @Override
+ protected double nextLatitude() {
+ return GeoPointTestUtil.nextLatitude();
+ }
+
+ @Override
+ protected double nextLatitudeNear(double other) {
+ return GeoPointTestUtil.nextLatitudeNear(other);
+ }
+
+ @Override
+ protected Rectangle nextBox() {
+ return GeoPointTestUtil.nextBox();
+ }
+
+ @Override
+ protected Rectangle nextBoxNear(double latitude, double longitude) {
+ return GeoPointTestUtil.nextBoxNear(latitude, longitude);
+ }
+
+ @Override
+ protected Polygon nextPolygon() {
+ return GeoPointTestUtil.nextPolygon();
+ }
+
+ @Override
+ protected Polygon nextPolygonNear(double latitude, double longitude) {
+ return GeoPointTestUtil.nextPolygonNear(latitude, longitude);
+ }
}
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/901a3af3/lucene/spatial/src/test/org/apache/lucene/spatial/geopoint/search/TestLegacyGeoPointQuery.java
----------------------------------------------------------------------
diff --git a/lucene/spatial/src/test/org/apache/lucene/spatial/geopoint/search/TestLegacyGeoPointQuery.java b/lucene/spatial/src/test/org/apache/lucene/spatial/geopoint/search/TestLegacyGeoPointQuery.java
index 4c8e3e3..75cc377 100644
--- a/lucene/spatial/src/test/org/apache/lucene/spatial/geopoint/search/TestLegacyGeoPointQuery.java
+++ b/lucene/spatial/src/test/org/apache/lucene/spatial/geopoint/search/TestLegacyGeoPointQuery.java
@@ -20,6 +20,7 @@ import org.apache.lucene.document.Document;
import org.apache.lucene.search.Query;
import org.apache.lucene.spatial.util.GeoEncodingUtils;
import org.apache.lucene.geo.Polygon;
+import org.apache.lucene.geo.Rectangle;
import org.apache.lucene.spatial.geopoint.document.GeoPointField;
import org.apache.lucene.spatial.geopoint.document.GeoPointField.TermEncoding;
import org.apache.lucene.spatial.util.BaseGeoPointTestCase;
@@ -77,5 +78,45 @@ public class TestLegacyGeoPointQuery extends BaseGeoPointTestCase {
assumeTrue("legacy encoding goes OOM on this test", false);
}
-
+ // TODO: remove these once we get tests passing!
+
+ @Override
+ protected double nextLongitude() {
+ return GeoPointTestUtil.nextLongitude();
+ }
+
+ @Override
+ protected double nextLongitudeNear(double other) {
+ return GeoPointTestUtil.nextLongitudeNear(other);
+ }
+
+ @Override
+ protected double nextLatitude() {
+ return GeoPointTestUtil.nextLatitude();
+ }
+
+ @Override
+ protected double nextLatitudeNear(double other) {
+ return GeoPointTestUtil.nextLatitudeNear(other);
+ }
+
+ @Override
+ protected Rectangle nextBox() {
+ return GeoPointTestUtil.nextBox();
+ }
+
+ @Override
+ protected Rectangle nextBoxNear(double latitude, double longitude) {
+ return GeoPointTestUtil.nextBoxNear(latitude, longitude);
+ }
+
+ @Override
+ protected Polygon nextPolygon() {
+ return GeoPointTestUtil.nextPolygon();
+ }
+
+ @Override
+ protected Polygon nextPolygonNear(double latitude, double longitude) {
+ return GeoPointTestUtil.nextPolygonNear(latitude, longitude);
+ }
}
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/901a3af3/lucene/spatial/src/test/org/apache/lucene/spatial/util/BaseGeoPointTestCase.java
----------------------------------------------------------------------
diff --git a/lucene/spatial/src/test/org/apache/lucene/spatial/util/BaseGeoPointTestCase.java b/lucene/spatial/src/test/org/apache/lucene/spatial/util/BaseGeoPointTestCase.java
index adca466..c2536bd 100644
--- a/lucene/spatial/src/test/org/apache/lucene/spatial/util/BaseGeoPointTestCase.java
+++ b/lucene/spatial/src/test/org/apache/lucene/spatial/util/BaseGeoPointTestCase.java
@@ -38,7 +38,6 @@ import org.apache.lucene.document.NumericDocValuesField;
import org.apache.lucene.document.StoredField;
import org.apache.lucene.document.StringField;
import org.apache.lucene.geo.Rectangle;
-import org.apache.lucene.geo.GeoTestUtil;
import org.apache.lucene.geo.GeoUtils;
import org.apache.lucene.geo.Polygon;
import org.apache.lucene.index.DirectoryReader;
@@ -68,7 +67,6 @@ import org.apache.lucene.util.LuceneTestCase;
import org.apache.lucene.util.SloppyMath;
import org.apache.lucene.util.TestUtil;
import org.apache.lucene.util.bkd.BKDWriter;
-import org.junit.BeforeClass;
/**
* Abstract class to do basic tests for a geospatial impl (high level
@@ -85,13 +83,48 @@ public abstract class BaseGeoPointTestCase extends LuceneTestCase {
protected static final String FIELD_NAME = "point";
- private static double originLat;
- private static double originLon;
+ private double originLat;
+ private double originLon;
- @BeforeClass
- public static void beforeClassBase() throws Exception {
- originLon = GeoTestUtil.nextLongitude();
- originLat = GeoTestUtil.nextLatitude();
+ @Override
+ public void setUp() throws Exception {
+ super.setUp();
+ originLon = nextLongitude();
+ originLat = nextLatitude();
+ }
+
+ // TODO: remove these hooks once all subclasses can pass with new random!
+
+ protected double nextLongitude() {
+ return org.apache.lucene.geo.GeoTestUtil.nextLongitude();
+ }
+
+ protected double nextLongitudeNear(double other) {
+ return org.apache.lucene.geo.GeoTestUtil.nextLongitudeNear(other);
+ }
+
+ protected double nextLatitude() {
+ return org.apache.lucene.geo.GeoTestUtil.nextLatitude();
+ }
+
+ protected double nextLatitudeNear(double other) {
+ return org.apache.lucene.geo.GeoTestUtil.nextLatitudeNear(other);
+ }
+
+ protected Rectangle nextBox() {
+ return org.apache.lucene.geo.GeoTestUtil.nextBox();
+ }
+
+ protected Rectangle nextBoxNear(double latitude, double longitude) {
+ return org.apache.lucene.geo.GeoTestUtil.nextBoxNear(latitude, longitude);
+ }
+
+ protected Polygon nextPolygon() {
+ return org.apache.lucene.geo.GeoTestUtil.nextPolygon();
+ }
+
+ protected Polygon nextPolygonNear(double latitude, double longitude) {
+ return org.apache.lucene.geo.GeoTestUtil.nextPolygonNear(latitude, longitude);
}
/** Valid values that should not cause exception */
@@ -691,19 +724,19 @@ public abstract class BaseGeoPointTestCase extends LuceneTestCase {
verify(small, lats, lons);
}
- public double randomLat(boolean small) {
+ public final double randomLat(boolean small) {
if (small) {
- return GeoTestUtil.nextLatitudeNear(originLat);
+ return nextLatitudeNear(originLat);
} else {
- return GeoTestUtil.nextLatitude();
+ return nextLatitude();
}
}
- public double randomLon(boolean small) {
+ public final double randomLon(boolean small) {
if (small) {
- return GeoTestUtil.nextLongitudeNear(originLon);
+ return nextLongitudeNear(originLon);
} else {
- return GeoTestUtil.nextLongitude();
+ return nextLongitude();
}
}
@@ -719,11 +752,11 @@ public abstract class BaseGeoPointTestCase extends LuceneTestCase {
return lon;
}
- protected Rectangle randomRect(boolean small) {
+ protected final Rectangle randomRect(boolean small) {
if (small) {
- return GeoTestUtil.nextBoxNear(originLat, originLon);
+ return nextBoxNear(originLat, originLon);
} else {
- return GeoTestUtil.nextBox();
+ return nextBox();
}
}
@@ -1102,9 +1135,9 @@ public abstract class BaseGeoPointTestCase extends LuceneTestCase {
// Polygon
final Polygon polygon;
if (small) {
- polygon = GeoTestUtil.nextPolygonNear(originLat, originLon);
+ polygon = nextPolygonNear(originLat, originLon);
} else {
- polygon = GeoTestUtil.nextPolygon();
+ polygon = nextPolygon();
}
Query query = newPolygonQuery(FIELD_NAME, polygon);
@@ -1291,8 +1324,8 @@ public abstract class BaseGeoPointTestCase extends LuceneTestCase {
RandomIndexWriter writer = new RandomIndexWriter(random(), dir, iwc);
for (int i = 0; i < numDocs; i++) {
- double latRaw = GeoTestUtil.nextLatitude();
- double lonRaw = GeoTestUtil.nextLongitude();
+ double latRaw = nextLatitude();
+ double lonRaw = nextLongitude();
// pre-normalize up front, so we can just use quantized value for testing and do simple exact comparisons
double lat = quantizeLat(latRaw);
double lon = quantizeLon(lonRaw);
@@ -1306,8 +1339,8 @@ public abstract class BaseGeoPointTestCase extends LuceneTestCase {
IndexSearcher searcher = newSearcher(reader);
for (int i = 0; i < numQueries; i++) {
- double lat = GeoTestUtil.nextLatitude();
- double lon = GeoTestUtil.nextLongitude();
+ double lat = nextLatitude();
+ double lon = nextLongitude();
double radius = 50000000D * random().nextDouble();
BitSet expected = new BitSet();
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/901a3af3/lucene/test-framework/src/java/org/apache/lucene/geo/GeoTestUtil.java
----------------------------------------------------------------------
diff --git a/lucene/test-framework/src/java/org/apache/lucene/geo/GeoTestUtil.java b/lucene/test-framework/src/java/org/apache/lucene/geo/GeoTestUtil.java
index 23e3416..9e719c0 100644
--- a/lucene/test-framework/src/java/org/apache/lucene/geo/GeoTestUtil.java
+++ b/lucene/test-framework/src/java/org/apache/lucene/geo/GeoTestUtil.java
@@ -17,24 +17,62 @@
package org.apache.lucene.geo;
import java.util.ArrayList;
-import java.util.List;
import java.util.Random;
-import org.apache.lucene.util.SloppyMath;
+import org.apache.lucene.util.NumericUtils;
+import org.apache.lucene.util.TestUtil;
import com.carrotsearch.randomizedtesting.RandomizedContext;
/** static methods for testing geo */
public class GeoTestUtil {
+ private static final long LATITUDE_MIN_SORTABLE = NumericUtils.doubleToSortableLong(-90);
+ private static final long LATITUDE_MAX_SORTABLE = NumericUtils.doubleToSortableLong(90);
+
/** returns next pseudorandom latitude (anywhere) */
public static double nextLatitude() {
- return -90 + 180.0 * random().nextDouble();
+ int surpriseMe = random().nextInt(17);
+ if (surpriseMe == 0) {
+ // random bitpattern in range
+ return NumericUtils.sortableLongToDouble(TestUtil.nextLong(random(), LATITUDE_MIN_SORTABLE, LATITUDE_MAX_SORTABLE));
+ } else if (surpriseMe == 1) {
+ // edge case
+ return -90.0;
+ } else if (surpriseMe == 2) {
+ // edge case
+ return 90.0;
+ } else if (surpriseMe == 3) {
+ // may trigger divide by zero
+ return 0.0;
+ } else {
+ // distributed ~ evenly
+ return -90 + 180.0 * random().nextDouble();
+ }
}
+ private static final long LONGITUDE_MIN_SORTABLE = NumericUtils.doubleToSortableLong(-180);
+ private static final long LONGITUDE_MAX_SORTABLE = NumericUtils.doubleToSortableLong(180);
+
/** returns next pseudorandom longitude (anywhere) */
public static double nextLongitude() {
- return -180 + 360.0 * random().nextDouble();
+ int surpriseMe = random().nextInt(17);
+ if (surpriseMe == 0) {
+ // random bitpattern in range
+ return NumericUtils.sortableLongToDouble(TestUtil.nextLong(random(), LONGITUDE_MIN_SORTABLE, LONGITUDE_MAX_SORTABLE));
+ } else if (surpriseMe == 1) {
+ // edge case
+ return -180.0;
+ } else if (surpriseMe == 2) {
+ // edge case
+ return 180.0;
+ } else if (surpriseMe == 3) {
+ // may trigger divide by 0
+ return 0.0;
+ } else {
+ // distributed ~ evenly
+ return -180 + 360.0 * random().nextDouble();
+ }
}
/** returns next pseudorandom latitude, kinda close to {@code otherLatitude} */
[42/50] lucene-solr:jira/SOLR-8908: SOLR-7729:
ConcurrentUpdateSolrClient ignores the collection parameter in some methods.
Posted by th...@apache.org.
SOLR-7729: ConcurrentUpdateSolrClient ignores the collection parameter in some methods.
Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/0a5f7f8b
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/0a5f7f8b
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/0a5f7f8b
Branch: refs/heads/jira/SOLR-8908
Commit: 0a5f7f8b5e35a053031cc89b40e7c315cfcef82d
Parents: 79195a8
Author: markrmiller <ma...@apache.org>
Authored: Wed Apr 13 10:55:21 2016 -0400
Committer: markrmiller <ma...@apache.org>
Committed: Wed Apr 13 10:55:21 2016 -0400
----------------------------------------------------------------------
solr/CHANGES.txt | 3 +
.../solrj/impl/ConcurrentUpdateSolrClient.java | 65 +++++++++++++---
.../impl/ConcurrentUpdateSolrClientTest.java | 78 +++++++++++++++++++-
3 files changed, 132 insertions(+), 14 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/0a5f7f8b/solr/CHANGES.txt
----------------------------------------------------------------------
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index fbe4698..fc50468 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -111,6 +111,9 @@ Bug Fixes
* SOLR-8914: ZkStateReader's refreshLiveNodes(Watcher) is not thread safe. (Scott Blum, hoss,
sarowe, Erick Erickson, Mark Miller, shalin)
+* SOLR-7729: ConcurrentUpdateSolrClient ignores the collection parameter in some methods.
+ (Nicolas Gavalda, Jorge Luis Betancourt Gonzalez via Mark Miller)
+
Optimizations
----------------------
* SOLR-8722: Don't force a full ZkStateReader refresh on every Overseer operation.
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/0a5f7f8b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/ConcurrentUpdateSolrClient.java
----------------------------------------------------------------------
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/ConcurrentUpdateSolrClient.java b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/ConcurrentUpdateSolrClient.java
index 2551957..f209672 100644
--- a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/ConcurrentUpdateSolrClient.java
+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/ConcurrentUpdateSolrClient.java
@@ -77,7 +77,7 @@ public class ConcurrentUpdateSolrClient extends SolrClient {
private static final long serialVersionUID = 1L;
private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
private HttpSolrClient client;
- final BlockingQueue<UpdateRequest> queue;
+ final BlockingQueue<Update> queue;
final ExecutorService scheduler;
final Queue<Runner> runners;
volatile CountDownLatch lock = null; // used to block everything
@@ -224,15 +224,15 @@ public class ConcurrentUpdateSolrClient extends SolrClient {
InputStream rspBody = null;
try {
- final UpdateRequest updateRequest =
+ final Update update =
queue.poll(pollQueueTime, TimeUnit.MILLISECONDS);
- if (updateRequest == null)
+ if (update == null)
break;
String contentType = client.requestWriter.getUpdateContentType();
final boolean isXml = ClientUtils.TEXT_XML.equals(contentType);
- final ModifiableSolrParams origParams = new ModifiableSolrParams(updateRequest.getParams());
+ final ModifiableSolrParams origParams = new ModifiableSolrParams(update.getRequest().getParams());
EntityTemplate template = new EntityTemplate(new ContentProducer() {
@@ -242,11 +242,12 @@ public class ConcurrentUpdateSolrClient extends SolrClient {
if (isXml) {
out.write("<stream>".getBytes(StandardCharsets.UTF_8)); // can be anything
}
- UpdateRequest req = updateRequest;
- while (req != null) {
+ Update upd = update;
+ while (upd != null) {
+ UpdateRequest req = upd.getRequest();
SolrParams currentParams = new ModifiableSolrParams(req.getParams());
if (!origParams.toNamedList().equals(currentParams.toNamedList())) {
- queue.add(req); // params are different, push back to queue
+ queue.add(upd); // params are different, push back to queue
break;
}
@@ -274,9 +275,9 @@ public class ConcurrentUpdateSolrClient extends SolrClient {
if (pollQueueTime > 0 && threadCount == 1 && req.isLastDocInBatch()) {
// no need to wait to see another doc in the queue if we've hit the last doc in a batch
- req = queue.poll(0, TimeUnit.MILLISECONDS);
+ upd = queue.poll(0, TimeUnit.MILLISECONDS);
} else {
- req = queue.poll(pollQueueTime, TimeUnit.MILLISECONDS);
+ upd = queue.poll(pollQueueTime, TimeUnit.MILLISECONDS);
}
}
@@ -298,7 +299,11 @@ public class ConcurrentUpdateSolrClient extends SolrClient {
requestParams.set(CommonParams.WT, client.parser.getWriterType());
requestParams.set(CommonParams.VERSION, client.parser.getVersion());
- method = new HttpPost(client.getBaseURL() + "/update"
+ String basePath = client.getBaseURL();
+ if (update.getCollection() != null)
+ basePath += "/" + update.getCollection();
+
+ method = new HttpPost(basePath + "/update"
+ requestParams.toQueryString());
org.apache.http.client.config.RequestConfig.Builder requestConfigBuilder = HttpClientUtil.createDefaultRequestConfigBuilder();
@@ -373,6 +378,41 @@ public class ConcurrentUpdateSolrClient extends SolrClient {
}
}
+ /**
+ * Class representing an UpdateRequest and an optional collection.
+ */
+ class Update {
+ UpdateRequest request;
+ String collection;
+ /**
+ *
+ * @param request the update request.
+ * @param collection The collection, can be null.
+ */
+ public Update(UpdateRequest request, String collection) {
+ this.request = request;
+ this.collection = collection;
+ }
+ /**
+ * @return the update request.
+ */
+ public UpdateRequest getRequest() {
+ return request;
+ }
+ public void setRequest(UpdateRequest request) {
+ this.request = request;
+ }
+ /**
+ * @return the collection, can be null.
+ */
+ public String getCollection() {
+ return collection;
+ }
+ public void setCollection(String collection) {
+ this.collection = collection;
+ }
+ }
+
@Override
public NamedList<Object> request(final SolrRequest request, String collection)
throws SolrServerException, IOException {
@@ -415,7 +455,8 @@ public class ConcurrentUpdateSolrClient extends SolrClient {
tmpLock.await();
}
- boolean success = queue.offer(req);
+ Update update = new Update(req, collection);
+ boolean success = queue.offer(update);
for (;;) {
synchronized (runners) {
@@ -448,7 +489,7 @@ public class ConcurrentUpdateSolrClient extends SolrClient {
// start more runners.
//
if (!success) {
- success = queue.offer(req, 100, TimeUnit.MILLISECONDS);
+ success = queue.offer(update, 100, TimeUnit.MILLISECONDS);
}
}
} catch (InterruptedException e) {
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/0a5f7f8b/solr/solrj/src/test/org/apache/solr/client/solrj/impl/ConcurrentUpdateSolrClientTest.java
----------------------------------------------------------------------
diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/impl/ConcurrentUpdateSolrClientTest.java b/solr/solrj/src/test/org/apache/solr/client/solrj/impl/ConcurrentUpdateSolrClientTest.java
index 5e2baeb..de728bd 100644
--- a/solr/solrj/src/test/org/apache/solr/client/solrj/impl/ConcurrentUpdateSolrClientTest.java
+++ b/solr/solrj/src/test/org/apache/solr/client/solrj/impl/ConcurrentUpdateSolrClientTest.java
@@ -18,6 +18,8 @@ package org.apache.solr.client.solrj.impl;
import org.apache.http.HttpResponse;
import org.apache.solr.SolrJettyTestBase;
+import org.apache.solr.client.solrj.SolrQuery;
+import org.apache.solr.client.solrj.SolrServerException;
import org.apache.solr.client.solrj.embedded.JettyConfig;
import org.apache.solr.client.solrj.request.JavaBinUpdateRequestCodec;
import org.apache.solr.client.solrj.request.UpdateRequest;
@@ -39,7 +41,6 @@ import java.util.Enumeration;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
@@ -187,16 +188,86 @@ public class ConcurrentUpdateSolrClientTest extends SolrJettyTestBase {
TestServlet.numDocsRcvd.get() == expectedDocs);
}
+ @Test
+ public void testCollectionParameters() throws IOException, SolrServerException {
+
+ int cussThreadCount = 2;
+ int cussQueueSize = 10;
+
+ try (ConcurrentUpdateSolrClient concurrentClient = new ConcurrentUpdateSolrClient(jetty.getBaseUrl().toString(), cussQueueSize, cussThreadCount)) {
+ SolrInputDocument doc = new SolrInputDocument();
+ doc.addField("id", "collection");
+ concurrentClient.add("collection1", doc);
+ concurrentClient.commit("collection1");
+
+ assertEquals(1, concurrentClient.query("collection1", new SolrQuery("id:collection")).getResults().getNumFound());
+ }
+
+ try (ConcurrentUpdateSolrClient concurrentClient = new ConcurrentUpdateSolrClient(jetty.getBaseUrl().toString() + "/collection1", cussQueueSize, cussThreadCount)) {
+ assertEquals(1, concurrentClient.query(new SolrQuery("id:collection")).getResults().getNumFound());
+ }
+
+ }
+
+ @Test
+ public void testConcurrentCollectionUpdate() throws Exception {
+
+ int cussThreadCount = 2;
+ int cussQueueSize = 100;
+ int numDocs = 100;
+ int numRunnables = 5;
+ int expected = numDocs * numRunnables;
+
+ try (ConcurrentUpdateSolrClient concurrentClient = new ConcurrentUpdateSolrClient(jetty.getBaseUrl().toString(), cussQueueSize, cussThreadCount)) {
+ concurrentClient.setPollQueueTime(0);
+
+ // ensure it doesn't block where there's nothing to do yet
+ concurrentClient.blockUntilFinished();
+
+ // Delete all existing documents.
+ concurrentClient.deleteByQuery("collection1", "*:*");
+
+ int poolSize = 5;
+ ExecutorService threadPool = ExecutorUtil.newMDCAwareFixedThreadPool(poolSize, new SolrjNamedThreadFactory("testCUSS"));
+
+ for (int r=0; r < numRunnables; r++)
+ threadPool.execute(new SendDocsRunnable(String.valueOf(r), numDocs, concurrentClient, "collection1"));
+
+ // ensure all docs are sent
+ threadPool.awaitTermination(5, TimeUnit.SECONDS);
+ threadPool.shutdown();
+
+ concurrentClient.commit("collection1");
+
+ assertEquals(expected, concurrentClient.query("collection1", new SolrQuery("*:*")).getResults().getNumFound());
+
+ // wait until all requests are processed by CUSS
+ concurrentClient.blockUntilFinished();
+ concurrentClient.shutdownNow();
+ }
+
+ try (ConcurrentUpdateSolrClient concurrentClient = new ConcurrentUpdateSolrClient(jetty.getBaseUrl().toString() + "/collection1", cussQueueSize, cussThreadCount)) {
+ assertEquals(expected, concurrentClient.query(new SolrQuery("*:*")).getResults().getNumFound());
+ }
+
+ }
+
class SendDocsRunnable implements Runnable {
private String id;
private int numDocs;
private ConcurrentUpdateSolrClient cuss;
+ private String collection;
SendDocsRunnable(String id, int numDocs, ConcurrentUpdateSolrClient cuss) {
+ this(id, numDocs, cuss, null);
+ }
+
+ SendDocsRunnable(String id, int numDocs, ConcurrentUpdateSolrClient cuss, String collection) {
this.id = id;
this.numDocs = numDocs;
this.cuss = cuss;
+ this.collection = collection;
}
@Override
@@ -208,7 +279,10 @@ public class ConcurrentUpdateSolrClientTest extends SolrJettyTestBase {
UpdateRequest req = new UpdateRequest();
req.add(doc);
try {
- cuss.request(req);
+ if (this.collection == null)
+ cuss.request(req);
+ else
+ cuss.request(req, this.collection);
} catch (Throwable t) {
t.printStackTrace();
}
[44/50] lucene-solr:jira/SOLR-8908: SOLR:8976: Add SolrJ support for
REBALANCELEADERS Collections API
Posted by th...@apache.org.
SOLR:8976: Add SolrJ support for REBALANCELEADERS Collections API
Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/689e9664
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/689e9664
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/689e9664
Branch: refs/heads/jira/SOLR-8908
Commit: 689e9664c51d4701300a1b843e6a430b7d90e67c
Parents: 478a2a4
Author: Anshum Gupta <an...@apache.org>
Authored: Wed Apr 13 12:10:00 2016 -0700
Committer: Anshum Gupta <an...@apache.org>
Committed: Wed Apr 13 12:10:26 2016 -0700
----------------------------------------------------------------------
solr/CHANGES.txt | 2 +
.../apache/solr/cloud/TestRebalanceLeaders.java | 18 +++++-
.../solrj/request/CollectionAdminRequest.java | 61 ++++++++++++++++++++
3 files changed, 80 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/689e9664/solr/CHANGES.txt
----------------------------------------------------------------------
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index b379716..b2b7ecd 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -91,6 +91,8 @@ New Features
* SOLR-8938: Add optional -excluderegex argument to ZkCLI. (Christine Poerschke)
+* SOLR-8976: Add SolrJ support for REBALANCELEADERS Collections API (Anshum Gupta)
+
Bug Fixes
----------------------
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/689e9664/solr/core/src/test/org/apache/solr/cloud/TestRebalanceLeaders.java
----------------------------------------------------------------------
diff --git a/solr/core/src/test/org/apache/solr/cloud/TestRebalanceLeaders.java b/solr/core/src/test/org/apache/solr/cloud/TestRebalanceLeaders.java
index 9208229..798a8a8 100644
--- a/solr/core/src/test/org/apache/solr/cloud/TestRebalanceLeaders.java
+++ b/solr/core/src/test/org/apache/solr/cloud/TestRebalanceLeaders.java
@@ -26,6 +26,7 @@ import java.util.concurrent.TimeUnit;
import org.apache.solr.client.solrj.SolrRequest;
import org.apache.solr.client.solrj.SolrServerException;
import org.apache.solr.client.solrj.impl.CloudSolrClient;
+import org.apache.solr.client.solrj.request.CollectionAdminRequest;
import org.apache.solr.client.solrj.request.QueryRequest;
import org.apache.solr.common.cloud.Replica;
import org.apache.solr.common.cloud.Slice;
@@ -276,7 +277,21 @@ public class TestRebalanceLeaders extends AbstractFullDistribZkTestBase {
fail("Waited for timeout for preferredLeader assignments to be made and they werent.");
}
//fillExpectedWithCurrent();
- // Now rebalance the leaders
+ // Now rebalance the leaders randomly using SolrJ or direct call
+ if(random().nextBoolean())
+ rebalanceLeaderUsingSolrJAPI();
+ else
+ rebalanceLeaderUsingDirectCall();
+
+ }
+
+ private void rebalanceLeaderUsingSolrJAPI() throws IOException, SolrServerException {
+ CollectionAdminRequest.RebalanceLeaders rebalanceLeaders = CollectionAdminRequest.rebalanceLeaders(COLLECTION_NAME);
+ rebalanceLeaders.setMaxAtOnce(10)
+ .process(cloudClient);
+ }
+
+ private void rebalanceLeaderUsingDirectCall() throws IOException, SolrServerException {
ModifiableSolrParams params = new ModifiableSolrParams();
params.set("action", CollectionParams.CollectionAction.REBALANCELEADERS.toString());
@@ -286,6 +301,7 @@ public class TestRebalanceLeaders extends AbstractFullDistribZkTestBase {
SolrRequest request = new QueryRequest(params);
request.setPath("/admin/collections");
cloudClient.request(request);
+
}
void issuePreferred(String slice, Replica rep) throws IOException, SolrServerException, InterruptedException {
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/689e9664/solr/solrj/src/java/org/apache/solr/client/solrj/request/CollectionAdminRequest.java
----------------------------------------------------------------------
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/request/CollectionAdminRequest.java b/solr/solrj/src/java/org/apache/solr/client/solrj/request/CollectionAdminRequest.java
index 0c25e09..ac829f1 100644
--- a/solr/solrj/src/java/org/apache/solr/client/solrj/request/CollectionAdminRequest.java
+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/request/CollectionAdminRequest.java
@@ -490,6 +490,67 @@ public abstract class CollectionAdminRequest<T extends CollectionAdminResponse>
}
}
+ /*
+ * Returns a RebalanceLeaders object to rebalance leaders for a collection
+ */
+ public static RebalanceLeaders rebalanceLeaders(String collection) {
+ return new RebalanceLeaders(collection);
+ }
+
+ public static class RebalanceLeaders extends AsyncCollectionAdminRequest {
+
+ protected Integer maxAtOnce;
+ protected Integer maxWaitSeconds;
+ protected String collection;
+
+ public RebalanceLeaders setMaxAtOnce(Integer maxAtOnce) {
+ this.maxAtOnce = maxAtOnce;
+ return this;
+ }
+
+ public RebalanceLeaders setMaxWaitSeconds(Integer maxWaitSeconds) {
+ this.maxWaitSeconds = maxWaitSeconds;
+ return this;
+ }
+
+ public Integer getMaxAtOnce() {
+ return maxAtOnce;
+ }
+
+ public Integer getMaxWaitSeconds() {
+ return maxWaitSeconds;
+ }
+
+ public RebalanceLeaders(String collection) {
+ super(CollectionAction.REBALANCELEADERS);
+ this.collection = collection;
+ }
+
+ @Override
+ public RebalanceLeaders setAsyncId(String id) {
+ this.asyncId = id;
+ return this;
+ }
+
+ @Override
+ public SolrParams getParams() {
+ ModifiableSolrParams params = (ModifiableSolrParams) super.getParams();
+
+ params.set(CoreAdminParams.COLLECTION, collection);
+
+ if(this.maxWaitSeconds != null) {
+ params.set("maxWaitSeconds", this.maxWaitSeconds);
+ }
+
+ if(this.maxAtOnce != null) {
+ params.set("maxAtOnce", this.maxAtOnce);
+ }
+
+ return params;
+ }
+
+ }
+
/**
* Returns a SolrRequest to delete a collection
*/
[12/50] lucene-solr:jira/SOLR-8908: LUCENE-7187: Block join queries'
Weight#extractTerms(...) implementations should delegate to the wrapped
weight.
Posted by th...@apache.org.
LUCENE-7187: Block join queries' Weight#extractTerms(...) implementations should delegate to the wrapped weight.
Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/d7867b80
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/d7867b80
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/d7867b80
Branch: refs/heads/jira/SOLR-8908
Commit: d7867b80f83beb0d30c5341f2a9d3ab6a35d70c7
Parents: dd8c199
Author: Martijn van Groningen <mv...@apache.org>
Authored: Mon Apr 11 09:20:39 2016 +0200
Committer: Martijn van Groningen <mv...@apache.org>
Committed: Mon Apr 11 09:20:39 2016 +0200
----------------------------------------------------------------------
lucene/CHANGES.txt | 3 ++
.../search/join/ToChildBlockJoinQuery.java | 4 ++-
.../search/join/ToParentBlockJoinQuery.java | 6 ++--
.../lucene/search/join/TestBlockJoin.java | 32 +++++++++++++++++++-
4 files changed, 40 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/d7867b80/lucene/CHANGES.txt
----------------------------------------------------------------------
diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txt
index 8209415..6b549f2 100644
--- a/lucene/CHANGES.txt
+++ b/lucene/CHANGES.txt
@@ -73,6 +73,9 @@ Bug Fixes
* LUCENE-7168: Switch to stable encode for geo3d, remove quantization
test leniency, remove dead code (Mike McCandless)
+* LUCENE-7187: Block join queries' Weight#extractTerms(...) implementations
+ should delegate to the wrapped weight. (Martijn van Groningen)
+
Other
* LUCENE-7174: Upgrade randomizedtesting to 2.3.4. (Uwe Schindler, Dawid Weiss)
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/d7867b80/lucene/join/src/java/org/apache/lucene/search/join/ToChildBlockJoinQuery.java
----------------------------------------------------------------------
diff --git a/lucene/join/src/java/org/apache/lucene/search/join/ToChildBlockJoinQuery.java b/lucene/join/src/java/org/apache/lucene/search/join/ToChildBlockJoinQuery.java
index d381cae..237b786 100644
--- a/lucene/join/src/java/org/apache/lucene/search/join/ToChildBlockJoinQuery.java
+++ b/lucene/join/src/java/org/apache/lucene/search/join/ToChildBlockJoinQuery.java
@@ -103,7 +103,9 @@ public class ToChildBlockJoinQuery extends Query {
}
@Override
- public void extractTerms(Set<Term> terms) {}
+ public void extractTerms(Set<Term> terms) {
+ parentWeight.extractTerms(terms);
+ }
@Override
public float getValueForNormalization() throws IOException {
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/d7867b80/lucene/join/src/java/org/apache/lucene/search/join/ToParentBlockJoinQuery.java
----------------------------------------------------------------------
diff --git a/lucene/join/src/java/org/apache/lucene/search/join/ToParentBlockJoinQuery.java b/lucene/join/src/java/org/apache/lucene/search/join/ToParentBlockJoinQuery.java
index f004fde..2a0ebaf 100644
--- a/lucene/join/src/java/org/apache/lucene/search/join/ToParentBlockJoinQuery.java
+++ b/lucene/join/src/java/org/apache/lucene/search/join/ToParentBlockJoinQuery.java
@@ -125,21 +125,21 @@ public class ToParentBlockJoinQuery extends Query {
}
private static class BlockJoinWeight extends Weight {
- private final Query joinQuery;
private final Weight childWeight;
private final BitSetProducer parentsFilter;
private final ScoreMode scoreMode;
public BlockJoinWeight(Query joinQuery, Weight childWeight, BitSetProducer parentsFilter, ScoreMode scoreMode) {
super(joinQuery);
- this.joinQuery = joinQuery;
this.childWeight = childWeight;
this.parentsFilter = parentsFilter;
this.scoreMode = scoreMode;
}
@Override
- public void extractTerms(Set<Term> terms) {}
+ public void extractTerms(Set<Term> terms) {
+ childWeight.extractTerms(terms);
+ }
@Override
public float getValueForNormalization() throws IOException {
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/d7867b80/lucene/join/src/test/org/apache/lucene/search/join/TestBlockJoin.java
----------------------------------------------------------------------
diff --git a/lucene/join/src/test/org/apache/lucene/search/join/TestBlockJoin.java b/lucene/join/src/test/org/apache/lucene/search/join/TestBlockJoin.java
index 01a8135..a67b0ec 100644
--- a/lucene/join/src/test/org/apache/lucene/search/join/TestBlockJoin.java
+++ b/lucene/join/src/test/org/apache/lucene/search/join/TestBlockJoin.java
@@ -20,8 +20,10 @@ import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
+import java.util.HashSet;
import java.util.List;
import java.util.Locale;
+import java.util.Set;
import org.apache.lucene.analysis.MockAnalyzer;
import org.apache.lucene.document.Document;
@@ -101,7 +103,35 @@ public class TestBlockJoin extends LuceneTestCase {
job.add(new IntPoint("year", year));
return job;
}
-
+
+ public void testExtractTerms() throws Exception {
+ TermQuery termQuery = new TermQuery(new Term("field", "value"));
+ QueryBitSetProducer bitSetProducer = new QueryBitSetProducer(new MatchNoDocsQuery());
+ ToParentBlockJoinQuery toParentBlockJoinQuery = new ToParentBlockJoinQuery(termQuery, bitSetProducer, ScoreMode.None);
+ ToChildBlockJoinQuery toChildBlockJoinQuery = new ToChildBlockJoinQuery(toParentBlockJoinQuery, bitSetProducer);
+
+ Directory directory = newDirectory();
+ final IndexWriter w = new IndexWriter(directory, new IndexWriterConfig(new MockAnalyzer(random())));
+ w.close();
+ IndexReader indexReader = DirectoryReader.open(directory);
+ IndexSearcher indexSearcher = new IndexSearcher(indexReader);
+
+ Weight weight = toParentBlockJoinQuery.createWeight(indexSearcher, false);
+ Set<Term> terms = new HashSet<>();
+ weight.extractTerms(terms);
+ Term[] termArr =terms.toArray(new Term[0]);
+ assertEquals(1, termArr.length);
+
+ weight = toChildBlockJoinQuery.createWeight(indexSearcher, false);
+ terms = new HashSet<>();
+ weight.extractTerms(terms);
+ termArr =terms.toArray(new Term[0]);
+ assertEquals(1, termArr.length);
+
+ indexReader.close();
+ directory.close();
+ }
+
public void testEmptyChildFilter() throws Exception {
final Directory dir = newDirectory();
final IndexWriterConfig config = new IndexWriterConfig(new MockAnalyzer(random()));
[26/50] lucene-solr:jira/SOLR-8908: LUCENE-7203: Improve polygon
intersection detection using a small amount of upfront work.
Posted by th...@apache.org.
LUCENE-7203: Improve polygon intersection detection using a small amount of upfront work.
Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/aa4236a6
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/aa4236a6
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/aa4236a6
Branch: refs/heads/jira/SOLR-8908
Commit: aa4236a61299aff832b2bac70585cb480e3274e5
Parents: 61e3c40
Author: Karl Wright <Da...@gmail.com>
Authored: Tue Apr 12 06:03:04 2016 -0400
Committer: Karl Wright <Da...@gmail.com>
Committed: Tue Apr 12 06:03:04 2016 -0400
----------------------------------------------------------------------
.../spatial3d/geom/GeoConcavePolygon.java | 39 ++++++++++---------
.../lucene/spatial3d/geom/GeoConvexPolygon.java | 40 +++++++++++---------
2 files changed, 44 insertions(+), 35 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/aa4236a6/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoConcavePolygon.java
----------------------------------------------------------------------
diff --git a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoConcavePolygon.java b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoConcavePolygon.java
index 8c6f757..518df33 100644
--- a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoConcavePolygon.java
+++ b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoConcavePolygon.java
@@ -224,7 +224,17 @@ class GeoConcavePolygon extends GeoBasePolygon {
// For each edge, create a bounds object.
eitherBounds = new HashMap<>(edges.length);
for (int edgeIndex = 0; edgeIndex < edges.length; edgeIndex++) {
- eitherBounds.put(edges[edgeIndex], new EitherBound(invertedEdges[edgeIndex]));
+ final SidedPlane edge = edges[edgeIndex];
+ final SidedPlane invertedEdge = invertedEdges[edgeIndex];
+ int bound1Index = legalIndex(edgeIndex+1);
+ while (invertedEdges[legalIndex(bound1Index)].isNumericallyIdentical(invertedEdge)) {
+ bound1Index++;
+ }
+ int bound2Index = legalIndex(edgeIndex-1);
+ while (invertedEdges[legalIndex(bound2Index)].isNumericallyIdentical(invertedEdge)) {
+ bound2Index--;
+ }
+ eitherBounds.put(edge, new EitherBound(invertedEdges[legalIndex(bound1Index)], invertedEdges[legalIndex(bound2Index)]));
}
// Pick an edge point arbitrarily
@@ -238,6 +248,9 @@ class GeoConcavePolygon extends GeoBasePolygon {
protected int legalIndex(int index) {
while (index >= points.size())
index -= points.size();
+ while (index < 0) {
+ index += points.size();
+ }
return index;
}
@@ -297,37 +310,29 @@ class GeoConcavePolygon extends GeoBasePolygon {
return false;
}
- /** A membership implementation representing polygon edges that all must apply.
+ /** A membership implementation representing polygon edges that must apply.
*/
protected class EitherBound implements Membership {
- protected final SidedPlane exception;
+ protected final SidedPlane sideBound1;
+ protected final SidedPlane sideBound2;
/** Constructor.
* @param exception is the one plane to exclude from the check.
*/
- public EitherBound(final SidedPlane exception) {
- this.exception = exception;
+ public EitherBound(final SidedPlane sideBound1, final SidedPlane sideBound2) {
+ this.sideBound1 = sideBound1;
+ this.sideBound2 = sideBound2;
}
@Override
public boolean isWithin(final Vector v) {
- for (final SidedPlane edge : invertedEdges) {
- if (edge != exception && !edge.isWithin(v)) {
- return false;
- }
- }
- return true;
+ return sideBound1.isWithin(v) && sideBound2.isWithin(v);
}
@Override
public boolean isWithin(final double x, final double y, final double z) {
- for (final SidedPlane edge : invertedEdges) {
- if (edge != exception && !edge.isWithin(x, y, z)) {
- return false;
- }
- }
- return true;
+ return sideBound1.isWithin(x,y,z) && sideBound2.isWithin(x,y,z);
}
}
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/aa4236a6/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoConvexPolygon.java
----------------------------------------------------------------------
diff --git a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoConvexPolygon.java b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoConvexPolygon.java
index b631b55..4cc8177 100755
--- a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoConvexPolygon.java
+++ b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoConvexPolygon.java
@@ -219,8 +219,17 @@ class GeoConvexPolygon extends GeoBasePolygon {
// For each edge, create a bounds object.
eitherBounds = new HashMap<>(edges.length);
- for (final SidedPlane edge : edges) {
- eitherBounds.put(edge, new EitherBound(edge));
+ for (int edgeIndex = 0; edgeIndex < edges.length; edgeIndex++) {
+ final SidedPlane edge = edges[edgeIndex];
+ int bound1Index = legalIndex(edgeIndex+1);
+ while (edges[legalIndex(bound1Index)].isNumericallyIdentical(edge)) {
+ bound1Index++;
+ }
+ int bound2Index = legalIndex(edgeIndex-1);
+ while (edges[legalIndex(bound2Index)].isNumericallyIdentical(edge)) {
+ bound2Index--;
+ }
+ eitherBounds.put(edge, new EitherBound(edges[legalIndex(bound1Index)], edges[legalIndex(bound2Index)]));
}
// Pick an edge point arbitrarily
@@ -234,6 +243,9 @@ class GeoConvexPolygon extends GeoBasePolygon {
protected int legalIndex(int index) {
while (index >= points.size())
index -= points.size();
+ while (index < 0) {
+ index += points.size();
+ }
return index;
}
@@ -284,37 +296,29 @@ class GeoConvexPolygon extends GeoBasePolygon {
return false;
}
- /** A membership implementation representing polygon edges that all must apply.
+ /** A membership implementation representing polygon edges that must apply.
*/
protected class EitherBound implements Membership {
- protected final SidedPlane exception;
+ protected final SidedPlane sideBound1;
+ protected final SidedPlane sideBound2;
/** Constructor.
* @param exception is the one plane to exclude from the check.
*/
- public EitherBound(final SidedPlane exception) {
- this.exception = exception;
+ public EitherBound(final SidedPlane sideBound1, final SidedPlane sideBound2) {
+ this.sideBound1 = sideBound1;
+ this.sideBound2 = sideBound2;
}
@Override
public boolean isWithin(final Vector v) {
- for (final SidedPlane edge : edges) {
- if (edge != exception && !edge.isWithin(v)) {
- return false;
- }
- }
- return true;
+ return sideBound1.isWithin(v) && sideBound2.isWithin(v);
}
@Override
public boolean isWithin(final double x, final double y, final double z) {
- for (final SidedPlane edge : edges) {
- if (edge != exception && !edge.isWithin(x, y, z)) {
- return false;
- }
- }
- return true;
+ return sideBound1.isWithin(x,y,z) && sideBound2.isWithin(x,y,z);
}
}
[06/50] lucene-solr:jira/SOLR-8908: SOLR-8922: optimize
DocSetCollector to produce less garbage
Posted by th...@apache.org.
SOLR-8922: optimize DocSetCollector to produce less garbage
Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/cfba58f0
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/cfba58f0
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/cfba58f0
Branch: refs/heads/jira/SOLR-8908
Commit: cfba58f0d0adecab495c8ea073f38b0e53f5481f
Parents: d377e7f
Author: yonik <yo...@apache.org>
Authored: Sat Apr 9 19:10:02 2016 -0400
Committer: yonik <yo...@apache.org>
Committed: Sat Apr 9 19:10:02 2016 -0400
----------------------------------------------------------------------
solr/CHANGES.txt | 5 ++
.../org/apache/solr/search/DocSetCollector.java | 84 ++++++++++++++++++--
2 files changed, 82 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/cfba58f0/solr/CHANGES.txt
----------------------------------------------------------------------
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index 1175123..b0047a1 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -118,6 +118,11 @@ Optimizations
* SOLR-8856: Do not cache merge or 'read once' contexts in the hdfs block cache. (Mark Miller, Mike Drob)
+* SOLR-8922: Optimize filter creation (DocSetCollector) to minimize the amount of garbage
+ produced. This resulted in up to 3x throughput when small filter creation was the bottleneck,
+ as well as orders of magnitude less garbage. (Jeff Wartes, yonik)
+
+
Other Changes
----------------------
* SOLR-7516: Improve javadocs for JavaBinCodec, ObjectResolver and enforce the single-usage policy.
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/cfba58f0/solr/core/src/java/org/apache/solr/search/DocSetCollector.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/search/DocSetCollector.java b/solr/core/src/java/org/apache/solr/search/DocSetCollector.java
index 8e529d9..25b12c5 100644
--- a/solr/core/src/java/org/apache/solr/search/DocSetCollector.java
+++ b/solr/core/src/java/org/apache/solr/search/DocSetCollector.java
@@ -17,6 +17,7 @@
package org.apache.solr.search;
import java.io.IOException;
+import java.util.ArrayList;
import org.apache.lucene.index.LeafReaderContext;
import org.apache.lucene.search.Scorer;
@@ -37,7 +38,7 @@ public class DocSetCollector extends SimpleCollector {
// in case there aren't that many hits, we may not want a very sparse
// bit array. Optimistically collect the first few docs in an array
// in case there are only a few.
- final int[] scratch;
+ final ExpandingIntArray scratch;
public DocSetCollector(int maxDoc) {
this(DocSetUtil.smallSetSize(maxDoc), maxDoc);
@@ -46,7 +47,7 @@ public class DocSetCollector extends SimpleCollector {
public DocSetCollector(int smallSetSize, int maxDoc) {
this.smallSetSize = smallSetSize;
this.maxDoc = maxDoc;
- this.scratch = new int[smallSetSize];
+ this.scratch = new ExpandingIntArray(smallSetSize);
}
@Override
@@ -59,8 +60,8 @@ public class DocSetCollector extends SimpleCollector {
// than scanning through a potentially huge bit vector.
// FUTURE: when search methods all start returning docs in order, maybe
// we could have a ListDocSet() and use the collected array directly.
- if (pos < scratch.length) {
- scratch[pos]=doc;
+ if (pos < smallSetSize) {
+ scratch.add(pos, doc);
} else {
// this conditional could be removed if BitSet was preallocated, but that
// would take up more memory, and add more GC time...
@@ -72,12 +73,12 @@ public class DocSetCollector extends SimpleCollector {
}
public DocSet getDocSet() {
- if (pos<=scratch.length) {
+ if (pos<=scratch.size()) {
// assumes docs were collected in sorted order!
- return new SortedIntDocSet(scratch, pos);
+ return new SortedIntDocSet(scratch.toArray(), pos);
} else {
// set the bits for ids that were collected in the array
- for (int i=0; i<scratch.length; i++) bits.set(scratch[i]);
+ scratch.copyTo(bits);
return new BitDocSet(bits,pos);
}
}
@@ -95,4 +96,73 @@ public class DocSetCollector extends SimpleCollector {
protected void doSetNextReader(LeafReaderContext context) throws IOException {
this.base = context.docBase;
}
+
+ protected static class ExpandingIntArray {
+ private static final int[] EMPTY = new int[0];
+ private int[] currentAddArray = null;
+ private int indexForNextAddInCurrentAddArray = 0;
+ private int size = 0;
+ private final int smallSetSize;
+ private ArrayList<int[]> arrays;
+
+ public ExpandingIntArray(int smallSetSize) {
+ this.smallSetSize = smallSetSize;
+ this.currentAddArray = EMPTY;
+ }
+
+ private void addNewArray() {
+ int arrSize = Math.max(10, currentAddArray.length << 1);
+ arrSize = Math.min(arrSize, smallSetSize - size); // max out at the smallSetSize
+ this.currentAddArray = new int[arrSize];
+ if (arrays == null) {
+ arrays = new ArrayList<>();
+ }
+ arrays.add(this.currentAddArray);
+ indexForNextAddInCurrentAddArray = 0;
+ // System.out.println("### ALLOCATED " + this + " " + arrSize + " smallSetSize="+smallSetSize + " left=" + (smallSetSize-size));
+ }
+
+ public void add(int index, int value) {
+ // assert index == size; // only appending is supported
+ if (indexForNextAddInCurrentAddArray >= currentAddArray.length) {
+ addNewArray();
+ }
+ currentAddArray[indexForNextAddInCurrentAddArray++] = value;
+ size++;
+ }
+
+ public void copyTo(FixedBitSet bits) {
+ if (size > 0) {
+ int resultPos = 0;
+ for (int i = 0; i < arrays.size(); i++) {
+ int[] srcArray = arrays.get(i);
+ int intsToCopy = (i < (arrays.size() - 1)) ? srcArray.length : indexForNextAddInCurrentAddArray;
+ for (int j = 0; j < intsToCopy; j++) {
+ bits.set(srcArray[j]);
+ }
+ resultPos += intsToCopy;
+ }
+ assert resultPos == size;
+ }
+ }
+
+ public int[] toArray() {
+ int[] result = new int[size];
+ if (size > 0) {
+ int resultPos = 0;
+ for (int i = 0; i < arrays.size(); i++) {
+ int[] srcArray = arrays.get(i);
+ int intsToCopy = (i < (arrays.size() - 1)) ? srcArray.length : indexForNextAddInCurrentAddArray;
+ System.arraycopy(srcArray, 0, result, resultPos, intsToCopy);
+ resultPos += intsToCopy;
+ }
+ assert resultPos == size;
+ }
+ return result;
+ }
+
+ public int size() {
+ return size;
+ }
+ }
}
[16/50] lucene-solr:jira/SOLR-8908: fix silly stack-building test bug
in BKD visitor forensics
Posted by th...@apache.org.
fix silly stack-building test bug in BKD visitor forensics
Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/38bf7dd8
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/38bf7dd8
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/38bf7dd8
Branch: refs/heads/jira/SOLR-8908
Commit: 38bf7dd8344129c956eb99bad4699687b1aa1635
Parents: 604fb28
Author: Mike McCandless <mi...@apache.org>
Authored: Mon Apr 11 05:42:59 2016 -0400
Committer: Mike McCandless <mi...@apache.org>
Committed: Mon Apr 11 05:42:59 2016 -0400
----------------------------------------------------------------------
.../src/test/org/apache/lucene/spatial3d/TestGeo3DPoint.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/38bf7dd8/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 9ec0e30..20302b4 100644
--- a/lucene/spatial3d/src/test/org/apache/lucene/spatial3d/TestGeo3DPoint.java
+++ b/lucene/spatial3d/src/test/org/apache/lucene/spatial3d/TestGeo3DPoint.java
@@ -1248,7 +1248,7 @@ public class TestGeo3DPoint extends LuceneTestCase {
if (firstPhase) {
// Pop stack:
- while (stack.size() > 0 && stack.get(stack.size()-1).contains(cell)) {
+ while (stack.size() > 0 && stack.get(stack.size()-1).contains(cell) == false) {
stack.remove(stack.size()-1);
//System.out.println(" pop");
}
[24/50] lucene-solr:jira/SOLR-8908: LUCENE-7155: Detect master/major
branch using enum, abort on more errors
Posted by th...@apache.org.
LUCENE-7155: Detect master/major branch using enum, abort on more errors
Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/10c77578
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/10c77578
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/10c77578
Branch: refs/heads/jira/SOLR-8908
Commit: 10c775785226263477e10de3ff056bfcf7d6e7f2
Parents: 61e3c40
Author: Jan Høydahl <ja...@apache.org>
Authored: Mon Apr 11 23:22:40 2016 +0200
Committer: Jan Høydahl <ja...@apache.org>
Committed: Mon Apr 11 23:22:40 2016 +0200
----------------------------------------------------------------------
dev-tools/scripts/addVersion.py | 19 +++++++++++--------
dev-tools/scripts/scriptutil.py | 16 ++++++++++------
2 files changed, 21 insertions(+), 14 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/10c77578/dev-tools/scripts/addVersion.py
----------------------------------------------------------------------
diff --git a/dev-tools/scripts/addVersion.py b/dev-tools/scripts/addVersion.py
index 6eaf517..414e4a1 100644
--- a/dev-tools/scripts/addVersion.py
+++ b/dev-tools/scripts/addVersion.py
@@ -19,9 +19,7 @@ sys.path.append(os.path.dirname(__file__))
from scriptutil import *
import argparse
-import io
import re
-import subprocess
def update_changes(filename, new_version):
print(' adding new section to %s...' % filename, end='', flush=True)
@@ -168,18 +166,23 @@ def check_solr_version_tests():
def read_config():
parser = argparse.ArgumentParser(description='Add a new version')
parser.add_argument('version', type=Version.parse)
- parser.add_argument('-c', '--changeid', type=str, help='SVN ChangeId for downstream version change to merge')
+ parser.add_argument('-c', '--changeid', type=str, help='Git ChangeId (commit hash) for downstream version change to merge')
c = parser.parse_args()
c.branch_type = find_branch_type()
- c.matching_branch = c.version.is_bugfix_release() and c.branch_type == 'release' or \
- c.version.is_minor_release() and c.branch_type == 'stable' or \
- c.branch_type == 'major'
+ c.matching_branch = c.version.is_bugfix_release() and c.branch_type == BranchType.release or \
+ c.version.is_minor_release() and c.branch_type == BranchType.stable or \
+ c.version.is_major_release() and c.branch_type == BranchType.major
- if c.changeid and c.matching_branch:
- parser.error('Cannot use --changeid on branch that new version will originate on')
+ print ("branch_type is %s " % c.branch_type)
if c.changeid and c.version.is_major_release():
parser.error('Cannot use --changeid for major release')
+ if c.changeid and c.matching_branch:
+ parser.error('Cannot use --changeid on branch that new version will originate on')
+ if c.version.is_bugfix_release() and c.branch_type in [BranchType.major, BranchType.stable] and not c.changeid:
+ parser.error('Adding bugfix release on master or stable branch requires --changeid')
+ if c.version.is_minor_release() and c.branch_type in [BranchType.major] and not c.changeid:
+ parser.error('Adding minor release on master branch requires --changeid')
return c
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/10c77578/dev-tools/scripts/scriptutil.py
----------------------------------------------------------------------
diff --git a/dev-tools/scripts/scriptutil.py b/dev-tools/scripts/scriptutil.py
index 10efd2b..216bde4 100644
--- a/dev-tools/scripts/scriptutil.py
+++ b/dev-tools/scripts/scriptutil.py
@@ -14,11 +14,10 @@
# limitations under the License.
import argparse
-import io
-import os
import re
import subprocess
import sys
+from enum import Enum
class Version(object):
def __init__(self, major, minor, bugfix, prerelease):
@@ -95,7 +94,12 @@ def update_file(filename, line_re, edit):
f.write(''.join(buffer))
return True
-# branch types are "release", "stable" and "trunk"
+# branch types are "release", "stable" and "major"
+class BranchType(Enum):
+ major = 1
+ stable = 2
+ release = 3
+
def find_branch_type():
output = subprocess.check_output('git status', shell=True)
for line in output.split(b'\n'):
@@ -106,11 +110,11 @@ def find_branch_type():
raise Exception('git status missing branch name')
if branchName == b'master':
- return 'master'
+ return BranchType.major
if re.match(r'branch_(\d+)x', branchName.decode('UTF-8')):
- return 'stable'
+ return BranchType.stable
if re.match(r'branch_(\d+)_(\d+)', branchName.decode('UTF-8')):
- return 'release'
+ return BranchType.release
raise Exception('Cannot run bumpVersion.py on feature branch')
version_prop_re = re.compile('version\.base=(.*)')
[30/50] lucene-solr:jira/SOLR-8908: LUCENE-7207: fix test bug.
shrinking a box which is a line can create a cross-dateline query!
Posted by th...@apache.org.
LUCENE-7207: fix test bug. shrinking a box which is a line can create a cross-dateline query!
Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/8f5ef078
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/8f5ef078
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/8f5ef078
Branch: refs/heads/jira/SOLR-8908
Commit: 8f5ef078b0af8db1998f5a04a772129fdd5c9f6e
Parents: e034b04
Author: Robert Muir <rm...@apache.org>
Authored: Tue Apr 12 09:27:30 2016 -0400
Committer: Robert Muir <rm...@apache.org>
Committed: Tue Apr 12 09:27:30 2016 -0400
----------------------------------------------------------------------
.../org/apache/lucene/spatial/util/BaseGeoPointTestCase.java | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/8f5ef078/lucene/spatial/src/test/org/apache/lucene/spatial/util/BaseGeoPointTestCase.java
----------------------------------------------------------------------
diff --git a/lucene/spatial/src/test/org/apache/lucene/spatial/util/BaseGeoPointTestCase.java b/lucene/spatial/src/test/org/apache/lucene/spatial/util/BaseGeoPointTestCase.java
index c2536bd..8daf83f 100644
--- a/lucene/spatial/src/test/org/apache/lucene/spatial/util/BaseGeoPointTestCase.java
+++ b/lucene/spatial/src/test/org/apache/lucene/spatial/util/BaseGeoPointTestCase.java
@@ -1271,7 +1271,9 @@ public abstract class BaseGeoPointTestCase extends LuceneTestCase {
}
// now shrink 1 ulp in each direction if possible: it should not include bogus stuff
- if (rect.minLat != 90 && rect.maxLat != -90 && rect.minLon != 80 && rect.maxLon != -180) {
+ // we can't shrink if values are already at extremes, and
+ // we can't do this if rectangle is actually a line or we will create a cross-dateline query
+ if (rect.minLat != 90 && rect.maxLat != -90 && rect.minLon != 80 && rect.maxLon != -180 && rect.minLon != rect.maxLon) {
// note we put points on "sides" not just "corners" so we just shrink all 4 at once for now: it should exclude all points!
assertEquals(0, s.count(newRectQuery(FIELD_NAME, Math.nextUp(rect.minLat),
Math.nextDown(rect.maxLat),
[38/50] lucene-solr:jira/SOLR-8908: SOLR-8914: ZkStateReader's
refreshLiveNodes(Watcher) is not thread safe.
Posted by th...@apache.org.
SOLR-8914: ZkStateReader's refreshLiveNodes(Watcher) is not thread safe.
Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/744b419b
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/744b419b
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/744b419b
Branch: refs/heads/jira/SOLR-8908
Commit: 744b419b42a5797700c0a3a5f859d86ae9d05325
Parents: 6c9391d
Author: markrmiller <ma...@apache.org>
Authored: Wed Apr 13 09:54:40 2016 -0400
Committer: markrmiller <ma...@apache.org>
Committed: Wed Apr 13 09:54:40 2016 -0400
----------------------------------------------------------------------
solr/CHANGES.txt | 3 +
.../apache/solr/cloud/TestStressLiveNodes.java | 252 +++++++++++++++++++
.../apache/solr/common/cloud/ZkStateReader.java | 85 ++++---
3 files changed, 311 insertions(+), 29 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/744b419b/solr/CHANGES.txt
----------------------------------------------------------------------
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index 0b98fa0..fbe4698 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -108,6 +108,9 @@ Bug Fixes
* SOLR-8948: OverseerTaskQueue.containsTaskWithRequestId encounters json parse error if a
SolrResponse node is in the overseer queue. (Jessica Cheng Mallet via shalin)
+* SOLR-8914: ZkStateReader's refreshLiveNodes(Watcher) is not thread safe. (Scott Blum, hoss,
+ sarowe, Erick Erickson, Mark Miller, shalin)
+
Optimizations
----------------------
* SOLR-8722: Don't force a full ZkStateReader refresh on every Overseer operation.
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/744b419b/solr/core/src/test/org/apache/solr/cloud/TestStressLiveNodes.java
----------------------------------------------------------------------
diff --git a/solr/core/src/test/org/apache/solr/cloud/TestStressLiveNodes.java b/solr/core/src/test/org/apache/solr/cloud/TestStressLiveNodes.java
new file mode 100644
index 0000000..28dcc82
--- /dev/null
+++ b/solr/core/src/test/org/apache/solr/cloud/TestStressLiveNodes.java
@@ -0,0 +1,252 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.solr.cloud;
+
+import java.lang.invoke.MethodHandles;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Random;
+import java.util.concurrent.Callable;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.TimeUnit;
+
+import org.apache.lucene.util.LuceneTestCase.Slow;
+import org.apache.lucene.util.TestUtil;
+import org.apache.solr.cloud.SolrCloudTestCase;
+import org.apache.solr.client.solrj.embedded.JettySolrRunner;
+import org.apache.solr.client.solrj.impl.CloudSolrClient;
+import org.apache.solr.common.cloud.SolrZkClient;
+import org.apache.solr.common.cloud.ZkStateReader;
+import org.apache.solr.common.util.ExecutorUtil;
+import org.apache.solr.core.CloudConfig.CloudConfigBuilder;
+import org.apache.solr.util.DefaultSolrThreadFactory;
+
+import org.apache.zookeeper.CreateMode;
+import org.apache.zookeeper.KeeperException;
+
+import org.junit.BeforeClass;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Stress test LiveNodes watching.
+ *
+ * Does bursts of adds to live_nodes using parallel threads to and verifies that after each
+ * burst a ZkStateReader detects the correct set.
+ */
+@Slow
+public class TestStressLiveNodes extends SolrCloudTestCase {
+
+ private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
+
+ /** A basic cloud client, we'll be testing the behavior of it's ZkStateReader */
+ private static CloudSolrClient CLOUD_CLIENT;
+
+ /** The addr of the zk server used in this test */
+ private static String ZK_SERVER_ADDR;
+
+ /* how many seconds we're willing to wait for our executor tasks to finish before failing the test */
+ private final static int WAIT_TIME = TEST_NIGHTLY ? 60 : 30;
+
+ @BeforeClass
+ private static void createMiniSolrCloudCluster() throws Exception {
+
+ // we only need 1 node, and we don't care about any configs or collections
+ // we're going to fake all the live_nodes changes we want to fake.
+ configureCluster(1).configure();
+
+ // give all nodes a chance to come alive
+ TestTolerantUpdateProcessorCloud.assertSpinLoopAllJettyAreRunning(cluster);
+
+ CLOUD_CLIENT = cluster.getSolrClient();
+ CLOUD_CLIENT.connect(); // force connection even though we aren't sending any requests
+
+ ZK_SERVER_ADDR = cluster.getZkServer().getZkAddress();
+
+ }
+
+ private static SolrZkClient newSolrZkClient() {
+ assertNotNull(ZK_SERVER_ADDR);
+ // WTF is CloudConfigBuilder.DEFAULT_ZK_CLIENT_TIMEOUT private?
+ return new SolrZkClient(ZK_SERVER_ADDR, 15000);
+ }
+
+ /** returns the true set of live nodes (currently in zk) as a sorted list */
+ private static List<String> getTrueLiveNodesFromZk() throws Exception {
+ SolrZkClient client = newSolrZkClient();
+ try {
+ ArrayList<String> result = new ArrayList<>(client.getChildren(ZkStateReader.LIVE_NODES_ZKNODE, null, true));
+ Collections.sort(result);
+ return result;
+ } finally {
+ client.close();
+ }
+ }
+
+ /**
+ * returns the cached set of live nodes (according to the ZkStateReader in our CloudSolrClient)
+ * as a sorted list.
+ * This is done in a sleep+retry loop until the result matches the expectedCount, or a few iters have passed
+ * (this way we aren't testing how fast the watchers complete, just that they got the correct result)
+ */
+ private static List<String> getCachedLiveNodesFromLocalState(final int expectedCount) throws Exception {
+ ArrayList<String> result = null;
+
+ for (int i = 0; i < 10; i++) {
+ result = new ArrayList<>(CLOUD_CLIENT.getZkStateReader().getClusterState().getLiveNodes());
+ if (expectedCount != result.size()) {
+ log.info("sleeping #{} to give watchers a chance to finish: {} != {}",
+ i, expectedCount, result.size());
+ Thread.sleep(200);
+ } else {
+ break;
+ }
+ }
+ if (expectedCount != result.size()) {
+ log.error("gave up waiting for live nodes to match expected size: {} != {}",
+ expectedCount, result.size());
+ }
+ Collections.sort(result);
+ return result;
+ }
+
+ public void testStress() throws Exception {
+
+ // do many iters, so we have "bursts" of adding nodes that we then check
+ final int numIters = atLeast(1000);
+ for (int iter = 0; iter < numIters; iter++) {
+
+ // sanity check that ZK says there is in fact 1 live node
+ List<String> actualLiveNodes = getTrueLiveNodesFromZk();
+ assertEquals("iter"+iter+": " + actualLiveNodes.toString(),
+ 1, actualLiveNodes.size());
+
+ // only here do we forcibly update the cached live nodes so we don't have to wait for it to catch up
+ // with all the ephemeral nodes that vanished after the last iteration
+ CLOUD_CLIENT.getZkStateReader().updateLiveNodes();
+
+ // sanity check that our Cloud Client's local state knows about the 1 (real) live node in our cluster
+ List<String> cachedLiveNodes = getCachedLiveNodesFromLocalState(actualLiveNodes.size());
+ assertEquals("iter"+iter+" " + actualLiveNodes.size() + " != " + cachedLiveNodes.size(),
+ actualLiveNodes, cachedLiveNodes);
+
+
+ // start spining up some threads to add some live_node children in parallel
+
+ // we don't need a lot of threads or nodes (we don't want to swamp the CPUs
+ // just bursts of conccurent adds) but we do want to randomize it a bit so we increase the
+ // odds of concurrent watchers firing regardless of the num CPUs or load on the machine running
+ // the test (but we deliberately don't look at availableProcessors() since we want randomization
+ // consistency across all machines for a given seed)
+ final int numThreads = TestUtil.nextInt(random(), 2, 5);
+
+ // use same num for all thrashers, to increase likely hood of them all competing
+ // (diff random number would mean heavy concurency only for ~ the first N=lowest num requetss)
+ //
+ // this does not need to be a large number -- in fact, the higher it is, the more
+ // likely we are to see a mistake in early watcher triggers get "corrected" by a later one
+ // and overlook a possible bug
+ final int numNodesPerThrasher = TestUtil.nextInt(random(), 1, 5);
+
+ log.info("preparing parallel adds to live nodes: iter={}, numThreads={} numNodesPerThread={}",
+ iter, numThreads, numNodesPerThrasher);
+
+ // NOTE: using ephemeral nodes
+ // so we can't close any of these thrashers until we are done with our assertions
+ final List<LiveNodeTrasher> thrashers = new ArrayList<>(numThreads);
+ for (int i = 0; i < numThreads; i++) {
+ thrashers.add(new LiveNodeTrasher("T"+iter+"_"+i, numNodesPerThrasher));
+ }
+ try {
+ final ExecutorService executorService = ExecutorUtil.newMDCAwareFixedThreadPool
+ (thrashers.size()+1, new DefaultSolrThreadFactory("test_live_nodes_thrasher_iter"+iter));
+
+ executorService.invokeAll(thrashers);
+ executorService.shutdown();
+ if (! executorService.awaitTermination(WAIT_TIME, TimeUnit.SECONDS)) {
+ for (LiveNodeTrasher thrasher : thrashers) {
+ thrasher.stop();
+ }
+ }
+ assertTrue("iter"+iter+": thrashers didn't finish even after explicitly stopping",
+ executorService.awaitTermination(WAIT_TIME, TimeUnit.SECONDS));
+
+ // sanity check the *real* live_nodes entries from ZK match what the thrashers added
+ int totalAdded = 1; // 1 real live node when we started
+ for (LiveNodeTrasher thrasher : thrashers) {
+ totalAdded += thrasher.getNumAdded();
+ }
+ actualLiveNodes = getTrueLiveNodesFromZk();
+ assertEquals("iter"+iter, totalAdded, actualLiveNodes.size());
+
+ // verify our local client knows the correct set of live nodes
+ cachedLiveNodes = getCachedLiveNodesFromLocalState(actualLiveNodes.size());
+ assertEquals("iter"+iter+" " + actualLiveNodes.size() + " != " + cachedLiveNodes.size(),
+ actualLiveNodes, cachedLiveNodes);
+
+ } finally {
+ for (LiveNodeTrasher thrasher : thrashers) {
+ // shutdown our zk connection, freeing our ephemeral nodes
+ thrasher.close();
+ }
+ }
+ }
+ }
+
+ /** NOTE: has internal counter which is not thread safe, only call() in one thread at a time */
+ public static final class LiveNodeTrasher implements Callable<Integer> {
+ private final String id;
+ private final int numNodesToAdd;
+ private final SolrZkClient client;
+
+ private boolean running = false;;
+ private int numAdded = 0;
+
+ /** ID should ideally be unique amonst any other instances */
+ public LiveNodeTrasher(String id, int numNodesToAdd) {
+ this.id = id;
+ this.numNodesToAdd = numNodesToAdd;
+ this.client = newSolrZkClient();
+ }
+ /** returns the number of nodes actually added w/o error */
+ public Integer call() {
+ running = true;
+ // NOTE: test includes 'running'
+ for (int i = 0; running && i < numNodesToAdd; i++) {
+ final String nodePath = ZkStateReader.LIVE_NODES_ZKNODE + "/thrasher-" + id + "-" + i;
+ try {
+ client.makePath(nodePath, CreateMode.EPHEMERAL, true);
+ numAdded++;
+ } catch (Exception e) {
+ log.error("failed to create: " + nodePath, e);
+ }
+ }
+ return numAdded;
+ }
+ public int getNumAdded() {
+ return numAdded;
+ }
+ public void close() {
+ client.close();
+ }
+ public void stop() {
+ running = false;
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/744b419b/solr/solrj/src/java/org/apache/solr/common/cloud/ZkStateReader.java
----------------------------------------------------------------------
diff --git a/solr/solrj/src/java/org/apache/solr/common/cloud/ZkStateReader.java b/solr/solrj/src/java/org/apache/solr/common/cloud/ZkStateReader.java
index 308b3e0..e8d95c3 100644
--- a/solr/solrj/src/java/org/apache/solr/common/cloud/ZkStateReader.java
+++ b/solr/solrj/src/java/org/apache/solr/common/cloud/ZkStateReader.java
@@ -32,6 +32,7 @@ import java.util.Set;
import java.util.TreeSet;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicReference;
import org.apache.solr.common.Callable;
import org.apache.solr.common.SolrException;
@@ -487,6 +488,10 @@ public class ZkStateReader implements Closeable {
final byte[] data = zkClient.getData(CLUSTER_STATE, watcher, stat, true);
final ClusterState loadedData = ClusterState.load(stat.getVersion(), data, emptySet(), CLUSTER_STATE);
synchronized (getUpdateLock()) {
+ if (this.legacyClusterStateVersion >= stat.getVersion()) {
+ // Nothing to do, someone else updated same or newer.
+ return;
+ }
this.legacyCollectionStates = loadedData.getCollectionStates();
this.legacyClusterStateVersion = stat.getVersion();
}
@@ -509,6 +514,9 @@ public class ZkStateReader implements Closeable {
}
}
+ // We don't get a Stat or track versions on getChildren() calls, so force linearization.
+ private final Object refreshCollectionListLock = new Object();
+
/**
* Search for any lazy-loadable state format2 collections.
*
@@ -522,29 +530,32 @@ public class ZkStateReader implements Closeable {
* {@link ClusterState#getCollections()} method as a safeguard against exposing wrong collection names to the users
*/
private void refreshCollectionList(Watcher watcher) throws KeeperException, InterruptedException {
- List<String> children = null;
- try {
- children = zkClient.getChildren(COLLECTIONS_ZKNODE, watcher, true);
- } catch (KeeperException.NoNodeException e) {
- LOG.warn("Error fetching collection names: [{}]", e.getMessage());
- // fall through
- }
- if (children == null || children.isEmpty()) {
- lazyCollectionStates.clear();
- return;
- }
-
- // Don't mess with watchedCollections, they should self-manage.
+ synchronized (refreshCollectionListLock) {
+ List<String> children = null;
+ try {
+ children = zkClient.getChildren(COLLECTIONS_ZKNODE, watcher, true);
+ } catch (KeeperException.NoNodeException e) {
+ LOG.warn("Error fetching collection names: [{}]", e.getMessage());
+ // fall through
+ }
+ if (children == null || children.isEmpty()) {
+ lazyCollectionStates.clear();
+ return;
+ }
- // First, drop any children that disappeared.
- this.lazyCollectionStates.keySet().retainAll(children);
- for (String coll : children) {
- // We will create an eager collection for any interesting collections, so don't add to lazy.
- if (!interestingCollections.contains(coll)) {
- // Double check contains just to avoid allocating an object.
- LazyCollectionRef existing = lazyCollectionStates.get(coll);
- if (existing == null) {
- lazyCollectionStates.putIfAbsent(coll, new LazyCollectionRef(coll));
+ // Don't lock getUpdateLock() here, we don't need it and it would cause deadlock.
+ // Don't mess with watchedCollections, they should self-manage.
+
+ // First, drop any children that disappeared.
+ this.lazyCollectionStates.keySet().retainAll(children);
+ for (String coll : children) {
+ // We will create an eager collection for any interesting collections, so don't add to lazy.
+ if (!interestingCollections.contains(coll)) {
+ // Double check contains just to avoid allocating an object.
+ LazyCollectionRef existing = lazyCollectionStates.get(coll);
+ if (existing == null) {
+ lazyCollectionStates.putIfAbsent(coll, new LazyCollectionRef(coll));
+ }
}
}
}
@@ -576,19 +587,35 @@ public class ZkStateReader implements Closeable {
}
}
+ // We don't get a Stat or track versions on getChildren() calls, so force linearization.
+ private final Object refreshLiveNodesLock = new Object();
+ // Ensures that only the latest getChildren fetch gets applied.
+ private final AtomicReference<Set<String>> lastFetchedLiveNodes = new AtomicReference<>();
+
/**
* Refresh live_nodes.
*/
private void refreshLiveNodes(Watcher watcher) throws KeeperException, InterruptedException {
- Set<String> newLiveNodes;
- try {
- List<String> nodeList = zkClient.getChildren(LIVE_NODES_ZKNODE, watcher, true);
- newLiveNodes = new HashSet<>(nodeList);
- } catch (KeeperException.NoNodeException e) {
- newLiveNodes = emptySet();
+ synchronized (refreshLiveNodesLock) {
+ Set<String> newLiveNodes;
+ try {
+ List<String> nodeList = zkClient.getChildren(LIVE_NODES_ZKNODE, watcher, true);
+ newLiveNodes = new HashSet<>(nodeList);
+ } catch (KeeperException.NoNodeException e) {
+ newLiveNodes = emptySet();
+ }
+ lastFetchedLiveNodes.set(newLiveNodes);
}
- Set<String> oldLiveNodes;
+
+ // Can't lock getUpdateLock() until we release the other, it would cause deadlock.
+ Set<String> oldLiveNodes, newLiveNodes;
synchronized (getUpdateLock()) {
+ newLiveNodes = lastFetchedLiveNodes.getAndSet(null);
+ if (newLiveNodes == null) {
+ // Someone else won the race to apply the last update, just exit.
+ return;
+ }
+
oldLiveNodes = this.liveNodes;
this.liveNodes = newLiveNodes;
if (clusterState != null) {
[43/50] lucene-solr:jira/SOLR-8908: Fix incorrect 'upgrading from'
version number in 7.0.0
Posted by th...@apache.org.
Fix incorrect 'upgrading from' version number in 7.0.0
Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/478a2a4c
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/478a2a4c
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/478a2a4c
Branch: refs/heads/jira/SOLR-8908
Commit: 478a2a4c790fdd2c227ff08d0d2a9b45e0c259d5
Parents: 0a5f7f8
Author: Shalin Shekhar Mangar <sh...@apache.org>
Authored: Wed Apr 13 23:49:59 2016 +0530
Committer: Shalin Shekhar Mangar <sh...@apache.org>
Committed: Wed Apr 13 23:49:59 2016 +0530
----------------------------------------------------------------------
solr/CHANGES.txt | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/478a2a4c/solr/CHANGES.txt
----------------------------------------------------------------------
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index fc50468..b379716 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -18,7 +18,7 @@ See the Quick Start guide at http://lucene.apache.org/solr/quickstart.html
================== 7.0.0 ==================
-Upgrading from Solr 5.x
+Upgrading from Solr 6.x
----------------------
* HttpClientInterceptorPlugin is now HttpClientBuilderPlugin and must work with a
[31/50] lucene-solr:jira/SOLR-8908: LUCENE-7204: Add check for
backtracking over polygon path.
Posted by th...@apache.org.
LUCENE-7204: Add check for backtracking over polygon path.
Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/414bdea9
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/414bdea9
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/414bdea9
Branch: refs/heads/jira/SOLR-8908
Commit: 414bdea97a5c1e514c0ea28abf3d7b0471cf04a5
Parents: e034b04
Author: Karl Wright <Da...@gmail.com>
Authored: Tue Apr 12 15:37:13 2016 -0400
Committer: Karl Wright <Da...@gmail.com>
Committed: Tue Apr 12 15:37:13 2016 -0400
----------------------------------------------------------------------
.../spatial3d/geom/GeoPolygonFactory.java | 79 +++++++++++++++++++-
.../lucene/spatial3d/geom/GeoPolygonTest.java | 40 ++++++++++
2 files changed, 117 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/414bdea9/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoPolygonFactory.java
----------------------------------------------------------------------
diff --git a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoPolygonFactory.java b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoPolygonFactory.java
index 4b7f4f4..9865ac0 100755
--- a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoPolygonFactory.java
+++ b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoPolygonFactory.java
@@ -64,6 +64,7 @@ public class GeoPolygonFactory {
final List<GeoPolygon> holes) {
// The basic operation uses a set of points, two points determining one particular edge, and a sided plane
// describing membership.
+ //System.out.println("Initial point list = "+pointList+"; convexPointIndex = "+convexPointIndex+"; holes = "+holes);
final GeoCompositePolygon rval = new GeoCompositePolygon();
if (buildPolygonShape(rval,
planetModel, pointList, new BitSet(),
@@ -391,6 +392,68 @@ public class GeoPolygonFactory {
// The edge buffer.
final EdgeBuffer edgeBuffer = new EdgeBuffer(pointsList, internalEdges, startPointIndex, endPointIndex, startingEdge);
+ /*
+ // Verify that the polygon does not self-intersect
+ // Now, look for non-adjacent edges that cross.
+ System.err.println("Looking for intersections...");
+ System.err.println("Starting edge is: "+startingEdge);
+ final Iterator<Edge> edgeIterator = edgeBuffer.iterator();
+ while (edgeIterator.hasNext()) {
+ final Edge edge = edgeIterator.next();
+ final Set<Edge> excludedEdges = new HashSet<>();
+ excludedEdges.add(edge);
+ Edge oneBoundary = edgeBuffer.getPrevious(edge);
+ while (oneBoundary.plane.isNumericallyIdentical(edge.plane)) {
+ excludedEdges.add(oneBoundary);
+ oneBoundary = edgeBuffer.getPrevious(oneBoundary);
+ }
+ excludedEdges.add(oneBoundary);
+ Edge otherBoundary = edgeBuffer.getNext(edge);
+ while (otherBoundary.plane.isNumericallyIdentical(edge.plane)) {
+ excludedEdges.add(otherBoundary);
+ otherBoundary = edgeBuffer.getNext(otherBoundary);
+ }
+ excludedEdges.add(otherBoundary);
+
+ // Now go through all other edges and rule out any intersections
+ final Iterator<Edge> compareIterator = edgeBuffer.iterator();
+ while (compareIterator.hasNext()) {
+ final Edge compareEdge = compareIterator.next();
+ if (!excludedEdges.contains(compareEdge)) {
+ // Found an edge we can compare with!
+ //System.err.println("Found a compare edge...");
+ boolean nonOverlapping = true;
+ // We need the other boundaries though.
+ Edge oneCompareBoundary = edgeBuffer.getPrevious(compareEdge);
+ while (oneCompareBoundary.plane.isNumericallyIdentical(compareEdge.plane)) {
+ if (excludedEdges.contains(oneCompareBoundary)) {
+ //System.err.println(" excluded because oneCompareBoundary found to be in set");
+ nonOverlapping = false;
+ break;
+ }
+ oneCompareBoundary = edgeBuffer.getPrevious(oneCompareBoundary);
+ }
+ Edge otherCompareBoundary = edgeBuffer.getNext(compareEdge);
+ while (otherCompareBoundary.plane.isNumericallyIdentical(compareEdge.plane)) {
+ if (excludedEdges.contains(otherCompareBoundary)) {
+ //System.err.println(" excluded because otherCompareBoundary found to be in set");
+ nonOverlapping = false;
+ break;
+ }
+ otherCompareBoundary = edgeBuffer.getNext(otherCompareBoundary);
+ }
+ if (nonOverlapping) {
+ //System.err.println("Preparing to call findIntersections...");
+ // Finally do an intersection test
+ if (edge.plane.findIntersections(planetModel, compareEdge.plane, oneBoundary.plane, otherBoundary.plane, oneCompareBoundary.plane, otherCompareBoundary.plane).length > 0) {
+ throw new IllegalArgumentException("polygon has intersecting edges");
+ }
+ }
+ }
+ }
+ }
+ */
+
// Starting state:
// The stopping point
Edge stoppingPoint = edgeBuffer.pickOne();
@@ -997,7 +1060,13 @@ public class GeoPolygonFactory {
System.out.println(" "+p);
}
*/
+
+ // We need to detect backtracks, and also situations where someone has tried to stitch together multiple segments into one long arc (> 180 degrees).
+ // To do this, every time we extend by a coplanar segment, we compute the total arc distance to the new endpoint, as
+ // well as a sum of the arc distances we've accumulated as we march forward. If these two numbers disagree, then
+ // we know there has been a backtrack or other anomaly.
+ // extend the edge, we compute the distance along the
final Edge startEdge = new Edge(pointList.get(startPlaneStartIndex), pointList.get(startPlaneEndIndex), startPlane, internalEdges.get(startPlaneStartIndex));
// Fill in the EdgeBuffer by walking around creating more stuff
Edge currentEdge = startEdge;
@@ -1027,15 +1096,21 @@ public class GeoPolygonFactory {
if (currentEdge.plane.evaluateIsZero(newPoint)) {
// The new point is colinear with the current edge. We'll have to look for the first point that isn't.
int checkPointIndex = -1;
+ // Compute the arc distance before we try to extend
+ double accumulatedDistance = 0.0;
final Plane checkPlane = new Plane(pointList.get(startIndex), newPoint);
for (int i = 0; i < pointList.size(); i++) {
final int index = getLegalIndex(startIndex - 1 - i, pointList.size());
if (!checkPlane.evaluateIsZero(pointList.get(index))) {
checkPointIndex = index;
break;
+ } else {
+ accumulatedDistance += pointList.get(getLegalIndex(index+1, pointList.size())).arcDistance(pointList.get(index));
+ final double actualDistance = pointList.get(getLegalIndex(startIndex-1, pointList.size())).arcDistance(pointList.get(index));
+ if (Math.abs(actualDistance - accumulatedDistance) >= Vector.MINIMUM_RESOLUTION) {
+ throw new IllegalArgumentException("polygon backtracks over itself");
+ }
}
- }
- if (checkPointIndex == -1) {
throw new IllegalArgumentException("polygon is illegal (linear)");
}
pointToPresent = pointList.get(checkPointIndex);
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/414bdea9/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 33840da..2da93cf 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
@@ -378,4 +378,44 @@ shape:
final GeoPolygon p = GeoPolygonFactory.makeGeoPolygon(PlanetModel.WGS84, points, null);
}
+ @Test
+ public void testPolygonIntersectionFailure1() {
+ final PlanetModel pm = PlanetModel.WGS84;
+ //[junit4] > Throwable #1: java.lang.AssertionError: invalid hits for shape=GeoCompositeMembershipShape:
+ //{[GeoConvexPolygon: {planetmodel=PlanetModel.WGS84, points=
+ //[[lat=0.2669499069140678, lon=-0.31249902828113546([X=0.9186752334433793, Y=-0.2968103450748192, Z=0.2640238502385029])],
+ //[lat=1.538559019421765, lon=0.0([X=0.03215971057004023, Y=0.0, Z=0.9972473454662941])],
+ //[lat=-0.5516194571595735, lon=0.0([X=0.8518418310766115, Y=0.0, Z=-0.5241686363384119])]], internalEdges={2}},
+ //GeoConvexPolygon: {planetmodel=PlanetModel.WGS84, points=
+ //[[lat=0.0, lon=-3.141592653589793([X=-1.0011188539924791, Y=-1.226017000107956E-16, Z=0.0])],
+ //[lat=-1.5707963267948966, lon=-2.2780601241431375([X=-3.9697069088211677E-17, Y=-4.644115432258393E-17, Z=-0.997762292022105])],
+ //[lat=0.2669499069140678, lon=-0.31249902828113546([X=0.9186752334433793, Y=-0.2968103450748192, Z=0.2640238502385029])]], internalEdges={2}},
+ //GeoConvexPolygon: {planetmodel=PlanetModel.WGS84, points=
+ //[[lat=0.2669499069140678, lon=-0.31249902828113546([X=0.9186752334433793, Y=-0.2968103450748192, Z=0.2640238502385029])],
+ //[lat=-0.5516194571595735, lon=0.0([X=0.8518418310766115, Y=0.0, Z=-0.5241686363384119])],
+ //[lat=0.0, lon=-3.141592653589793([X=-1.0011188539924791, Y=-1.226017000107956E-16, Z=0.0])]], internalEdges={0, 2}}]}
+
+ // Build the polygon
+ //[[lat=-0.5516194571595735, lon=0.0([X=0.8518418310766115, Y=0.0, Z=-0.5241686363384119])],
+ //[lat=0.0, lon=-3.141592653589793([X=-1.0011188539924791, Y=-1.226017000107956E-16, Z=0.0])],
+ //[lat=-1.5707963267948966, lon=-2.2780601241431375([X=-3.9697069088211677E-17, Y=-4.644115432258393E-17, Z=-0.997762292022105])],
+ //[lat=0.2669499069140678, lon=-0.31249902828113546([X=0.9186752334433793, Y=-0.2968103450748192, Z=0.2640238502385029])],
+ //[lat=1.538559019421765, lon=0.0([X=0.03215971057004023, Y=0.0, Z=0.9972473454662941])]]
+ List<GeoPoint> polyPoints = new ArrayList<>();
+ polyPoints.add(new GeoPoint(pm, -0.5516194571595735, 0.0));
+ polyPoints.add(new GeoPoint(pm, 0.0, -3.141592653589793));
+ polyPoints.add(new GeoPoint(pm, -1.5707963267948966, -2.2780601241431375));
+ polyPoints.add(new GeoPoint(pm, 0.2669499069140678, -0.31249902828113546));
+ polyPoints.add(new GeoPoint(pm, 1.538559019421765, 0.0));
+ // Make sure we catch the backtrack
+ boolean backtracks = false;
+ try {
+ GeoPolygonFactory.makeGeoPolygon(pm, polyPoints, 4, null);
+ } catch (IllegalArgumentException e) {
+ backtracks = true;
+ }
+ assertTrue(backtracks);
+
+ }
+
}
[36/50] lucene-solr:jira/SOLR-8908: LUCENE-7205: Remove repeated
nl.getLength() calls in (Boolean|DisjunctionMax|FuzzyLikeThis)QueryBuilder.
Posted by th...@apache.org.
LUCENE-7205: Remove repeated nl.getLength() calls in (Boolean|DisjunctionMax|FuzzyLikeThis)QueryBuilder.
Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/f2f48468
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/f2f48468
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/f2f48468
Branch: refs/heads/jira/SOLR-8908
Commit: f2f484680f155e89139e5651955ff057660bd2aa
Parents: e076b4c
Author: Christine Poerschke <cp...@apache.org>
Authored: Wed Apr 13 11:27:17 2016 +0100
Committer: Christine Poerschke <cp...@apache.org>
Committed: Wed Apr 13 11:27:17 2016 +0100
----------------------------------------------------------------------
lucene/CHANGES.txt | 3 +++
.../lucene/queryparser/xml/builders/BooleanQueryBuilder.java | 3 ++-
.../queryparser/xml/builders/DisjunctionMaxQueryBuilder.java | 3 ++-
.../queryparser/xml/builders/FuzzyLikeThisQueryBuilder.java | 3 ++-
4 files changed, 9 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/f2f48468/lucene/CHANGES.txt
----------------------------------------------------------------------
diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txt
index e371f25..87d039f 100644
--- a/lucene/CHANGES.txt
+++ b/lucene/CHANGES.txt
@@ -84,6 +84,9 @@ Other
* LUCENE-7174: Upgrade randomizedtesting to 2.3.4. (Uwe Schindler, Dawid Weiss)
+* LUCENE-7205: Remove repeated nl.getLength() calls in
+ (Boolean|DisjunctionMax|FuzzyLikeThis)QueryBuilder. (Christine Poerschke)
+
======================= Lucene 6.0.0 =======================
System Requirements
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/f2f48468/lucene/queryparser/src/java/org/apache/lucene/queryparser/xml/builders/BooleanQueryBuilder.java
----------------------------------------------------------------------
diff --git a/lucene/queryparser/src/java/org/apache/lucene/queryparser/xml/builders/BooleanQueryBuilder.java b/lucene/queryparser/src/java/org/apache/lucene/queryparser/xml/builders/BooleanQueryBuilder.java
index 1dd859c..fbd678b 100644
--- a/lucene/queryparser/src/java/org/apache/lucene/queryparser/xml/builders/BooleanQueryBuilder.java
+++ b/lucene/queryparser/src/java/org/apache/lucene/queryparser/xml/builders/BooleanQueryBuilder.java
@@ -49,7 +49,8 @@ public class BooleanQueryBuilder implements QueryBuilder {
bq.setMinimumNumberShouldMatch(DOMUtils.getAttribute(e, "minimumNumberShouldMatch", 0));
NodeList nl = e.getChildNodes();
- for (int i = 0; i < nl.getLength(); i++) {
+ final int nlLen = nl.getLength();
+ for (int i = 0; i < nlLen; i++) {
Node node = nl.item(i);
if (node.getNodeName().equals("Clause")) {
Element clauseElem = (Element) node;
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/f2f48468/lucene/queryparser/src/java/org/apache/lucene/queryparser/xml/builders/DisjunctionMaxQueryBuilder.java
----------------------------------------------------------------------
diff --git a/lucene/queryparser/src/java/org/apache/lucene/queryparser/xml/builders/DisjunctionMaxQueryBuilder.java b/lucene/queryparser/src/java/org/apache/lucene/queryparser/xml/builders/DisjunctionMaxQueryBuilder.java
index 8490667..0dc9e05 100644
--- a/lucene/queryparser/src/java/org/apache/lucene/queryparser/xml/builders/DisjunctionMaxQueryBuilder.java
+++ b/lucene/queryparser/src/java/org/apache/lucene/queryparser/xml/builders/DisjunctionMaxQueryBuilder.java
@@ -49,7 +49,8 @@ public class DisjunctionMaxQueryBuilder implements QueryBuilder {
List<Query> disjuncts = new ArrayList<>();
NodeList nl = e.getChildNodes();
- for (int i = 0; i < nl.getLength(); i++) {
+ final int nlLen = nl.getLength();
+ for (int i = 0; i < nlLen; i++) {
Node node = nl.item(i);
if (node instanceof Element) { // all elements are disjuncts.
Element queryElem = (Element) node;
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/f2f48468/lucene/queryparser/src/java/org/apache/lucene/queryparser/xml/builders/FuzzyLikeThisQueryBuilder.java
----------------------------------------------------------------------
diff --git a/lucene/queryparser/src/java/org/apache/lucene/queryparser/xml/builders/FuzzyLikeThisQueryBuilder.java b/lucene/queryparser/src/java/org/apache/lucene/queryparser/xml/builders/FuzzyLikeThisQueryBuilder.java
index f969a66..e7e9ad3 100644
--- a/lucene/queryparser/src/java/org/apache/lucene/queryparser/xml/builders/FuzzyLikeThisQueryBuilder.java
+++ b/lucene/queryparser/src/java/org/apache/lucene/queryparser/xml/builders/FuzzyLikeThisQueryBuilder.java
@@ -50,7 +50,8 @@ public class FuzzyLikeThisQueryBuilder implements QueryBuilder {
FuzzyLikeThisQuery fbq = new FuzzyLikeThisQuery(maxNumTerms, analyzer);
fbq.setIgnoreTF(DOMUtils.getAttribute(e, "ignoreTF", DEFAULT_IGNORE_TF));
- for (int i = 0; i < nl.getLength(); i++) {
+ final int nlLen = nl.getLength();
+ for (int i = 0; i < nlLen; i++) {
Element fieldElem = (Element) nl.item(i);
float minSimilarity = DOMUtils.getAttribute(fieldElem, "minSimilarity", DEFAULT_MIN_SIMILARITY);
int prefixLength = DOMUtils.getAttribute(fieldElem, "prefixLength", DEFAULT_PREFIX_LENGTH);
[03/50] lucene-solr:jira/SOLR-8908: Merge branch 'master' of
https://git-wip-us.apache.org/repos/asf/lucene-solr
Posted by th...@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/23b953cb
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/23b953cb
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/23b953cb
Branch: refs/heads/jira/SOLR-8908
Commit: 23b953cb4fd0b6829747147e7755fa0490748799
Parents: 4537a66 455f3dd
Author: Karl Wright <Da...@gmail.com>
Authored: Fri Apr 8 20:35:55 2016 -0400
Committer: Karl Wright <Da...@gmail.com>
Committed: Fri Apr 8 20:35:55 2016 -0400
----------------------------------------------------------------------
lucene/CHANGES.txt | 4 ++++
1 file changed, 4 insertions(+)
----------------------------------------------------------------------
[04/50] lucene-solr:jira/SOLR-8908: Augment explain output from geo3d
BKD tree tests to include shape relationships etc.
Posted by th...@apache.org.
Augment explain output from geo3d BKD tree tests to include shape relationships etc.
Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/4d3a633b
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/4d3a633b
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/4d3a633b
Branch: refs/heads/jira/SOLR-8908
Commit: 4d3a633bf1f9d3fb544f81765a15d6f126e53f6d
Parents: 23b953c
Author: Karl Wright <Da...@gmail.com>
Authored: Sat Apr 9 00:56:27 2016 -0400
Committer: Karl Wright <Da...@gmail.com>
Committed: Sat Apr 9 00:56:27 2016 -0400
----------------------------------------------------------------------
.../apache/lucene/spatial3d/TestGeo3DPoint.java | 37 +++++++++++++++++---
1 file changed, 32 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/4d3a633b/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 3aa1719..4edfd2d 100644
--- a/lucene/spatial3d/src/test/org/apache/lucene/spatial3d/TestGeo3DPoint.java
+++ b/lucene/spatial3d/src/test/org/apache/lucene/spatial3d/TestGeo3DPoint.java
@@ -56,6 +56,7 @@ import org.apache.lucene.search.IndexSearcher;
import org.apache.lucene.search.Query;
import org.apache.lucene.search.SimpleCollector;
import org.apache.lucene.spatial3d.geom.XYZSolid;
+import org.apache.lucene.spatial3d.geom.XYZSolidFactory;
import org.apache.lucene.spatial3d.geom.GeoArea;
import org.apache.lucene.spatial3d.geom.GeoAreaFactory;
import org.apache.lucene.spatial3d.geom.GeoBBox;
@@ -791,7 +792,7 @@ public class TestGeo3DPoint extends LuceneTestCase {
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(), r, docID).replace("\n", "\n "));
+ b.append(" explanation:\n " + explain("point", ((PointInGeo3DShapeQuery)query).getShape(), point, r, docID).replace("\n", "\n "));
fail(b.toString());
}
} else {
@@ -1168,6 +1169,8 @@ public class TestGeo3DPoint extends LuceneTestCase {
private static class ExplainingVisitor implements IntersectVisitor {
+ final GeoShape shape;
+ final GeoPoint targetDocPoint;
final IntersectVisitor in;
final List<Cell> stack = new ArrayList<>();
private List<Cell> stackToTargetDoc;
@@ -1180,7 +1183,9 @@ public class TestGeo3DPoint extends LuceneTestCase {
// In the first phase, we always return CROSSES to do a full scan of the BKD tree to see which leaf block the document lives in
boolean firstPhase = true;
- public ExplainingVisitor(IntersectVisitor in, int targetDocID, int numDims, int bytesPerDim, StringBuilder b) {
+ public ExplainingVisitor(GeoShape shape, GeoPoint targetDocPoint, IntersectVisitor in, int targetDocID, int numDims, int bytesPerDim, StringBuilder b) {
+ this.shape = shape;
+ this.targetDocPoint = targetDocPoint;
this.in = in;
this.targetDocID = targetDocID;
this.numDims = numDims;
@@ -1293,7 +1298,29 @@ public class TestGeo3DPoint extends LuceneTestCase {
double yMax = Geo3DUtil.decodeValueCeil(NumericUtils.sortableBytesToInt(maxPackedValue, 1 * Integer.BYTES));
double zMin = Geo3DUtil.decodeValueFloor(NumericUtils.sortableBytesToInt(minPackedValue, 2 * Integer.BYTES));
double zMax = Geo3DUtil.decodeValueCeil(NumericUtils.sortableBytesToInt(maxPackedValue, 2 * Integer.BYTES));
- return "Cell(x=" + xMin + " TO " + xMax + " y=" + yMin + " TO " + yMax + " z=" + zMin + " TO " + zMax + ")";
+ 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 String relationshipString;
+ switch (relationship) {
+ case GeoArea.CONTAINS:
+ relationshipString = "CONTAINS";
+ break;
+ case GeoArea.WITHIN:
+ relationshipString = "WITHIN";
+ break;
+ case GeoArea.OVERLAPS:
+ relationshipString = "OVERLAPS";
+ break;
+ case GeoArea.DISJOINT:
+ relationshipString = "DISJOINT";
+ break;
+ default:
+ relationshipString = "UNKNOWN";
+ break;
+ }
+ 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;
}
@Override
@@ -1313,7 +1340,7 @@ public class TestGeo3DPoint extends LuceneTestCase {
}
}
- public static String explain(String fieldName, GeoShape shape, IndexReader reader, int docID) throws Exception {
+ public static String explain(String fieldName, GeoShape shape, GeoPoint targetDocPoint, IndexReader reader, int docID) throws Exception {
// First find the leaf reader that owns this doc:
int subIndex = ReaderUtil.subIndex(docID, reader.leaves());
@@ -1323,7 +1350,7 @@ public class TestGeo3DPoint extends LuceneTestCase {
b.append("target is in leaf " + leafReader + " of full reader " + reader + "\n");
DocIdSetBuilder hits = new DocIdSetBuilder(leafReader.maxDoc());
- ExplainingVisitor visitor = new ExplainingVisitor(new PointInShapeIntersectVisitor(hits, shape), docID - reader.leaves().get(subIndex).docBase, 3, Integer.BYTES, b);
+ ExplainingVisitor visitor = new ExplainingVisitor(shape, targetDocPoint, new PointInShapeIntersectVisitor(hits, shape), docID - reader.leaves().get(subIndex).docBase, 3, Integer.BYTES, b);
// Do first phase, where we just figure out the "path" that leads to the target docID:
leafReader.getPointValues().intersect(fieldName, visitor);
[20/50] lucene-solr:jira/SOLR-8908: Fix javadoc generation.
Posted by th...@apache.org.
Fix javadoc generation.
Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/88965a0b
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/88965a0b
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/88965a0b
Branch: refs/heads/jira/SOLR-8908
Commit: 88965a0bec6054fb6fe2c316b5d1747100ef1c9f
Parents: 901a3af
Author: Adrien Grand <jp...@gmail.com>
Authored: Mon Apr 11 18:46:47 2016 +0200
Committer: Adrien Grand <jp...@gmail.com>
Committed: Mon Apr 11 18:46:47 2016 +0200
----------------------------------------------------------------------
lucene/classification/build.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/88965a0b/lucene/classification/build.xml
----------------------------------------------------------------------
diff --git a/lucene/classification/build.xml b/lucene/classification/build.xml
index c56d481..3ddb9bd 100644
--- a/lucene/classification/build.xml
+++ b/lucene/classification/build.xml
@@ -46,7 +46,7 @@
<invoke-module-javadoc>
<links>
<link href="../queries"/>
- <link href="../group"/>
+ <link href="../grouping"/>
<link href="../misc"/>
</links>
</invoke-module-javadoc>
[09/50] lucene-solr:jira/SOLR-8908: Merge branch 'master' of
https://git-wip-us.apache.org/repos/asf/lucene-solr
Posted by th...@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/7441f88b
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/7441f88b
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/7441f88b
Branch: refs/heads/jira/SOLR-8908
Commit: 7441f88ba6f718473a51f41ab59eb7b372d80aa9
Parents: a4bf526 93f9456
Author: Karl Wright <Da...@gmail.com>
Authored: Sun Apr 10 05:11:27 2016 -0400
Committer: Karl Wright <Da...@gmail.com>
Committed: Sun Apr 10 05:11:27 2016 -0400
----------------------------------------------------------------------
solr/CHANGES.txt | 5 ++
.../org/apache/solr/search/DocSetCollector.java | 84 ++++++++++++++++++--
.../test/org/apache/solr/search/TestDocSet.java | 27 ++++++-
3 files changed, 108 insertions(+), 8 deletions(-)
----------------------------------------------------------------------
[02/50] lucene-solr:jira/SOLR-8908: Stop tests from failing just
because of toString test
Posted by th...@apache.org.
Stop tests from failing just because of toString test
Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/4537a66b
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/4537a66b
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/4537a66b
Branch: refs/heads/jira/SOLR-8908
Commit: 4537a66bb16610dafef06965a0cfa346a2edd7de
Parents: eb87512
Author: Karl Wright <Da...@gmail.com>
Authored: Fri Apr 8 20:34:23 2016 -0400
Committer: Karl Wright <Da...@gmail.com>
Committed: Fri Apr 8 20:34:23 2016 -0400
----------------------------------------------------------------------
.../src/test/org/apache/lucene/spatial3d/TestGeo3DPoint.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/4537a66b/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 4e2e02e..3aa1719 100644
--- a/lucene/spatial3d/src/test/org/apache/lucene/spatial3d/TestGeo3DPoint.java
+++ b/lucene/spatial3d/src/test/org/apache/lucene/spatial3d/TestGeo3DPoint.java
@@ -805,7 +805,7 @@ public class TestGeo3DPoint extends LuceneTestCase {
public void testToString() {
Geo3DPoint point = new Geo3DPoint("point", 44.244272, 7.769736);
- assertEquals("Geo3DPoint <point: x=0.7094263130517758 y=0.09679758927665334 z=0.6973564618592686>", point.toString());
+ assertEquals("Geo3DPoint <point: x=", point.toString().substring(0,"Geo3DPoint <point: x=".length()));
}
public void testShapeQueryToString() {
[21/50] lucene-solr:jira/SOLR-8908: LUCENE-7201: Handle backside
whole-world case for bbox generation.
Posted by th...@apache.org.
LUCENE-7201: Handle backside whole-world case for bbox generation.
Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/05dc9021
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/05dc9021
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/05dc9021
Branch: refs/heads/jira/SOLR-8908
Commit: 05dc90215ad69c16c0284fdbe9e5df2cf4bf5f8e
Parents: 901a3af
Author: Karl Wright <Da...@gmail.com>
Authored: Mon Apr 11 12:52:48 2016 -0400
Committer: Karl Wright <Da...@gmail.com>
Committed: Mon Apr 11 12:52:48 2016 -0400
----------------------------------------------------------------------
.../src/java/org/apache/lucene/spatial3d/geom/GeoBBoxFactory.java | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/05dc9021/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoBBoxFactory.java
----------------------------------------------------------------------
diff --git a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoBBoxFactory.java b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoBBoxFactory.java
index de7493e..3d0b8cb 100755
--- a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoBBoxFactory.java
+++ b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoBBoxFactory.java
@@ -45,7 +45,8 @@ public class GeoBBoxFactory {
leftLon = -Math.PI;
if (rightLon > Math.PI)
rightLon = Math.PI;
- if (Math.abs(leftLon + Math.PI) < Vector.MINIMUM_RESOLUTION && Math.abs(rightLon - Math.PI) < Vector.MINIMUM_RESOLUTION) {
+ if ((Math.abs(leftLon + Math.PI) < Vector.MINIMUM_RESOLUTION && Math.abs(rightLon - Math.PI) < Vector.MINIMUM_RESOLUTION) ||
+ (Math.abs(rightLon + Math.PI) < Vector.MINIMUM_RESOLUTION && Math.abs(leftLon - Math.PI) < Vector.MINIMUM_RESOLUTION)) {
if (Math.abs(topLat - Math.PI * 0.5) < Vector.MINIMUM_RESOLUTION && Math.abs(bottomLat + Math.PI * 0.5) < Vector.MINIMUM_RESOLUTION)
return new GeoWorld(planetModel);
if (Math.abs(topLat - bottomLat) < Vector.MINIMUM_RESOLUTION) {
[46/50] lucene-solr:jira/SOLR-8908: Disable GeoConvexPolygon and
GeoConcavePolygon sanity checks,
since these are now package private and the check happens in GeoPolygonFactory
anyway.
Posted by th...@apache.org.
Disable GeoConvexPolygon and GeoConcavePolygon sanity checks, since these are now package private and the check happens in GeoPolygonFactory anyway.
Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/6e5ec3bb
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/6e5ec3bb
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/6e5ec3bb
Branch: refs/heads/jira/SOLR-8908
Commit: 6e5ec3bb4cfe8b74a89ddc4243d0b45e6f0cd4e9
Parents: 69f3d1f
Author: Karl Wright <Da...@gmail.com>
Authored: Wed Apr 13 16:15:43 2016 -0400
Committer: Karl Wright <Da...@gmail.com>
Committed: Wed Apr 13 16:15:43 2016 -0400
----------------------------------------------------------------------
.../java/org/apache/lucene/spatial3d/geom/GeoConcavePolygon.java | 2 ++
.../java/org/apache/lucene/spatial3d/geom/GeoConvexPolygon.java | 2 ++
2 files changed, 4 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/6e5ec3bb/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoConcavePolygon.java
----------------------------------------------------------------------
diff --git a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoConcavePolygon.java b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoConcavePolygon.java
index 995e191..b28ebd2 100644
--- a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoConcavePolygon.java
+++ b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoConcavePolygon.java
@@ -207,6 +207,7 @@ class GeoConcavePolygon extends GeoBasePolygon {
invertedEdges[i] = new SidedPlane(edges[i]);
notableEdgePoints[i] = new GeoPoint[]{start, end};
}
+ /* Disable since GeoPolygonFactory does this too.
// In order to naively confirm that the polygon is concave, I would need to
// check every edge, and verify that every point (other than the edge endpoints)
// is within the edge's sided plane. This is an order n^2 operation. That's still
@@ -220,6 +221,7 @@ class GeoConcavePolygon extends GeoBasePolygon {
}
}
}
+ */
// For each edge, create a bounds object.
eitherBounds = new HashMap<>(edges.length);
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/6e5ec3bb/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoConvexPolygon.java
----------------------------------------------------------------------
diff --git a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoConvexPolygon.java b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoConvexPolygon.java
index dd5971f..890df30 100755
--- a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoConvexPolygon.java
+++ b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoConvexPolygon.java
@@ -203,6 +203,7 @@ class GeoConvexPolygon extends GeoBasePolygon {
edges[i] = sp;
notableEdgePoints[i] = new GeoPoint[]{start, end};
}
+ /* Disabled since GeoPolygonFactory does the checking too.
// In order to naively confirm that the polygon is convex, I would need to
// check every edge, and verify that every point (other than the edge endpoints)
// is within the edge's sided plane. This is an order n^2 operation. That's still
@@ -216,6 +217,7 @@ class GeoConvexPolygon extends GeoBasePolygon {
}
}
}
+ */
// For each edge, create a bounds object.
eitherBounds = new HashMap<>(edges.length);
[29/50] lucene-solr:jira/SOLR-8908: LUCENE-7189: improve geo
debugging technology
Posted by th...@apache.org.
LUCENE-7189: improve geo debugging technology
Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/e034b04b
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/e034b04b
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/e034b04b
Branch: refs/heads/jira/SOLR-8908
Commit: e034b04b065ca635553672d2b35c6b36578fd673
Parents: a3ee984
Author: Mike McCandless <mi...@apache.org>
Authored: Tue Apr 12 06:10:08 2016 -0400
Committer: Mike McCandless <mi...@apache.org>
Committed: Tue Apr 12 06:10:08 2016 -0400
----------------------------------------------------------------------
.../org/apache/lucene/geo/EarthDebugger.java | 43 +++++++----
.../apache/lucene/index/PointsStackTracker.java | 79 ++++++++++++++++++++
2 files changed, 108 insertions(+), 14 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/e034b04b/lucene/test-framework/src/java/org/apache/lucene/geo/EarthDebugger.java
----------------------------------------------------------------------
diff --git a/lucene/test-framework/src/java/org/apache/lucene/geo/EarthDebugger.java b/lucene/test-framework/src/java/org/apache/lucene/geo/EarthDebugger.java
index 6c06c94..56dde88 100644
--- a/lucene/test-framework/src/java/org/apache/lucene/geo/EarthDebugger.java
+++ b/lucene/test-framework/src/java/org/apache/lucene/geo/EarthDebugger.java
@@ -17,8 +17,6 @@ package org.apache.lucene.geo;
* limitations under the License.
*/
-import org.apache.lucene.geo.Polygon;
-import org.apache.lucene.geo.Rectangle;
import org.apache.lucene.util.SloppyMath;
/** Draws shapes on the earth surface and renders using the very cool http://www.webglearth.org.
@@ -40,6 +38,16 @@ public class EarthDebugger {
b.append(" var earth = new WE.map('earth_div');\n");
}
+ public EarthDebugger(double centerLat, double centerLon, double altitudeMeters) {
+ b.append("<!DOCTYPE HTML>\n");
+ b.append("<html>\n");
+ b.append(" <head>\n");
+ b.append(" <script src=\"http://www.webglearth.com/v2/api.js\"></script>\n");
+ b.append(" <script>\n");
+ b.append(" function initialize() {\n");
+ b.append(" var earth = new WE.map('earth_div', {center: [" + centerLat + ", " + centerLon + "], altitude: " + altitudeMeters + "});\n");
+ }
+
public void addPolygon(Polygon poly) {
addPolygon(poly, "#00ff00");
}
@@ -54,29 +62,36 @@ public class EarthDebugger {
for(int i=0;i<polyLats.length;i++) {
b.append(" [" + polyLats[i] + ", " + polyLons[i] + "],\n");
}
- b.append(" ], {color: '" + color + "'});\n");
+ b.append(" ], {color: '" + color + "', fillColor: \"#000000\", fillOpacity: 0.0001});\n");
b.append(" " + name + ".addTo(earth);\n");
for (Polygon hole : poly.getHoles()) {
- addPolygon(poly, "#ffffff");
+ addPolygon(hole, "#ffffff");
}
}
- private static double MAX_LAT_LON_PER_STEP = 5.0;
+ private static double MAX_KM_PER_STEP = 100.0;
+
+ // Web GL earth connects dots by tunneling under the earth, so we approximate a great circle by sampling it, to minimize how deep in the
+ // earth each segment tunnels:
+ private int getStepCount(double minLat, double maxLat, double minLon, double maxLon) {
+ double distanceMeters = SloppyMath.haversinMeters(minLat, minLon, maxLat, maxLon);
+ return Math.max(1, (int) Math.round((distanceMeters / 1000.0) / MAX_KM_PER_STEP));
+ }
// first point is inclusive, last point is exclusive!
private void drawSegment(double minLat, double maxLat, double minLon, double maxLon) {
- int steps = (int) Math.round(Math.max(Math.abs(maxLat-minLat)/MAX_LAT_LON_PER_STEP, Math.abs(maxLon-minLon)/MAX_LAT_LON_PER_STEP));
- if (steps < 1) {
- steps = 1;
- }
+ int steps = getStepCount(minLat, maxLat, minLon, maxLon);
for(int i=0;i<steps;i++) {
b.append(" [" + (minLat + (maxLat - minLat) * i / steps) + ", " + (minLon + (maxLon - minLon) * i / steps) + "],\n");
}
}
public void addRect(double minLat, double maxLat, double minLon, double maxLon) {
- int steps = 20;
+ addRect(minLat, maxLat, minLon, maxLon, "#ff0000");
+ }
+
+ public void addRect(double minLat, double maxLat, double minLon, double maxLon, String color) {
String name = "rect" + nextShape;
nextShape++;
@@ -97,7 +112,7 @@ public class EarthDebugger {
b.append(" // min lat, min lon\n");
b.append(" [" + minLat + ", " + minLon + "]\n");
- b.append(" ], {color: \"#ff0000\", fillColor: \"#ff0000\"});\n");
+ b.append(" ], {color: \"" + color + "\", fillColor: \"" + color + "\"});\n");
b.append(" " + name + ".addTo(earth);\n");
}
@@ -108,7 +123,7 @@ public class EarthDebugger {
b.append(" var " + name + " = WE.polygon([\n");
double lon;
- int steps = 36;
+ int steps = getStepCount(lat, minLon, lat, maxLon);
for(lon = minLon;lon<=maxLon;lon += (maxLon-minLon)/steps) {
b.append(" [" + lat + ", " + lon + "],\n");
}
@@ -128,7 +143,7 @@ public class EarthDebugger {
b.append(" var " + name + " = WE.polygon([\n");
double lat;
- int steps = 36;
+ int steps = getStepCount(minLat, lon, maxLat, lon);
for(lat = minLat;lat<=maxLat;lat += (maxLat-minLat)/steps) {
b.append(" [" + lat + ", " + lon + "],\n");
}
@@ -151,7 +166,7 @@ public class EarthDebugger {
nextShape++;
b.append(" var " + name + " = WE.polygon([\n");
inverseHaversin(b, centerLat, centerLon, radiusMeters);
- b.append(" ], {color: '#00ff00'});\n");
+ b.append(" ], {color: '#00ff00', fillColor: \"#000000\", fillOpacity: 0.0001 });\n");
b.append(" " + name + ".addTo(earth);\n");
if (alsoAddBBox) {
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/e034b04b/lucene/test-framework/src/java/org/apache/lucene/index/PointsStackTracker.java
----------------------------------------------------------------------
diff --git a/lucene/test-framework/src/java/org/apache/lucene/index/PointsStackTracker.java b/lucene/test-framework/src/java/org/apache/lucene/index/PointsStackTracker.java
new file mode 100644
index 0000000..b439ec4
--- /dev/null
+++ b/lucene/test-framework/src/java/org/apache/lucene/index/PointsStackTracker.java
@@ -0,0 +1,79 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.lucene.index;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.lucene.index.PointValues.IntersectVisitor;
+import org.apache.lucene.util.StringHelper;
+
+/** Simple utility class to track the current BKD stack based solely on calls to {@link IntersectVisitor#compare}. */
+public class PointsStackTracker {
+
+ private final int numDims;
+ private final int bytesPerDim;
+
+ public final List<Cell> stack = new ArrayList<>();
+
+ public class Cell {
+ public final byte[] minPackedValue;
+ public final byte[] maxPackedValue;
+
+ public Cell(byte[] minPackedValue, byte[] maxPackedValue) {
+ this.minPackedValue = minPackedValue.clone();
+ this.maxPackedValue = maxPackedValue.clone();
+ }
+
+ public boolean contains(Cell other) {
+ for(int dim=0;dim<numDims;dim++) {
+ int offset = dim * bytesPerDim;
+ // other.min < min?
+ if (StringHelper.compare(bytesPerDim, other.minPackedValue, offset, minPackedValue, offset) < 0) {
+ return false;
+ }
+ // other.max > max?
+ if (StringHelper.compare(bytesPerDim, other.maxPackedValue, offset, maxPackedValue, offset) > 0) {
+ return false;
+ }
+ }
+
+ return true;
+ }
+ }
+
+ public PointsStackTracker(int numDims, int bytesPerDim) {
+ this.numDims = numDims;
+ this.bytesPerDim = bytesPerDim;
+ }
+
+ public void onCompare(byte[] minPackedValue, byte[] maxPackedValue) {
+ Cell cell = new Cell(minPackedValue, maxPackedValue);
+
+ // Pop stack:
+ while (stack.size() > 0 && stack.get(stack.size()-1).contains(cell) == false) {
+ stack.remove(stack.size()-1);
+ //System.out.println(" pop");
+ }
+
+ // Push stack:
+ stack.add(cell);
+ }
+
+ // TODO: expose other details about the stack...
+}
[41/50] lucene-solr:jira/SOLR-8908: SOLR-8899: Ignore thread leaks
for this test - due to the HttpClient leak,
the idle connection evictor thread can sometimes leak.
Posted by th...@apache.org.
SOLR-8899: Ignore thread leaks for this test - due to the HttpClient leak, the idle connection evictor thread can sometimes leak.
Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/79195a8e
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/79195a8e
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/79195a8e
Branch: refs/heads/jira/SOLR-8908
Commit: 79195a8e540e2013a538860151a16b49c538418c
Parents: f7f64c2
Author: markrmiller <ma...@apache.org>
Authored: Wed Apr 13 10:45:09 2016 -0400
Committer: markrmiller <ma...@apache.org>
Committed: Wed Apr 13 10:45:09 2016 -0400
----------------------------------------------------------------------
.../test/org/apache/solr/search/AnalyticsMergeStrategyTest.java | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/79195a8e/solr/core/src/test/org/apache/solr/search/AnalyticsMergeStrategyTest.java
----------------------------------------------------------------------
diff --git a/solr/core/src/test/org/apache/solr/search/AnalyticsMergeStrategyTest.java b/solr/core/src/test/org/apache/solr/search/AnalyticsMergeStrategyTest.java
index 160d2f7..d314b86 100644
--- a/solr/core/src/test/org/apache/solr/search/AnalyticsMergeStrategyTest.java
+++ b/solr/core/src/test/org/apache/solr/search/AnalyticsMergeStrategyTest.java
@@ -16,7 +16,6 @@
*/
package org.apache.solr.search;
-import org.apache.lucene.util.Constants;
import org.apache.solr.BaseDistributedSearchTestCase;
import org.apache.solr.SolrTestCaseJ4;
import org.apache.solr.SolrTestCaseJ4.SuppressObjectReleaseTracker;
@@ -26,6 +25,9 @@ import org.apache.solr.common.util.NamedList;
import org.junit.BeforeClass;
import org.junit.Test;
+import com.carrotsearch.randomizedtesting.annotations.ThreadLeakScope;
+import com.carrotsearch.randomizedtesting.annotations.ThreadLeakScope.Scope;
+
/**
* Test for QueryComponent's distributed querying
*
@@ -34,6 +36,7 @@ import org.junit.Test;
@SolrTestCaseJ4.SuppressSSL(bugUrl="https://issues.apache.org/jira/browse/SOLR-8433")
@SuppressObjectReleaseTracker(bugUrl="https://issues.apache.org/jira/browse/SOLR-8899")
+@ThreadLeakScope(Scope.NONE)
public class AnalyticsMergeStrategyTest extends BaseDistributedSearchTestCase {