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/10/02 19:21:05 UTC
lucene-solr:branch_6x: LUCENE-7430: Add some explicit delta for
bounds objects that corresponds to point resolution in doc values.
Repository: lucene-solr
Updated Branches:
refs/heads/branch_6x cc1841cbb -> d4a24af7e
LUCENE-7430: Add some explicit delta for bounds objects that corresponds to point resolution in doc values.
Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/d4a24af7
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/d4a24af7
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/d4a24af7
Branch: refs/heads/branch_6x
Commit: d4a24af7ea3e69c63e09edfe4d6a63e7d2fa2741
Parents: cc1841c
Author: Karl Wright <Da...@gmail.com>
Authored: Sun Oct 2 15:17:58 2016 -0400
Committer: Karl Wright <Da...@gmail.com>
Committed: Sun Oct 2 15:19:52 2016 -0400
----------------------------------------------------------------------
.../lucene/spatial3d/Geo3DDocValuesField.java | 54 ++++++++++++++++++++
.../spatial3d/PointInShapeIntersectVisitor.java | 30 +++++++----
.../apache/lucene/spatial3d/TestGeo3DPoint.java | 4 +-
3 files changed, 78 insertions(+), 10 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/d4a24af7/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/Geo3DDocValuesField.java
----------------------------------------------------------------------
diff --git a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/Geo3DDocValuesField.java b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/Geo3DDocValuesField.java
index dd171ec..ef33fd5 100644
--- a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/Geo3DDocValuesField.java
+++ b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/Geo3DDocValuesField.java
@@ -67,6 +67,12 @@ public class Geo3DDocValuesField extends Field {
private final static double yFactor = 1.0 / inverseYFactor;
private final static double zFactor = 1.0 / inverseZFactor;
+ // These values are the delta between a value and the next value in each specific dimension
+
+ private final static double xStep = inverseXFactor;
+ private final static double yStep = inverseYFactor;
+ private final static double zStep = inverseZFactor;
+
/**
* Type for a Geo3DDocValuesField
* <p>
@@ -182,6 +188,54 @@ public class Geo3DDocValuesField extends Field {
return decodeZ(((int)(docValue)) & 0x1FFFFF);
}
+ /** Round the provided X value down, by encoding it, decrementing it, and unencoding it.
+ * @param startValue is the starting value.
+ * @return the rounded value.
+ */
+ public static double roundDownX(final double startValue) {
+ return startValue - xStep;
+ }
+
+ /** Round the provided X value up, by encoding it, incrementing it, and unencoding it.
+ * @param startValue is the starting value.
+ * @return the rounded value.
+ */
+ public static double roundUpX(final double startValue) {
+ return startValue + xStep;
+ }
+
+ /** Round the provided Y value down, by encoding it, decrementing it, and unencoding it.
+ * @param startValue is the starting value.
+ * @return the rounded value.
+ */
+ public static double roundDownY(final double startValue) {
+ return startValue - yStep;
+ }
+
+ /** Round the provided Y value up, by encoding it, incrementing it, and unencoding it.
+ * @param startValue is the starting value.
+ * @return the rounded value.
+ */
+ public static double roundUpY(final double startValue) {
+ return startValue + yStep;
+ }
+
+ /** Round the provided Z value down, by encoding it, decrementing it, and unencoding it.
+ * @param startValue is the starting value.
+ * @return the rounded value.
+ */
+ public static double roundDownZ(final double startValue) {
+ return startValue - zStep;
+ }
+
+ /** Round the provided Z value up, by encoding it, incrementing it, and unencoding it.
+ * @param startValue is the starting value.
+ * @return the rounded value.
+ */
+ public static double roundUpZ(final double startValue) {
+ return startValue + zStep;
+ }
+
// For encoding/decoding, we generally want the following behavior:
// (1) If you encode the maximum value or the minimum value, the resulting int fits in 21 bits.
// (2) If you decode an encoded value, you get back the original value for both the minimum and maximum planet model values.
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/d4a24af7/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 7755109..422c40f 100644
--- a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/PointInShapeIntersectVisitor.java
+++ b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/PointInShapeIntersectVisitor.java
@@ -30,13 +30,25 @@ import org.apache.lucene.util.NumericUtils;
class PointInShapeIntersectVisitor implements IntersectVisitor {
private final DocIdSetBuilder hits;
private final GeoShape shape;
- private final XYZBounds shapeBounds;
+ private final double minimumX;
+ private final double maximumX;
+ private final double minimumY;
+ private final double maximumY;
+ private final double minimumZ;
+ private final double maximumZ;
private DocIdSetBuilder.BulkAdder adder;
- public PointInShapeIntersectVisitor(DocIdSetBuilder hits, GeoShape shape, XYZBounds shapeBounds) {
+ public PointInShapeIntersectVisitor(DocIdSetBuilder hits,
+ GeoShape shape,
+ XYZBounds bounds) {
this.hits = hits;
this.shape = shape;
- this.shapeBounds = shapeBounds;
+ this.minimumX = Geo3DDocValuesField.roundDownX(bounds.getMinimumX());
+ this.maximumX = Geo3DDocValuesField.roundUpX(bounds.getMaximumX());
+ this.minimumY = Geo3DDocValuesField.roundDownY(bounds.getMinimumY());
+ this.maximumY = Geo3DDocValuesField.roundUpY(bounds.getMaximumY());
+ this.minimumZ = Geo3DDocValuesField.roundDownZ(bounds.getMinimumZ());
+ this.maximumZ = Geo3DDocValuesField.roundUpZ(bounds.getMaximumZ());
}
@Override
@@ -55,9 +67,9 @@ 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 (x >= shapeBounds.getMinimumX() && x <= shapeBounds.getMaximumX() &&
- y >= shapeBounds.getMinimumY() && y <= shapeBounds.getMaximumY() &&
- z >= shapeBounds.getMinimumZ() && z <= shapeBounds.getMaximumZ()) {
+ if (x >= minimumX && x <= maximumX &&
+ y >= minimumY && y <= maximumY &&
+ z >= minimumZ && z <= maximumZ) {
if (shape.isWithin(x, y, z)) {
adder.add(docID);
}
@@ -83,9 +95,9 @@ class PointInShapeIntersectVisitor implements IntersectVisitor {
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) {
+ if (minimumX >= xMin && maximumX <= xMax &&
+ minimumY >= yMin && maximumY <= yMax &&
+ minimumZ >= zMin && maximumZ <= zMax) {
return Relation.CELL_CROSSES_QUERY;
}
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/d4a24af7/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 d9baf61..f5b7441 100644
--- a/lucene/spatial3d/src/test/org/apache/lucene/spatial3d/TestGeo3DPoint.java
+++ b/lucene/spatial3d/src/test/org/apache/lucene/spatial3d/TestGeo3DPoint.java
@@ -1480,7 +1480,9 @@ 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, scaledDocPoint, new PointInShapeIntersectVisitor(hits, shape, bounds), docID - reader.leaves().get(subIndex).docBase, 3, Integer.BYTES, b);
+ ExplainingVisitor visitor = new ExplainingVisitor(shape, targetDocPoint, scaledDocPoint,
+ new PointInShapeIntersectVisitor(hits, shape, bounds),
+ 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);