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/08 12:07:35 UTC

[1/2] lucene-solr:master: LUCENE-7191: Tests now exercise the query factory methods in Geo3DPoint.

Repository: lucene-solr
Updated Branches:
  refs/heads/master c906b4fc5 -> 9b65416e6


LUCENE-7191: Tests now exercise the query factory methods in Geo3DPoint.


Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/99fa5590
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/99fa5590
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/99fa5590

Branch: refs/heads/master
Commit: 99fa55906c1f5ee8c7572d7980e224edffe3222e
Parents: 5e47773
Author: Karl Wright <Da...@gmail.com>
Authored: Fri Apr 8 01:33:46 2016 -0400
Committer: Karl Wright <Da...@gmail.com>
Committed: Fri Apr 8 01:33:46 2016 -0400

----------------------------------------------------------------------
 .../apache/lucene/spatial3d/TestGeo3DPoint.java | 81 ++++++++++++++++++--
 1 file changed, 74 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/99fa5590/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 5aaa835..98446d3 100644
--- a/lucene/spatial3d/src/test/org/apache/lucene/spatial3d/TestGeo3DPoint.java
+++ b/lucene/spatial3d/src/test/org/apache/lucene/spatial3d/TestGeo3DPoint.java
@@ -37,6 +37,7 @@ import org.apache.lucene.document.Field;
 import org.apache.lucene.document.NumericDocValuesField;
 import org.apache.lucene.geo.GeoTestUtil;
 import org.apache.lucene.geo.Polygon;
+import org.apache.lucene.geo.Rectangle;
 import org.apache.lucene.index.DirectoryReader;
 import org.apache.lucene.index.IndexReader;
 import org.apache.lucene.index.IndexWriter;
@@ -54,8 +55,10 @@ import org.apache.lucene.index.Term;
 import org.apache.lucene.search.IndexSearcher;
 import org.apache.lucene.search.Query;
 import org.apache.lucene.search.SimpleCollector;
+import org.apache.lucene.spatial3d.geom.XYZSolid;
 import org.apache.lucene.spatial3d.geom.GeoArea;
 import org.apache.lucene.spatial3d.geom.GeoAreaFactory;
+import org.apache.lucene.spatial3d.geom.GeoBBox;
 import org.apache.lucene.spatial3d.geom.GeoBBoxFactory;
 import org.apache.lucene.spatial3d.geom.GeoCircleFactory;
 import org.apache.lucene.spatial3d.geom.GeoPathFactory;
@@ -514,6 +517,68 @@ public class TestGeo3DPoint extends LuceneTestCase {
     verify(lats, lons);
   }
 
