You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by ab...@apache.org on 2018/04/16 17:21:21 UTC
[41/46] lucene-solr:jira/solr-11833: SOLR-11731: revert to 7 decimal
places so we can maintain the round-trip property. Add test that we
round-trip random numbers at 7 decimal places. Would fail at 8.
SOLR-11731: revert to 7 decimal places so we can maintain the round-trip property.
Add test that we round-trip random numbers at 7 decimal places. Would fail at 8.
Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/dad2d107
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/dad2d107
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/dad2d107
Branch: refs/heads/jira/solr-11833
Commit: dad2d1076db632535c33fa118eb851ad7d0e2537
Parents: 93f9a65
Author: David Smiley <ds...@apache.org>
Authored: Sat Apr 14 10:51:51 2018 -0400
Committer: David Smiley <ds...@apache.org>
Committed: Sat Apr 14 10:51:51 2018 -0400
----------------------------------------------------------------------
solr/CHANGES.txt | 2 +-
.../apache/solr/schema/LatLonPointSpatialField.java | 4 ++--
.../org/apache/solr/search/TestSolr4Spatial2.java | 15 ++++++++++++---
3 files changed, 15 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/dad2d107/solr/CHANGES.txt
----------------------------------------------------------------------
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index b39fd6f..08c246f 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -168,7 +168,7 @@ Optimizations
a few segments diverge. (Ishan Chattopadhyaya, Shaun Sabo, John Gallagher)
* SOLR-11731: LatLonPointSpatialField can now decode points from docValues when stored=false docValues=true,
- albeit with maximum precision of 1.04cm (Karthik Ramachandran, David Smiley)
+ albeit with maximum precision of 1.37cm (Karthik Ramachandran, David Smiley)
* SOLR-11891: DocStreamer now respects the ReturnFields when populating a SolrDocument, reducing the
number of unneccessary fields a ResponseWriter will see if documentCache is used (wei wang, hossman)
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/dad2d107/solr/core/src/java/org/apache/solr/schema/LatLonPointSpatialField.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/schema/LatLonPointSpatialField.java b/solr/core/src/java/org/apache/solr/schema/LatLonPointSpatialField.java
index dd3f586..dfdd074 100644
--- a/solr/core/src/java/org/apache/solr/schema/LatLonPointSpatialField.java
+++ b/solr/core/src/java/org/apache/solr/schema/LatLonPointSpatialField.java
@@ -87,10 +87,10 @@ public class LatLonPointSpatialField extends AbstractSpatialFieldType implements
public static String decodeDocValueToString(long value) {
final double latDouble = GeoEncodingUtils.decodeLatitude((int) (value >> 32));
final double lonDouble = GeoEncodingUtils.decodeLongitude((int) (value & 0xFFFFFFFFL));
- // This # decimal places maximizes our available precision to just over a centimeter; we have a test for it.
+ // This # decimal places gets us close to our available precision to 1.37cm; we have a test for it.
// CEILING round-trips (decode then re-encode then decode to get identical results). Others did not. It also
// reverses the "floor" that occurred when we encoded.
- final int DECIMAL_PLACES = 8;
+ final int DECIMAL_PLACES = 7;
final RoundingMode ROUND_MODE = CEILING;
BigDecimal latitudeDecoded = BigDecimal.valueOf(latDouble).setScale(DECIMAL_PLACES, ROUND_MODE);
BigDecimal longitudeDecoded = BigDecimal.valueOf(lonDouble).setScale(DECIMAL_PLACES, ROUND_MODE);
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/dad2d107/solr/core/src/test/org/apache/solr/search/TestSolr4Spatial2.java
----------------------------------------------------------------------
diff --git a/solr/core/src/test/org/apache/solr/search/TestSolr4Spatial2.java b/solr/core/src/test/org/apache/solr/search/TestSolr4Spatial2.java
index df1c8cd..e5dc691 100644
--- a/solr/core/src/test/org/apache/solr/search/TestSolr4Spatial2.java
+++ b/solr/core/src/test/org/apache/solr/search/TestSolr4Spatial2.java
@@ -16,6 +16,7 @@
*/
package org.apache.solr.search;
+import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
@@ -56,6 +57,7 @@ public class TestSolr4Spatial2 extends SolrTestCaseJ4 {
public void setUp() throws Exception {
super.setUp();
clearIndex();
+ RetrievalCombo.idCounter = 0;
}
@Test
@@ -164,18 +166,25 @@ public class TestSolr4Spatial2 extends SolrTestCaseJ4 {
= SpatialContext.GEO.calcDistance(absErrorPt, 0,0) * DistanceUtils.DEG_TO_KM * 1000.0 * 100.0;
assertEquals(1.0420371840922256, deltaCentimetersMax, 0.0);// just so that we see it in black & white in the test
- assertTrue("deltaCm too high: " + deltaCentimeters, deltaCentimeters <= deltaCentimetersMax);
+ //max found by trial & error. If we used 8 decimal places then we could get down to 1.04cm accuracy but then we
+ // lose the ability to round-trip -- 40 would become 39.99999997 (ugh).
+ assertTrue("deltaCm too high: " + deltaCentimeters, deltaCentimeters <= 1.37);
}
@Test
public void testLatLonRetrieval() throws Exception {
- final String ptHighPrecision = "40.2996543270,-74.0824956673";
+ final String ptHighPrecision = "40.2996543270,-74.0824956673";
final String ptLossOfPrecision = "40.2996544,-74.0824957"; // rounded version of the one above, losing precision
// "_1" is single, "_N" is multiValued
// "_dv" is docValues (otherwise not), "_dvasst" is useDocValuesAsStored (otherwise not)
// "_st" is stored" (otherwise not)
+ // a random point using the number of decimal places we support for round-tripping.
+ String randPointStr =
+ new BigDecimal(GeoTestUtil.nextLatitude()).setScale(7, BigDecimal.ROUND_HALF_UP).stripTrailingZeros().toPlainString() +
+ "," + new BigDecimal(GeoTestUtil.nextLongitude()).setScale(7, BigDecimal.ROUND_HALF_UP).stripTrailingZeros().toPlainString();
+
List<RetrievalCombo> combos = Arrays.asList(
new RetrievalCombo("llp_1_dv_st", ptHighPrecision),
new RetrievalCombo("llp_N_dv_st", Arrays.asList("-40,40", "-45,45")),
@@ -184,7 +193,7 @@ public class TestSolr4Spatial2 extends SolrTestCaseJ4 {
new RetrievalCombo("llp_1_dv_dvasst", ptHighPrecision, ptLossOfPrecision),
// this one comes back in a different order since it gets sorted low to high
new RetrievalCombo("llp_N_dv_dvasst", Arrays.asList("-40,40", "-45,45"), Arrays.asList("-45,45", "-40,40")),
- new RetrievalCombo("llp_N_dv_dvasst", Arrays.asList("-40,40")), // multiValued but 1 value
+ new RetrievalCombo("llp_N_dv_dvasst", Arrays.asList(randPointStr)), // multiValued but 1 value
// edge cases. (note we sorted it as Lucene will internally)
new RetrievalCombo("llp_N_dv_dvasst", Arrays.asList(
"-90,180", "-90,-180",