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

Clean up Extent logic in Geo Tree readers #42968

Merged
merged 6 commits into from
Jun 10, 2019

Conversation

talevy
Copy link
Contributor

@talevy talevy commented Jun 6, 2019

  • min and max values of coordinates were difficult to
    track, this fixes that by introducing a new Extent
    object
  • Instead of re-wrapping ByteRef into a StreamInput, a stream
    input is made once
  • a new getExtent() method is introduced for use by aggregations like
    geo_bounds
  • re-use bounding-box containment checks

Extent object may come in handy for actual logic in the future. if/when the time comes, it
would make sense to up-lift the class into its own file.

- min and max values of coordinates were difficult to
  track, this fixes that by introducing a new Extent
  object
- Instead of re-wrapping ByteRef into a StreamInput, a stream
  input is made once
- a new getExtent() method is introduced for use by aggregations like
  geo_bounds
- re-use bounding-box containment checks
@talevy talevy added the :Analytics/Geo Indexing, search aggregations of geo points and shapes label Jun 6, 2019
@talevy talevy requested a review from imotov June 6, 2019 20:55
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-analytics-geo

Copy link
Contributor

@imotov imotov left a comment

Choose a reason for hiding this comment

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

I think we are moving in the right direction here, but I would like to iterate a bit more on this PR to make sure we indeed can switch to StreamInput in a reasonable manner.


public EdgeTreeReader(StreamInput input) throws IOException {
int treeBytesSize = input.readVInt();
this.bytesRef = input.readBytesRef(treeBytesSize);
this.input = new ByteBufferStreamInput(ByteBuffer.wrap(bytesRef.bytes, bytesRef.offset, bytesRef.length));
Copy link
Contributor

Choose a reason for hiding this comment

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

Now that you merged #42910 that just doesn't look right. Perhaps we can brainstorm a bit on how to improve that.

Copy link
Contributor

@imotov imotov left a comment

Choose a reason for hiding this comment

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

I think this might be a good stopping point for this iteration. I would still love to get rid of dependency on ByteBufferStreamInput eventually, but we can deal with it in future iterations.

public boolean containedInOrCrosses(int minLon, int minLat, int maxLon, int maxLat) throws IOException {
ByteBufferStreamInput input = new ByteBufferStreamInput(
ByteBuffer.wrap(bytesRef.bytes, bytesRef.offset, bytesRef.length));
public Extent getExtent() throws IOException {
Copy link
Contributor

Choose a reason for hiding this comment

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

This method is no longer needed, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

so, this method is to be used by aggregations like geo_bounds in the future, so I figured I would throw it in here while I'm at it. happy to remove and only add when used

Copy link
Contributor

Choose a reason for hiding this comment

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

In this case we should probably add a test for it and replace reading individual components with invoking `Extent(StreamInput).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

++ will follow-up

@talevy talevy merged commit 92b24c3 into elastic:geoshape-doc-values Jun 10, 2019
@talevy talevy deleted the extent-cleanup branch June 10, 2019 21:05
talevy added a commit that referenced this pull request Sep 20, 2019
- min and max values of coordinates were difficult to
  track, this fixes that by introducing a new Extent
  object
- Instead of re-wrapping ByteRef into a StreamInput, a stream
  input is made once
- a new getExtent() method is introduced for use by aggregations like
  geo_bounds
- re-use bounding-box containment checks
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants