Skip to content

Conversation

@nknize
Copy link
Contributor

@nknize nknize commented Nov 19, 2018

This PR adds support for building lucene geometry from the ShapeBuilders. This is PR 1 of 2 for for integrating LatLonShape as the primary indexing approach for geo_shape field types. All unit and integration tests are updated to add randomization for testing both lucene shapes and jts/s4j shapes for bwc.

relates #35320

@nknize nknize added :Analytics/Geo Indexing, search aggregations of geo points and shapes v7.0.0 v6.6.0 labels Nov 19, 2018
@nknize nknize requested review from cbuescher and imotov November 19, 2018 18:47
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-search-aggs

@nknize
Copy link
Contributor Author

nknize commented Nov 19, 2018

/cc @jpountz @iverase @talevy if anyone wants to jump in and review. Trying to make the review process for #35320 easier

This commit adds support for building lucene geometry from the ShapeBuilders. This is needed for integrating LatLonShape as the primary indexing approach for geo_shape field types. All unit and integration tests are updated to add randomization for testing both jts/s4j shapes and lucene shapes.
@nknize nknize force-pushed the bkdBackedShapes-ShapeBuilders branch from 8ba0cfb to ab3f2fe Compare November 19, 2018 19:50
Copy link
Contributor

@jpountz jpountz left a comment

Choose a reason for hiding this comment

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

Let's fix tests to test both the JTS and Lucene shape on every test run rather than randomly testing one of them?

public abstract T build();
public abstract T buildS4J();

public abstract Object buildLucene();
Copy link
Contributor

Choose a reason for hiding this comment

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

If I understand it correctly, this is the future way of building shapes. So, would it make sense to call this method simply build()?

Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe in the future we want to add a new topology library, e.g. spatial3d, so I think it is better to name the method with a reference to the underlaying library.

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 think if we eventually end up supporting spatial3d or other packages then a more sophisticated factory pattern would be appropriate. But I chose this simple naming approach because its going to be removed / deleted in 7.0. So I didn't want to get too extravagant

}

@Override
public Object buildLucene() {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think having this return type as a parameter type would have helped me to understand the builder better.

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 think if these factory methods were hanging around longer we could/should go that way, but buildS4J is being removed in 7.0, so I was trying to keep it simple / straight-forward for removal.

I think we could go this route if/when we add something like spatial3d in the future.

@nknize
Copy link
Contributor Author

nknize commented Nov 20, 2018

Okay.. I think all comments have been addressed in the first round review. I removed the useJTS randomized testing and set it up to explicitly test both S4J and Lucene builders. I think that's a good approach; and the s4j explicit testing will be removed in 7.0.

Copy link
Contributor

@jpountz jpountz left a comment

Choose a reason for hiding this comment

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

Left some minor comments, otherwise LGTM

if (lon > 180d || lon <= -180d) {
return centeredModulus(lon, 360);
}
return lon + 0d;
Copy link
Contributor

Choose a reason for hiding this comment

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

can you add a comment that this aims at avoiding negative zeros? Also it's not obvious to me that centerModulus may never return negative zero should we do the same? Also we do we want to avoid negative zeros?

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 think it would be good to avoid negative 0. We can look at adding that to the parser in a separate PR? For now I'll add the comment and cleanup so that if centerModulus does return -0.0 its handled appropriately

@nknize
Copy link
Contributor Author

nknize commented Nov 20, 2018

Made changes... will keep an eye on ci tests and merge when they go green

for (ShapeBuilder shape : this.shapes) {
Object o = shape.buildLucene();
if (o.getClass().isArray()) {
shapes.addAll(Arrays.asList((Object[])o));
Copy link
Contributor

Choose a reason for hiding this comment

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

Would this work for a collection of points?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It does.. Arrays.asList on a double[][] multipoint type correctly adds two double[] points to the list as expected

@nknize nknize merged commit 3bee25c into elastic:master Nov 21, 2018
nknize added a commit that referenced this pull request Dec 17, 2018
This commit adds support for building lucene geometry from the ShapeBuilders. This is needed for integrating LatLonShape as the primary indexing approach for geo_shape field types. All unit and integration tests are updated to add randomization for testing both jts/s4j shapes and lucene shapes.
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 >enhancement v6.6.0 v7.0.0-beta1

7 participants