-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
LUCENE-8746: Refactor EdgeTree #878
Conversation
I checked out the PR and got the following test failures:
|
@nknize totally right, some bug I introduce when trying to improve it. Now it should be fixed. |
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.
Gave it a first go and have a few thoughts / suggestions...
} | ||
}; | ||
} | ||
|
||
@Override | ||
public Weight createWeight(IndexSearcher searcher, ScoreMode scoreMode, float boost) throws IOException { | ||
|
||
final Component2D tree = Polygon2D.create(polygons); |
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.
Can we push these variables into getIntersectVisitor
? That would delay creating the bounding box, Component2D
, and PolygonPredicate
objects until the visitor is needed and save unnecessary computation when no docs contain point fields.
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.
See above suggestion: I think it makes the code here a bit cleaner?
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.
Not sure if we should do that. I think we create one ScorerSupplier per segment so moving that logic to the IntersectVisitor means that we will creating this objects per segment.
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.
👍 Thanks for reminding me. I ran into that same problem ages ago as well.
@@ -84,7 +84,7 @@ public void visit(QueryVisitor visitor) { | |||
} | |||
} | |||
|
|||
private IntersectVisitor getIntersectVisitor(DocIdSetBuilder result, Polygon2D tree, GeoEncodingUtils.PolygonPredicate polygonPredicate, | |||
private IntersectVisitor getIntersectVisitor(DocIdSetBuilder result, Component2D tree, GeoEncodingUtils.PolygonPredicate polygonPredicate, |
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.
private IntersectVisitor getIntersectVisitor(DocIdSetBuilder result, Component2D tree, GeoEncodingUtils.PolygonPredicate polygonPredicate, | |
private IntersectVisitor getIntersectVisitor(DocIdSetBuilder result) { |
@@ -84,7 +84,7 @@ public void visit(QueryVisitor visitor) { | |||
} | |||
} | |||
|
|||
private IntersectVisitor getIntersectVisitor(DocIdSetBuilder result, Polygon2D tree, GeoEncodingUtils.PolygonPredicate polygonPredicate, | |||
private IntersectVisitor getIntersectVisitor(DocIdSetBuilder result, Component2D tree, GeoEncodingUtils.PolygonPredicate polygonPredicate, | |||
byte[] minLat, byte[] maxLat, byte[] minLon, byte[] maxLon) { |
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.
byte[] minLat, byte[] maxLat, byte[] minLon, byte[] maxLon) { | |
final Component2D tree = Polygon2D.create(polygons); | |
final GeoEncodingUtils.PolygonPredicate polygonPredicate = GeoEncodingUtils.createComponentPredicate(tree); | |
// bounding box over all polygons, this can speed up tree intersection/cheaply improve approximation for complex multi-polygons | |
final byte minLat[] = new byte[Integer.BYTES]; | |
final byte maxLat[] = new byte[Integer.BYTES]; | |
final byte minLon[] = new byte[Integer.BYTES]; | |
final byte maxLon[] = new byte[Integer.BYTES]; | |
NumericUtils.intToSortableBytes(encodeLatitude(tree.getMinY()), minLat, 0); | |
NumericUtils.intToSortableBytes(encodeLatitude(tree.getMaxY()), maxLat, 0); | |
NumericUtils.intToSortableBytes(encodeLongitude(tree.getMinX()), minLon, 0); | |
NumericUtils.intToSortableBytes(encodeLongitude(tree.getMaxX()), maxLon, 0); |
@nkine do you think we can move this forward? |
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.
LGTM. Thank you @iverase
Introduce a Component tree that represents the tree of components (e.g polygons). Edge tree is now just a tree of edges.
Another try in refactoring edge tree. This PR splits Edge Tree class into two and adds a new interface:
Unfortunately the PR touches quite a lots of files but most of them are test files. Running benchmark for points results look good, points shows same performance and there is an increase of performance for shapes (we are not computing the bounding box of the triangle many times).