You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by kw...@apache.org on 2016/04/15 02:47:14 UTC
[1/2] lucene-solr:master: LUCENE-7221: Limit the number of requests
to getRelationship() and isWithin() using bounds.
Repository: lucene-solr
Updated Branches:
refs/heads/master bdaddafcc -> ab906b5a7
LUCENE-7221: Limit the number of requests to getRelationship() and isWithin() using bounds.
Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/1d76b2c4
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/1d76b2c4
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/1d76b2c4
Branch: refs/heads/master
Commit: 1d76b2c49ba9c924b539f7d8a0f58c3e609656f1
Parents: 43b8456
Author: Karl Wright <Da...@gmail.com>
Authored: Thu Apr 14 20:46:38 2016 -0400
Committer: Karl Wright <Da...@gmail.com>
Committed: Thu Apr 14 20:46:38 2016 -0400
----------------------------------------------------------------------
.../spatial3d/PointInGeo3DShapeQuery.java | 10 ++++++---
.../spatial3d/PointInShapeIntersectVisitor.java | 23 ++++++++++++++++----
2 files changed, 26 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/1d76b2c4/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/PointInGeo3DShapeQuery.java
----------------------------------------------------------------------
diff --git a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/PointInGeo3DShapeQuery.java b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/PointInGeo3DShapeQuery.java
index ef0fe47..24a4224 100644
--- a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/PointInGeo3DShapeQuery.java
+++ b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/PointInGeo3DShapeQuery.java
@@ -21,6 +21,7 @@ import java.io.IOException;
import org.apache.lucene.spatial3d.geom.BasePlanetObject;
import org.apache.lucene.spatial3d.geom.GeoShape;
import org.apache.lucene.spatial3d.geom.PlanetModel;
+import org.apache.lucene.spatial3d.geom.XYZBounds;
import org.apache.lucene.index.PointValues;
import org.apache.lucene.index.LeafReader;
import org.apache.lucene.index.LeafReaderContext;
@@ -41,12 +42,15 @@ import org.apache.lucene.util.DocIdSetBuilder;
final class PointInGeo3DShapeQuery extends Query {
final String field;
final GeoShape shape;
-
+ final XYZBounds shapeBounds;
+
/** The lats/lons must be clockwise or counter-clockwise. */
public PointInGeo3DShapeQuery(String field, GeoShape shape) {
this.field = field;
this.shape = shape;
-
+ this.shapeBounds = new XYZBounds();
+ shape.getBounds(shapeBounds);
+
if (shape instanceof BasePlanetObject) {
BasePlanetObject planetObject = (BasePlanetObject) shape;
if (planetObject.getPlanetModel().equals(PlanetModel.WGS84) == false) {
@@ -95,7 +99,7 @@ final class PointInGeo3DShapeQuery extends Query {
DocIdSetBuilder result = new DocIdSetBuilder(reader.maxDoc());
- values.intersect(field, new PointInShapeIntersectVisitor(result, shape));
+ values.intersect(field, new PointInShapeIntersectVisitor(result, shape, shapeBounds));
return new ConstantScoreScorer(this, score(), result.build().iterator());
}
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/1d76b2c4/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/PointInShapeIntersectVisitor.java
----------------------------------------------------------------------
diff --git a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/PointInShapeIntersectVisitor.java b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/PointInShapeIntersectVisitor.java
index b9d4e70..348396b 100644
--- a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/PointInShapeIntersectVisitor.java
+++ b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/PointInShapeIntersectVisitor.java
@@ -23,16 +23,19 @@ import org.apache.lucene.spatial3d.geom.GeoArea;
import org.apache.lucene.spatial3d.geom.GeoAreaFactory;
import org.apache.lucene.spatial3d.geom.GeoShape;
import org.apache.lucene.spatial3d.geom.PlanetModel;
+import org.apache.lucene.spatial3d.geom.XYZBounds;
import org.apache.lucene.util.DocIdSetBuilder;
import org.apache.lucene.util.NumericUtils;
class PointInShapeIntersectVisitor implements IntersectVisitor {
private final DocIdSetBuilder hits;
private final GeoShape shape;
-
- public PointInShapeIntersectVisitor(DocIdSetBuilder hits, GeoShape shape) {
+ private final XYZBounds shapeBounds;
+
+ public PointInShapeIntersectVisitor(DocIdSetBuilder hits, GeoShape shape, XYZBounds shapeBounds) {
this.hits = hits;
this.shape = shape;
+ this.shapeBounds = shapeBounds;
}
@Override
@@ -46,8 +49,12 @@ class PointInShapeIntersectVisitor implements IntersectVisitor {
double x = Geo3DPoint.decodeDimension(packedValue, 0);
double y = Geo3DPoint.decodeDimension(packedValue, Integer.BYTES);
double z = Geo3DPoint.decodeDimension(packedValue, 2 * Integer.BYTES);
- if (shape.isWithin(x, y, z)) {
- hits.add(docID);
+ if (x >= shapeBounds.getMinimumX() && x <= shapeBounds.getMaximumX() &&
+ y >= shapeBounds.getMinimumY() && y <= shapeBounds.getMaximumY() &&
+ z >= shapeBounds.getMinimumZ() && z <= shapeBounds.getMaximumZ()) {
+ if (shape.isWithin(x, y, z)) {
+ hits.add(docID);
+ }
}
}
@@ -69,6 +76,14 @@ class PointInShapeIntersectVisitor implements IntersectVisitor {
assert yMin <= yMax;
assert zMin <= zMax;
+ // First, check bounds. If the shape is entirely contained, return CELL_CROSSES_QUERY.
+ if (shapeBounds.getMinimumX() >= xMin && shapeBounds.getMaximumX() <= xMax &&
+ shapeBounds.getMinimumY() >= yMin && shapeBounds.getMaximumY() <= yMax &&
+ shapeBounds.getMinimumZ() >= zMin && shapeBounds.getMaximumZ() <= zMax) {
+ return Relation.CELL_CROSSES_QUERY;
+ }
+
+ // Quick test failed so do slower one...
GeoArea xyzSolid = GeoAreaFactory.makeGeoArea(PlanetModel.WGS84, xMin, xMax, yMin, yMax, zMin, zMax);
switch(xyzSolid.getRelationship(shape)) {
[2/2] lucene-solr:master: Merge branch 'master' of
https://git-wip-us.apache.org/repos/asf/lucene-solr
Posted by kw...@apache.org.
Merge branch 'master' of https://git-wip-us.apache.org/repos/asf/lucene-solr
Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/ab906b5a
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/ab906b5a
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/ab906b5a
Branch: refs/heads/master
Commit: ab906b5a74a0a303f644b0448d9d207c66bf6945
Parents: 1d76b2c bdaddaf
Author: Karl Wright <Da...@gmail.com>
Authored: Thu Apr 14 20:47:05 2016 -0400
Committer: Karl Wright <Da...@gmail.com>
Committed: Thu Apr 14 20:47:05 2016 -0400
----------------------------------------------------------------------
solr/webapp/web/index.html | 2 +-
solr/webapp/web/js/angular/app.js | 1 +
2 files changed, 2 insertions(+), 1 deletion(-)
----------------------------------------------------------------------