+  private static final double MEAN_EARTH_RADIUS_METERS = PlanetModel.WGS84_MEAN;
+  
+  private static Query random3DQuery(final String field) {
+    while (true) {
+      final int shapeType = random().nextInt(4);
+      switch (shapeType) {
+      case 0: {
+        // Polygons
+        final boolean isClockwise = random().nextDouble() < 0.5;
+        try {
+          return Geo3DPoint.newPolygonQuery(field, makePoly(PlanetModel.WGS84,
+            new GeoPoint(PlanetModel.WGS84, toRadians(GeoTestUtil.nextLatitude()), toRadians(GeoTestUtil.nextLongitude())),
+            isClockwise,
+            true));
+        } catch (IllegalArgumentException e) {
+          continue;
+        }
+      }
+
+      case 1: {
+        // Circles
+        final double widthMeters = random().nextDouble() * Math.PI * MEAN_EARTH_RADIUS_METERS;
+        try {
+          return Geo3DPoint.newDistanceQuery(field, GeoTestUtil.nextLatitude(), GeoTestUtil.nextLongitude(), widthMeters);
+        } catch (IllegalArgumentException e) {
+          continue;
+        }
+      }
+
+      case 2: {
+        // Rectangles
+        final Rectangle r = GeoTestUtil.nextBox();
+        return Geo3DPoint.newBoxQuery(field, r.minLat, r.maxLat, r.minLon, r.maxLon);
+      }
+
+      case 3: {
+        // Paths
+        // TBD: Need to rework generation to be realistic
+        final int pointCount = random().nextInt(5) + 1;
+        final double width = random().nextDouble() * Math.PI * 0.5 * MEAN_EARTH_RADIUS_METERS;
+        final double[] latitudes = new double[pointCount];
+        final double[] longitudes = new double[pointCount];
+        for (int i = 0; i < pointCount; i++) {
+          latitudes[i] = GeoTestUtil.nextLatitude();
+          longitudes[i] = GeoTestUtil.nextLongitude();
+        }
+        try {
+          return Geo3DPoint.newPathQuery(field, latitudes, longitudes, width);
+        } catch (IllegalArgumentException e) {
+          // This is what happens when we create a shape that is invalid.  Although it is conceivable that there are cases where
+          // the exception is thrown incorrectly, we aren't going to be able to do that in this random test.
+          continue;
+        }
+      }
+
+      default:
+        throw new IllegalStateException("Unexpected shape type");
+      }
+    }
+
+  }
+  
   // Poached from Geo3dRptTest.randomShape:
   private static GeoShape randomShape() {
     while (true) {
@@ -660,13 +725,15 @@ public class TestGeo3DPoint extends LuceneTestCase {
 
     for (int iter=0;iter<iters;iter++) {
 
+      /*
       GeoShape shape = randomShape();
 
       if (VERBOSE) {
         System.err.println("\nTEST: iter=" + iter + " shape="+shape);
       }
-              
-      Query query = Geo3DPoint.newShapeQuery("point", shape);
+      */
+      
+      Query query = random3DQuery("point"); // Geo3DPoint.newShapeQuery("point", shape);
 
       if (VERBOSE) {
         System.err.println("  using query: " + query);
@@ -702,7 +769,7 @@ public class TestGeo3DPoint extends LuceneTestCase {
         int id = (int) docIDToID.get(docID);
         GeoPoint point = points[id];
         if (point != null) {
-          boolean expected = ((deleted.contains(id) == false) && shape.isWithin(point));
+          boolean expected = ((deleted.contains(id) == false) && ((PointInGeo3DShapeQuery)query).getShape().isWithin(point));
           if (hits.get(docID) != expected) {
             StringBuilder b = new StringBuilder();
             if (expected) {
@@ -710,11 +777,11 @@ public class TestGeo3DPoint extends LuceneTestCase {
             } else {
               b.append("FAIL: id=" + id + " should not have matched but did\n");
             }
-            b.append("  shape=" + shape + "\n");
+            b.append("  shape=" + ((PointInGeo3DShapeQuery)query).getShape() + "\n");
             b.append("  point=" + point + "\n");
             b.append("  docID=" + docID + " deleted?=" + deleted.contains(id) + "\n");
             b.append("  query=" + query + "\n");
-            b.append("  explanation:\n    " + explain("point", shape, r, docID).replace("\n", "\n  "));
+            b.append("  explanation:\n    " + explain("point", ((PointInGeo3DShapeQuery)query).getShape(), r, docID).replace("\n", "\n  "));
             fail(b.toString());
           }
         } else {
@@ -770,7 +837,7 @@ public class TestGeo3DPoint extends LuceneTestCase {
       final Polygon counterClockWise = makePoly(pm, randomPole, false, true);
     }
   }
-  
+
   protected static double MINIMUM_EDGE_ANGLE = Math.toRadians(5.0);
   protected static double MINIMUM_ARC_ANGLE = Math.toRadians(1.0);
   
@@ -779,7 +846,7 @@ public class TestGeo3DPoint extends LuceneTestCase {
     * doesn't do it because it's almost impossible to come up with nested ones of the proper 
     * clockwise/counterclockwise rotation that way.
     */
-  protected Polygon makePoly(final PlanetModel pm, final GeoPoint pole, final boolean clockwiseDesired, final boolean createHoles) {
+  protected static Polygon makePoly(final PlanetModel pm, final GeoPoint pole, final boolean clockwiseDesired, final boolean createHoles) {
     // Polygon edges will be arranged around the provided pole, and holes will each have a pole selected within the parent
     // polygon.
     final int pointCount = TestUtil.nextInt(random(), 3, 10);


[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/9b65416e
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/9b65416e
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/9b65416e

Branch: refs/heads/master
Commit: 9b65416e60d1183e0d145646c36e5eb9018603f8
Parents: 99fa559 c906b4f
Author: Karl Wright <Da...@gmail.com>
Authored: Fri Apr 8 06:07:13 2016 -0400
Committer: Karl Wright <Da...@gmail.com>
Committed: Fri Apr 8 06:07:13 2016 -0400

----------------------------------------------------------------------
 .../utils/ConfusionMatrixGenerator.java         |  39 +++-
 .../BooleanPerceptronClassifierTest.java        |   2 +-
 .../CachingNaiveBayesClassifierTest.java        |   2 +-
 .../KNearestNeighborClassifierTest.java         |   2 +-
 .../SimpleNaiveBayesClassifierTest.java         |   2 +-
 .../utils/ConfusionMatrixGeneratorTest.java     |  30 ++-
 .../org/apache/lucene/spatial3d/Geo3DUtil.java  |  44 +---
 .../apache/lucene/spatial3d/TestGeo3DPoint.java |  21 +-
 solr/CHANGES.txt                                |   3 +
 .../handler/dataimport/SolrEntityProcessor.java |  10 +-
 .../dataimport/TestContentStreamDataSource.java |   4 +-
 .../TestSolrEntityProcessorEndToEnd.java        |   2 +-
 .../src/java/org/apache/solr/hadoop/GoLive.java |   6 +-
 .../solr/hadoop/MorphlineGoLiveMiniMRTest.java  |   4 +-
 .../solr/SafeConcurrentUpdateSolrClient.java    |   2 +-
 .../solr/morphlines/solr/SolrLocator.java       |   5 +-
 .../solr/AbstractSolrMorphlineTestBase.java     |   2 +-
 .../cloud/LeaderInitiatedRecoveryThread.java    |   2 +-
 .../OverseerAutoReplicaFailoverThread.java      |  32 ++-
 .../cloud/OverseerCollectionMessageHandler.java |   2 +-
 .../org/apache/solr/cloud/RecoveryStrategy.java |   5 +-
 .../org/apache/solr/cloud/SyncStrategy.java     |   2 +-
 .../org/apache/solr/cloud/ZkController.java     |   3 +-
 .../apache/solr/cloud/rule/SnitchContext.java   |   3 +-
 .../solr/handler/CdcrReplicatorManager.java     |  18 +-
 .../apache/solr/handler/CdcrRequestHandler.java |   2 +-
 .../solr/handler/CdcrUpdateLogSynchronizer.java |   2 +-
 .../org/apache/solr/handler/IndexFetcher.java   |  12 +-
 .../apache/solr/handler/SolrConfigHandler.java  |   3 +-
 .../solr/handler/admin/CollectionsHandler.java  |   3 +-
 .../handler/component/HttpShardHandler.java     |   5 +-
 .../component/HttpShardHandlerFactory.java      |   5 +-
 .../component/IterativeMergeStrategy.java       |   7 +-
 .../apache/solr/schema/ManagedIndexSchema.java  |   2 +-
 .../apache/solr/update/SolrCmdDistributor.java  |   3 +-
 .../solr/update/StreamingSolrClients.java       |  66 +++---
 .../src/java/org/apache/solr/util/SolrCLI.java  |  21 +-
 .../org/apache/solr/TestTolerantSearch.java     |   6 +-
 .../solr/client/solrj/ConnectionReuseTest.java  |   6 +-
 .../solrj/embedded/TestJettySolrRunner.java     |   3 +-
 .../apache/solr/cloud/AliasIntegrationTest.java |  14 +-
 .../solr/cloud/AsyncMigrateRouteKeyTest.java    |   2 +-
 .../solr/cloud/BaseCdcrDistributedZkTest.java   |   4 +-
 .../solr/cloud/BasicDistributedZk2Test.java     |   6 +-
 .../solr/cloud/BasicDistributedZkTest.java      |  14 +-
 .../cloud/ChaosMonkeyNothingIsSafeTest.java     |  46 ++--
 .../apache/solr/cloud/CollectionReloadTest.java |   2 +-
 .../cloud/CollectionsAPIDistributedZkTest.java  |  12 +-
 .../solr/cloud/CollectionsAPISolrJTest.java     |   2 +-
 ...ConcurrentDeleteAndCreateCollectionTest.java |   6 +-
 .../apache/solr/cloud/CustomCollectionTest.java |  12 +-
 .../solr/cloud/DeleteInactiveReplicaTest.java   |   2 +-
 .../apache/solr/cloud/DeleteReplicaTest.java    |   4 +-
 .../org/apache/solr/cloud/DeleteShardTest.java  |   6 +-
 .../solr/cloud/DistributedVersionInfoTest.java  |   8 +-
 .../org/apache/solr/cloud/ForceLeaderTest.java  |   2 +-
 .../cloud/FullSolrCloudDistribCmdsTest.java     |   2 +-
 .../apache/solr/cloud/HttpPartitionTest.java    |   2 +-
 .../LeaderInitiatedRecoveryOnCommitTest.java    |   2 +-
 ...aderInitiatedRecoveryOnShardRestartTest.java |   2 +-
 .../apache/solr/cloud/MigrateRouteKeyTest.java  |   4 +-
 .../solr/cloud/ReplicationFactorTest.java       |   2 +-
 .../org/apache/solr/cloud/SSLMigrationTest.java |   2 +-
 .../org/apache/solr/cloud/ShardSplitTest.java   |  33 ++-
 .../org/apache/solr/cloud/SyncSliceTest.java    |   2 +-
 .../solr/cloud/TestCloudDeleteByQuery.java      |  10 +-
 .../apache/solr/cloud/TestConfigSetsAPI.java    |  20 +-
 .../cloud/TestConfigSetsAPIExclusivity.java     |   4 +-
 .../solr/cloud/TestConfigSetsAPIZkFailure.java  |   4 +-
 .../org/apache/solr/cloud/TestCryptoKeys.java   |   2 +-
 .../solr/cloud/TestMiniSolrCloudClusterSSL.java |   2 +-
 .../cloud/TestRandomRequestDistribution.java    |   4 +-
 .../cloud/TestRequestStatusCollectionAPI.java   |   2 +-
 .../cloud/TestTolerantUpdateProcessorCloud.java |  10 +-
 .../TestTolerantUpdateProcessorRandomCloud.java |   2 +-
 .../solr/cloud/UnloadDistributedZkTest.java     |  30 +--
 .../HdfsWriteToMultipleCollectionsTest.java     |   2 +-
 .../apache/solr/cloud/hdfs/StressHdfsTest.java  |   2 +-
 .../solr/core/OpenCloseCoreStressTest.java      |   4 +-
 .../apache/solr/core/TestDynamicLoading.java    |   2 +-
 .../solr/handler/TestReplicationHandler.java    |   5 +-
 .../handler/TestReplicationHandlerBackup.java   |   3 +-
 .../apache/solr/handler/TestRestoreCore.java    |   3 +-
 .../handler/admin/CoreAdminHandlerTest.java     |   4 +-
 .../DistributedDebugComponentTest.java          |   6 +-
 .../DistributedQueryElevationComponentTest.java |   3 +-
 .../test/org/apache/solr/search/TestSolrJ.java  |   4 +-
 .../solr/search/stats/TestDistribIDF.java       |   8 +-
 .../solr/security/BasicAuthIntegrationTest.java |   3 +-
 .../processor/TestNamedUpdateProcessors.java    |   3 +-
 .../apache/solr/util/TestSolrCLIRunExample.java |   4 +-
 .../solr/client/solrj/impl/CloudSolrClient.java | 229 ++++++++++++++++---
 .../solrj/impl/ConcurrentUpdateSolrClient.java  | 148 ++++++++++--
 .../solr/client/solrj/impl/HttpSolrClient.java  |  77 ++++++-
 .../client/solrj/impl/LBHttpSolrClient.java     | 126 ++++++++--
 .../solr/client/solrj/io/SolrClientCache.java   |   9 +-
 .../solrj/io/sql/DatabaseMetaDataImpl.java      |   4 +-
 .../client/solrj/io/stream/CloudSolrStream.java |   7 +-
 .../client/solrj/io/stream/FacetStream.java     |   8 +-
 .../solr/client/solrj/io/stream/SolrStream.java |   4 +-
 .../client/solrj/io/stream/StatsStream.java     |   7 +-
 .../client/solrj/io/stream/TopicStream.java     |   8 +-
 .../client/solrj/io/stream/UpdateStream.java    |   5 +-
 .../client/solrj/SolrExampleBinaryTest.java     |   2 +-
 .../solr/client/solrj/SolrExampleTests.java     |   2 +-
 .../solr/client/solrj/SolrExampleXMLTest.java   |   2 +-
 .../solr/client/solrj/SolrExceptionTest.java    |   4 +-
 .../client/solrj/SolrSchemalessExampleTest.java |   2 +-
 .../solr/client/solrj/TestLBHttpSolrClient.java |   8 +-
 .../solrj/embedded/SolrExampleJettyTest.java    |   2 +-
 .../embedded/SolrExampleStreamingTest.java      |  23 +-
 .../solrj/impl/BasicHttpSolrClientTest.java     |  47 ++--
 .../solrj/impl/CloudSolrClientBuilderTest.java  |  90 ++++++++
 .../client/solrj/impl/CloudSolrClientTest.java  |  21 +-
 .../ConcurrentUpdateSolrClientBuilderTest.java  |  33 +++
 .../impl/ConcurrentUpdateSolrClientTest.java    |  37 ++-
 .../solrj/impl/HttpSolrClientBuilderTest.java   |  76 ++++++
 .../solrj/impl/LBHttpSolrClientBuilderTest.java |  65 ++++++
 .../solr/BaseDistributedSearchTestCase.java     |   2 +-
 .../java/org/apache/solr/SolrJettyTestBase.java |   2 +-
 .../java/org/apache/solr/SolrTestCaseHS.java    |  40 ++--
 .../java/org/apache/solr/SolrTestCaseJ4.java    | 142 ++++++++++++
 .../cloud/AbstractFullDistribZkTestBase.java    |  18 +-
 .../apache/solr/cloud/MiniSolrCloudCluster.java |   5 +-
 124 files changed, 1457 insertions(+), 530 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/9b65416e/lucene/spatial3d/src/test/org/apache/lucene/spatial3d/TestGeo3DPoint.java
----------------------------------------------------------------------