-
Notifications
You must be signed in to change notification settings - Fork 24.9k
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
Conversation
- 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
Pinging @elastic/es-analytics-geo |
There was a problem hiding this 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.
server/src/main/java/org/elasticsearch/common/geo/EdgeTreeReader.java
Outdated
Show resolved
Hide resolved
server/src/main/java/org/elasticsearch/common/geo/EdgeTreeReader.java
Outdated
Show resolved
Hide resolved
server/src/main/java/org/elasticsearch/common/geo/EdgeTreeReader.java
Outdated
Show resolved
Hide resolved
|
||
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)); |
There was a problem hiding this comment.
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.
There was a problem hiding this 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 { |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
++ will follow-up
- 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
track, this fixes that by introducing a new Extent
object
input is made once
geo_bounds
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.