Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Geo: replace intermediate geo objects with libs/geo #37721

Merged
merged 7 commits into from
Jan 25, 2019

Conversation

imotov
Copy link
Contributor

@imotov imotov commented Jan 22, 2019

Replaces intermediate geo objects built by ShapeBuilders with
objects from the libs/geo hierarchy. This should allow us to build
all geo functionality around a single hierarchy.

Follow up for #35320

Replaces intermediate geo objects built by ShapeBuilders with
objects from the libs/geo hierarchy. This should allow us to build
all geo functionality around a single hierarchy.

Follow up for elastic#35320
@imotov imotov added :Analytics/Geo Indexing, search aggregations of geo points and shapes v7.0.0 >refactoring labels Jan 22, 2019
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-analytics-geo

@imotov
Copy link
Contributor Author

imotov commented Jan 22, 2019

@atorok I had to make a few changes, otherwise server couldn't find the dependencies for some reason. Could you take a look and see if there is a better way to do that? Thanks!

@@ -21,6 +21,16 @@ apply plugin: 'elasticsearch.build'
apply plugin: 'nebula.maven-base-publish'
apply plugin: 'nebula.maven-scm'

archivesBaseName = 'elasticsearch-geo'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change should not be needed since we have project(":libs:geo").name = 'elasticsearch-geo' in settings.gradle. Do you get an error without this ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@atorok when I tried to do that I have got:

* Where:
Build file '/home/igor/Projects/Elastic/7.x/elasticsearch/build.gradle' line: 279

* What went wrong:
A problem occurred configuring root project 'elasticsearch'.
> Project :libs:geo not found.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you have to reference it by the changed name as :libs:elasticsearch-geo

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I get the same thing only with a different name:

FAILURE: Build failed with an exception.

* Where:
Settings file '/home/igor/Projects/Elastic/7.x/elasticsearch/settings.gradle' line: 155

* What went wrong:
A problem occurred evaluating settings 'elasticsearch'.
> Project with path ':libs:elasticsearch-geo' could not be found.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe you forgot to revert the change in settings.gradle ?
This work for me (I can ./gradlew assemble):

diff --git a/build.gradle b/build.gradle
index 8f359365794..c611cb7cedb 100644
--- a/build.gradle
+++ b/build.gradle
@@ -212,7 +212,7 @@ allprojects {
     "org.elasticsearch:elasticsearch-core:${version}": ':libs:core',
     "org.elasticsearch:elasticsearch-nio:${version}": ':libs:nio',
     "org.elasticsearch:elasticsearch-x-content:${version}": ':libs:x-content',
-    "org.elasticsearch:elasticsearch-geo:${version}": ':libs:geo',
+    "org.elasticsearch:elasticsearch-geo:${version}": ':libs:elasticsearch-geo',
     "org.elasticsearch:elasticsearch-secure-sm:${version}": ':libs:secure-sm',
     "org.elasticsearch.client:elasticsearch-rest-client:${version}": ':client:rest',
     "org.elasticsearch.client:elasticsearch-rest-client-sniffer:${version}": ':client:sniffer',
diff --git a/libs/geo/build.gradle b/libs/geo/build.gradle
index fdfdc5c7b12..ab3419b93b9 100644
--- a/libs/geo/build.gradle
+++ b/libs/geo/build.gradle
@@ -21,16 +21,6 @@ apply plugin: 'elasticsearch.build'
 apply plugin: 'nebula.maven-base-publish'
 apply plugin: 'nebula.maven-scm'
 
-archivesBaseName = 'elasticsearch-geo'
-
-publishing {
-    publications {
-        nebula {
-            artifactId = archivesBaseName
-        }
-    }
-}
-
 dependencies {
     if (isEclipse == false || project.path == ":libs:geo-tests") {
         testCompile("org.elasticsearch.test:framework:${version}") {
diff --git a/settings.gradle b/settings.gradle
index a9f08e53cb0..c098dc2c723 100644
--- a/settings.gradle
+++ b/settings.gradle
@@ -152,3 +152,4 @@ if (extraProjects.exists()) {
 
 project(":libs:cli").name = 'elasticsearch-cli'
 project(":libs:ssl-config").name = 'elasticsearch-ssl-config'
+project(":libs:geo").name = 'elasticsearch-geo'

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@atorok I could swear that I did exactly that and server couldn't pick up geo as a dependency :-) except... I just repeated that and it works. So I must have missed something. Thanks!

Copy link
Contributor

@nknize nknize left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work. I like where this is going. It'll make it cleaner to decouple JTS in the future. Just a few comments but I think this is close.

@@ -67,6 +67,14 @@ public double getLon(int i) {
return lons[i];
}

public double[] getLats() {
return lats;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For safety can we change this to return lats.clone()?

}

public double[] getLons() {
return lons;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here: return lons.clone()

indexShape(context, o);
}
if (luceneShape instanceof Geometry) {
((Geometry) luceneShape).visit(new GeometryVisitor<Void>() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is kind of hairy. Can we maybe have a protected member class that implements GeometryVisitor<Void> instead of doing this inline?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm thinking it might be cleaner to do something like this

    private void indexShape(ParseContext context, Object luceneShape) {
        if (luceneShape instanceof Geometry) {
            ((Geometry) luceneShape).visit(new LuceneGeometryIndexer(context));
        } else {
            throw new IllegalArgumentException("invalid shape type found [" + luceneShape.getClass() + "] while indexing shape");
        }
    }

...

protected class LuceneGeometryIndexer implements GeometryVisitor<Void> {
...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea. I don't think it needs to be protected though. We can make it private here.

Copy link
Contributor

@nknize nknize left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excellent! Thanks for the changes and good work. LGTM

Copy link
Contributor

@alpar-t alpar-t left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

build LGTM

@imotov imotov merged commit 68149b6 into elastic:master Jan 25, 2019
jasontedor added a commit to jasontedor/elasticsearch that referenced this pull request Jan 25, 2019
* elastic/master: (68 commits)
  Fix potential IllegalCapacityException in LLRC when selecting nodes (elastic#37821)
  Mute CcrRepositoryIT#testFollowerMappingIsUpdated
  Fix S3 Repository ITs When Docker is not Available (elastic#37878)
  Pass distribution type through to docs tests (elastic#37885)
  Mute SharedClusterSnapshotRestoreIT#testSnapshotCanceledOnRemovedShard
  SQL: Fix casting from date to numeric type to use millis (elastic#37869)
  Migrate o.e.i.r.RecoveryState to Writeable (elastic#37380)
  ML: removing unnecessary upgrade code (elastic#37879)
  Relax cluster metadata version check (elastic#37834)
  Mute TransformIntegrationTests#testSearchTransform
  Refactored GeoHashGrid unit tests (elastic#37832)
  Fixes for a few randomized agg tests that fail hasValue() checks
  Geo: replace intermediate geo objects with libs/geo (elastic#37721)
  Remove NOREPLACE for /etc/elasticsearch in rpm and deb (elastic#37839)
  Remove "reinstall" packaging tests (elastic#37851)
  Add unit tests for ShardStateAction's ShardStartedClusterStateTaskExecutor (elastic#37756)
  Exit batch files explictly using ERRORLEVEL (elastic#29583)
  TransportUnfollowAction should increase settings version (elastic#37859)
  AsyncTwoPhaseIndexerTests race condition fixed (elastic#37830)
  Do not allow negative variances (elastic#37384)
  ...
@imotov imotov deleted the switch-to-libsgeo-object branch May 1, 2020 22:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Analytics/Geo Indexing, search aggregations of geo points and shapes >refactoring v7.0.0-beta1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants