-
Notifications
You must be signed in to change notification settings - Fork 985
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
Fix a bug in ShapeTestUtil #12287
Fix a bug in ShapeTestUtil #12287
Conversation
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.
Nice find! I wonder if we could put a test in place that would have reliably detected this issue.
This is a code for test actually. If we are writing a test using this method, we will detect the issue and that is how I found it. |
I should have been clearer. I'm assuming the existing tests that call |
Got your point. Actually, I am using this utility methods in other dependency repos, OpenSearch. There, the test fails without this fix. Let me see if I can add a test using this utility method in lucene. |
The test could call the modified methods with a random |
This PR has not had activity in the past 2 weeks, labeling it as stale. If the PR is waiting for review, notify the dev@lucene.apache.org list. Thank you for your contribution! |
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
There are existing tests which should fails. https://github.com/apache/lucene/blob/main/lucene/core/src/test/org/apache/lucene/document/TestShapeDocValues.java#L67 However because we are catching exception and try until we get the correct polygon, it never fails. I cannot remove the try-catch statement as of now because there are bug in I would like to wait until the other issues are resolved and remove the try-catch statement rather than writing a unit test for just the test utility code. |
That try-catch is intentional. The evil, esoteric / invalid test geometry generation is also intentional so we can maximize our test coverage across the tessellator and Shape indexing. This is why we have Tessellator logic to filter colinear and coplanar points so we can best effort index shapes that may not be well formed or may not have been pre-validated or cleaned. While we expect well formed data, that's not the real world. Users (especially geo users) often throw dirty data at the API. And to pre-validate geometries is an expensive operation. Not all users want to pay that price. This is why we left much of that diligence out of Lucene and in the hands of the integrating API. For example, see Elasticsearch |
However, the implementation between latlon and xy are different then. lucene/lucene/core/src/test/org/apache/lucene/document/TestShapeDocValues.java Lines 77 to 95 in 7b8aece
For latlon, it does not have try-catch statement wrapping |
A quick glance looks like the difference is from LUCENE-9192 where ShapeTestUtil#nextPolygon will only consider executing the try-catch path on Nightly runs. GeoTestUtil will consider it 10% of the time.. |
Yes. But what I meant is |
Doing that could create a polygon that can't be tessellated. |
But lucene/lucene/core/src/test/org/apache/lucene/document/TestShapeDocValues.java Lines 77 to 86 in 7b8aece
|
This PR has not had activity in the past 2 weeks, labeling it as stale. If the PR is waiting for review, notify the dev@lucene.apache.org list. Thank you for your contribution! |
Any update? |
Maybe we can merge this fix as-is and continue the conversation about where test polygon generation should produce valid polygons in #12596. It's not clear to me now if there is anything to fix in #12596, but I think we agree that the fix in this PR should go ahead. @heemin32 - do you want to write a CHANGES entry for Lucene 9.10? |
+1. Progress not perfection! |
6a0a2fa
to
ad1bcfe
Compare
boxPolygon and trianglePolygon only uses minX and minY value of give XY Rectangle which results in a polygon with points in single place. With this changes, both methods generate correct polygons.
ad1bcfe
to
c80955c
Compare
Added CHANGELOG entry |
Thank you for persevering @heemin32! |
boxPolygon and trianglePolygon only uses minX and minY value of give XY Rectangle which results in a polygon with points in single place. With this changes, both methods generate correct polygons.
Description
boxPolygon and trianglePolygon only uses minX and minY value of give XY Rectangle which results in a polygon with points in single place. With this changes, both methods generate correct polygons.