You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by rm...@apache.org on 2016/03/28 20:37:16 UTC
lucene-solr:master: don't quantize ALL generated points in this test,
just the ones we index (except for some leniency: see the TODO).
Repository: lucene-solr
Updated Branches:
refs/heads/master 8c5115ea9 -> 9189bdc1c
don't quantize ALL generated points in this test, just the ones we index (except for some leniency: see the TODO).
This may cause more test failures!
Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/9189bdc1
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/9189bdc1
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/9189bdc1
Branch: refs/heads/master
Commit: 9189bdc1c27d0519f7aa1a533b0fc3a68a1d9611
Parents: 8c5115e
Author: Robert Muir <rm...@apache.org>
Authored: Mon Mar 28 14:39:01 2016 -0400
Committer: Robert Muir <rm...@apache.org>
Committed: Mon Mar 28 14:39:01 2016 -0400
----------------------------------------------------------------------
.../spatial/util/BaseGeoPointTestCase.java | 31 +++++++++++---------
1 file changed, 17 insertions(+), 14 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/9189bdc1/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 5958910..021d638 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
@@ -485,12 +485,12 @@ public abstract class BaseGeoPointTestCase extends LuceneTestCase {
for (int id=0;id<numPoints;id++) {
Document doc = new Document();
- lats[2*id] = randomLat(small);
- lons[2*id] = randomLon(small);
+ lats[2*id] = quantizeLat(randomLat(small));
+ lons[2*id] = quantizeLon(randomLon(small));
doc.add(newStringField("id", ""+id, Field.Store.YES));
addPointToDoc(FIELD_NAME, doc, lats[2*id], lons[2*id]);
- lats[2*id+1] = randomLat(small);
- lons[2*id+1] = randomLon(small);
+ lats[2*id+1] = quantizeLat(randomLat(small));
+ lons[2*id+1] = quantizeLon(randomLon(small));
addPointToDoc(FIELD_NAME, doc, lats[2*id+1], lons[2*id+1]);
if (VERBOSE) {
@@ -513,6 +513,8 @@ public abstract class BaseGeoPointTestCase extends LuceneTestCase {
int iters = atLeast(25);
for (int iter=0;iter<iters;iter++) {
GeoRect rect = randomRect(small);
+ // TODO: why does this test need this quantization leniency? something is not right
+ rect = new GeoRect(quantizeLat(rect.minLat), quantizeLat(rect.maxLat), quantizeLon(rect.minLon), quantizeLon(rect.maxLon));
if (VERBOSE) {
System.out.println("\nTEST: iter=" + iter + " rect=" + rect);
@@ -664,26 +666,20 @@ public abstract class BaseGeoPointTestCase extends LuceneTestCase {
}
public double randomLat(boolean small) {
- double result;
if (small) {
- result = GeoTestUtil.nextLatitudeNear(originLat);
+ return GeoTestUtil.nextLatitudeNear(originLat);
} else {
- result = GeoTestUtil.nextLatitude();
+ return GeoTestUtil.nextLatitude();
}
- return quantizeLat(result);
}
public double randomLon(boolean small) {
- double result;
if (small) {
- result = GeoTestUtil.nextLongitudeNear(originLon);
+ return GeoTestUtil.nextLongitudeNear(originLon);
} else {
- result = GeoTestUtil.nextLongitude();
+ return GeoTestUtil.nextLongitude();
}
- return quantizeLon(result);
}
-
-
/** Override this to quantize randomly generated lat, so the test won't fail due to quantization errors, which are 1) annoying to debug,
* and 2) should never affect "real" usage terribly. */
@@ -729,6 +725,13 @@ public abstract class BaseGeoPointTestCase extends LuceneTestCase {
}
private void verify(boolean small, double[] lats, double[] lons) throws Exception {
+ // quantize each value the same way the index does
+ for (int i = 0; i < lats.length; i++) {
+ lats[i] = quantizeLat(lats[i]);
+ }
+ for (int i = 0; i < lons.length; i++) {
+ lons[i] = quantizeLon(lons[i]);
+ }
verifyRandomRectangles(small, lats, lons);
verifyRandomDistances(small, lats, lons);
verifyRandomPolygons(small, lats, lons);