You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by mi...@apache.org on 2015/10/19 23:28:06 UTC
svn commit: r1709483 - in /lucene/dev/branches/lucene6780/lucene/sandbox/src:
java/org/apache/lucene/util/GeoUtils.java
test/org/apache/lucene/search/TestGeoPointQuery.java
test/org/apache/lucene/util/BaseGeoPointTestCase.java
Author: mikemccand
Date: Mon Oct 19 21:28:06 2015
New Revision: 1709483
URL: http://svn.apache.org/viewvc?rev=1709483&view=rev
Log:
LUCENE-6780: mark slow tests nightly, turn back on some big bbox/distances in tests, use GeoUtils.bboxContains
Modified:
lucene/dev/branches/lucene6780/lucene/sandbox/src/java/org/apache/lucene/util/GeoUtils.java
lucene/dev/branches/lucene6780/lucene/sandbox/src/test/org/apache/lucene/search/TestGeoPointQuery.java
lucene/dev/branches/lucene6780/lucene/sandbox/src/test/org/apache/lucene/util/BaseGeoPointTestCase.java
Modified: lucene/dev/branches/lucene6780/lucene/sandbox/src/java/org/apache/lucene/util/GeoUtils.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6780/lucene/sandbox/src/java/org/apache/lucene/util/GeoUtils.java?rev=1709483&r1=1709482&r2=1709483&view=diff
==============================================================================
--- lucene/dev/branches/lucene6780/lucene/sandbox/src/java/org/apache/lucene/util/GeoUtils.java (original)
+++ lucene/dev/branches/lucene6780/lucene/sandbox/src/java/org/apache/lucene/util/GeoUtils.java Mon Oct 19 21:28:06 2015
@@ -76,7 +76,7 @@ public final class GeoUtils {
public static double compare(final double v1, final double v2) {
final double delta = v1-v2;
- return Math.abs(delta) <= TOLERANCE ? 0 : delta;
+ return ((int)(Math.abs(delta)/TOLERANCE)*TOLERANCE) <= TOLERANCE ? 0 : delta;
}
/**
Modified: lucene/dev/branches/lucene6780/lucene/sandbox/src/test/org/apache/lucene/search/TestGeoPointQuery.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6780/lucene/sandbox/src/test/org/apache/lucene/search/TestGeoPointQuery.java?rev=1709483&r1=1709482&r2=1709483&view=diff
==============================================================================
--- lucene/dev/branches/lucene6780/lucene/sandbox/src/test/org/apache/lucene/search/TestGeoPointQuery.java (original)
+++ lucene/dev/branches/lucene6780/lucene/sandbox/src/test/org/apache/lucene/search/TestGeoPointQuery.java Mon Oct 19 21:28:06 2015
@@ -157,16 +157,11 @@ public class TestGeoPointQuery extends B
}
if (rect.minLon < rect.maxLon) {
- return pointLat >= rect.minLat &&
- pointLat < rect.maxLat &&
- pointLon >= rect.minLon &&
- pointLon < rect.maxLon;
+ return GeoUtils.bboxContains(pointLon, pointLat, rect.minLon, rect.minLat, rect.maxLon, rect.maxLat);
} else {
// Rect crosses dateline:
- return pointLat >= rect.minLat &&
- pointLat < rect.maxLat &&
- (pointLon >= rect.minLon ||
- pointLon < rect.maxLon);
+ return GeoUtils.bboxContains(pointLon, pointLat, -180.0, rect.minLat, rect.maxLon, rect.maxLat)
+ || GeoUtils.bboxContains(pointLon, pointLat, rect.minLon, rect.minLat, 180.0, rect.maxLat);
}
}
@@ -200,15 +195,6 @@ public class TestGeoPointQuery extends B
return delta < (ptDistance*DISTANCE_PCT_ERR);
}
- // nocommit fixme!
- @AwaitsFix(bugUrl = "Fix Tolerance on GeoPolygonSearch tests")
- public void testExplicitFailure() throws Exception {
- TopDocs td = polygonQuery(new double[]{-116.6911, -116.6911, -116.39189, -116.39189, -116.6911},
- new double[]{-20.357460000000003, -19.424280000000003, -19.424280000000003, -20.357460000000003, -20.357460000000003},
- 20);
- assertEquals("Explicit Failure", 2, td.totalHits);
- }
-
public void testRectCrossesCircle() throws Exception {
assertTrue(GeoUtils.rectCrossesCircle(-180, -90, 180, 0.0, 0.667, 0.0, 88000.0));
}
Modified: lucene/dev/branches/lucene6780/lucene/sandbox/src/test/org/apache/lucene/util/BaseGeoPointTestCase.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6780/lucene/sandbox/src/test/org/apache/lucene/util/BaseGeoPointTestCase.java?rev=1709483&r1=1709482&r2=1709483&view=diff
==============================================================================
--- lucene/dev/branches/lucene6780/lucene/sandbox/src/test/org/apache/lucene/util/BaseGeoPointTestCase.java (original)
+++ lucene/dev/branches/lucene6780/lucene/sandbox/src/test/org/apache/lucene/util/BaseGeoPointTestCase.java Mon Oct 19 21:28:06 2015
@@ -69,9 +69,8 @@ public abstract class BaseGeoPointTestCa
// A particularly tricky adversary for BKD tree:
public void testSamePointManyTimes() throws Exception {
int numPoints = atLeast(1000);
- // TODO: GeoUtils are buggy/slow if we use small=false
- // boolean small = random().nextBoolean();
- boolean small = true;
+ // TODO: GeoUtils are potentially slow if we use small=false with heavy testing
+ boolean small = random().nextBoolean();
// Every doc has 2 points:
double theLat = randomLat(small);
@@ -86,9 +85,10 @@ public abstract class BaseGeoPointTestCa
verify(small, lats, lons);
}
+ @Nightly
public void testAllLatEqual() throws Exception {
int numPoints = atLeast(10000);
- // TODO: GeoUtils are buggy/slow if we use small=false
+ // TODO: GeoUtils are potentially slow if we use small=false with heavy testing
// boolean small = random().nextBoolean();
boolean small = true;
double lat = randomLat(small);
@@ -135,9 +135,10 @@ public abstract class BaseGeoPointTestCa
verify(small, lats, lons);
}
+ @Nightly
public void testAllLonEqual() throws Exception {
int numPoints = atLeast(10000);
- // TODO: GeoUtils are buggy/slow if we use small=false
+ // TODO: GeoUtils are potentially slow if we use small=false with heavy testing
// boolean small = random().nextBoolean();
boolean small = true;
double theLon = randomLon(small);
@@ -199,7 +200,7 @@ public abstract class BaseGeoPointTestCa
iwc.setMergePolicy(newLogMergePolicy());
RandomIndexWriter w = new RandomIndexWriter(random(), dir, iwc);
- // TODO: GeoUtils APIs are still slow/buggy with large distances
+ // TODO: GeoUtils are potentially slow if we use small=false with heavy testing
// boolean small = random().nextBoolean();
boolean small = true;
@@ -230,7 +231,7 @@ public abstract class BaseGeoPointTestCa
// We can't wrap with "exotic" readers because the BKD query must see the BKDDVFormat:
IndexSearcher s = newSearcher(r, false);
- int iters = atLeast(100);
+ int iters = atLeast(75);
for (int iter=0;iter<iters;iter++) {
// Don't allow dateline crossing when testing small:
GeoRect rect = randomRect(small, small == false);
@@ -331,9 +332,8 @@ public abstract class BaseGeoPointTestCa
double[] lats = new double[numPoints];
double[] lons = new double[numPoints];
- // TODO: GeoUtils APIs are still slow/buggy with large distances
- //boolean small = random().nextBoolean();
- boolean small = true;
+ // TODO: GeoUtils are potentially slow if we use small=false with heavy testing
+ boolean small = random().nextBoolean();
boolean haveRealDoc = false;
@@ -519,7 +519,6 @@ public abstract class BaseGeoPointTestCa
}
protected void verify(boolean small, double[] lats, double[] lons) throws Exception {
- assert small;
IndexWriterConfig iwc = newIndexWriterConfig();
// Else we can get O(N^2) merging:
int mbd = iwc.getMaxBufferedDocs();
@@ -568,7 +567,7 @@ public abstract class BaseGeoPointTestCa
int numThreads = TestUtil.nextInt(random(), 2, 5);
List<Thread> threads = new ArrayList<>();
- final int iters = atLeast(100);
+ final int iters = atLeast(75);
final CountDownLatch startingGun = new CountDownLatch(1);
final AtomicBoolean failed = new AtomicBoolean();
@@ -634,7 +633,14 @@ public abstract class BaseGeoPointTestCa
System.out.println(" radiusMeters = " + new DecimalFormat("#,###.00").format(radiusMeters));
}
- query = newDistanceQuery(FIELD_NAME, centerLat, centerLon, radiusMeters);
+ try {
+ query = newDistanceQuery(FIELD_NAME, centerLat, centerLon, radiusMeters);
+ } catch (IllegalArgumentException e) {
+ if (e.getMessage().contains("exceeds maxRadius")) {
+ continue;
+ }
+ throw e;
+ }
verifyHits = new VerifyHits() {
@Override
@@ -673,8 +679,7 @@ public abstract class BaseGeoPointTestCa
verifyHits = new VerifyHits() {
@Override
protected Boolean shouldMatch(double pointLat, double pointLon) {
- return GeoUtils.pointInPolygon(lons, lats, pointLat, pointLon);
-// return polyRectContainsPoint(bbox, pointLat, pointLon);
+ return polyRectContainsPoint(bbox, pointLat, pointLon);
}
@Override