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: Makes coordinate validator in libs/geo plugable #43657

Merged
merged 1 commit into from
Jun 27, 2019

Conversation

imotov
Copy link
Contributor

@imotov imotov commented Jun 26, 2019

Moves coordinate validation from Geometry constructors into
parser.

Relates #43644

Moves coordinate validation from Geometry constructors into
parser.

Relates elastic#40908
@imotov imotov added :Analytics/Geo Indexing, search aggregations of geo points and shapes >refactoring v8.0.0 v7.3.0 labels Jun 26, 2019
@imotov imotov requested review from talevy and nknize June 26, 2019 18:31
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-analytics-geo

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.

I really like where this is going! Just left a couple questions that might be more applicable to consider for the future refactoring PRs.

* Validator that checks that lats are between -90 and +90 and lons are between -180 and +180 and altitude is present only if
* ignoreZValue is set to true
*/
public class GeographyValidator implements GeometryValidator {
Copy link
Contributor

Choose a reason for hiding this comment

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

I ran into this in #40869 Because we don't include lucene dependencies in our library plugins I had to copy much of Lucene's BitUtils and GeoHashUtils implementation. Here we're having to copy some of Lucene's GeoUtils functionality. Starting to get a little concerned w/ the code duplication and am curious as to whether or not it makes sense to start allowing lucene dependencies in our Libraries? Will this break the build configuration or just our library philosophy? /cc @rjernst @atorok

Copy link
Contributor Author

@imotov imotov Jun 26, 2019

Choose a reason for hiding this comment

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

If we want to reuse lucene pieces we would have to jump through a lot of hoops and probably move validation to server since we need libs/geo in SQL client and we really don't want SQL client to depend on Lucene. I don't think it is worth bringing lucene here because of 2 constants.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah. I'm not so concerned about the two constants here as I am about the growing duplication of code, like IOUtils, BitUtils, GeoHashUtils, and now GeoUtils. Perhaps the concern is premature, but I'm starting to see this become a bit of a trend. I just don't want to wake up one day and see that it got out of hand and future maintenance becomes a nightmare. It doesn't have to hold up this PR but I think it does warrant an async discussion.

Copy link
Member

Choose a reason for hiding this comment

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

Worst case, in a distant future if it gets out of hand, we could have a compile time shading/copying of relevant lucene classes, if we want to include these in our lib without adding an external jar dep. I agree with Igor we should not add deps to SQL client.

Copy link
Contributor

Choose a reason for hiding this comment

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

Awesome... thx @rjernst

Copy link
Contributor

Choose a reason for hiding this comment

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

Would it be conceivable to have something like lucene-utils produced upstream on which we could depend on ? That could be a long term solution too, would be the same as @rjernst suggested, but would allow us to add a clean dependency.

Copy link
Member

Choose a reason for hiding this comment

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

I don't think this would be likely, since from Lucene's perspective there is no reason for this extra dependency. Lucene doesn't want to be a general purpose utility library.


public WellKnownText(boolean coerce, boolean ignoreZValue) {
public WellKnownText(boolean coerce, GeometryValidator validator) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Should coerce also be part of the validator? Or are we trying to ensure the Validator treats incoming Geometry as "immutable"? It certainly makes the API cleaner, and XY geometry will coerce in a slightly different manner than LatLon geometry.

Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm... or maybe coerce is specific to the builders? And closeLinearRingIfCoerced is called there instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah here coerce is basically close linear ring if they are open. I am not really sure what to do with it to be honest. I kind of hope that we can deprecate that and remove it eventually. But I am ok with allowing validator to do coercing if needed but I am not totally sold that it belongs there to be honest.

Copy link
Contributor

Choose a reason for hiding this comment

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

Sounds good. I don't think it needs to hold up this PR by any means. Let's see where the full refactoring goes and the solution may become more clear down the line.

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.

I'd like to keep the dialogue open re: dependencies and the library plugins; but I don't think it needs to hold up this PR. Perhaps it can be added as a discussion topic at one of the area meetings (core-features?)

@imotov
Copy link
Contributor Author

imotov commented Jun 26, 2019

@nknize I think we have a solution for dependency - we just move such pieces to the server project. Hopefully, we will be able to keep libs/geo dependency free. I don't think we will need to add more logic there, since libs/geo is targeting the client side. However, I agree, if we find ourselves wanting to add some logic there, we need to revisit this question.

@imotov imotov removed the request for review from talevy June 27, 2019 13:59
@imotov imotov merged commit 8029b47 into elastic:master Jun 27, 2019
imotov added a commit that referenced this pull request Jun 28, 2019
Moves coordinate validation from Geometry constructors into
parser.

Relates #43644
@jpountz
Copy link
Contributor

jpountz commented Jul 5, 2019

@imotov Since seems to be on 7.3 already, is there anything more to backport?

@imotov
Copy link
Contributor Author

imotov commented Jul 5, 2019

@jpountz No. I just forgot to remove backport pending label. Thanks!

@imotov imotov deleted the remove-validator-from-libs-geo branch May 1, 2020 22:28
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.3.0 v8.0.0-alpha1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants