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

[CI/CD] Test failure in GeoHashGridIT#testMultivaluedGeoPointsAggregation #7101

Closed
nknize opened this issue Apr 11, 2023 · 6 comments
Closed
Assignees
Labels
bug Something isn't working Geospatial v3.0.0 Issues and PRs related to version 3.0.0

Comments

@nknize
Copy link
Collaborator

nknize commented Apr 11, 2023

Describe the bug
Caught on PR #7094 GeoHashGridIT#testMultivaluedGeoPointsAggregation reproducibly fails.

To Reproduce
Steps to reproduce the behavior:

./gradlew ':modules:geo:internalClusterTest' --tests "org.opensearch.geo.search.aggregations.bucket.GeoTileGridIT.testMultivaluedGeoPointsAggregation" -Dtests.seed=73A6EB980B2F13B4 -Dtests.security.manager=true -Dtests.jvm.argline="-XX:TieredStopAtLevel=1 -XX:ReservedCodeCacheSize=64m" -Dtests.locale=is -Dtests.timezone=Africa/Addis_Ababa -Druntime.java=19

Expected behavior
Passing test

@nknize nknize added bug Something isn't working untriaged Geospatial v3.0.0 Issues and PRs related to version 3.0.0 labels Apr 11, 2023
@nknize nknize changed the title [CI/CD] Test failure in [CI/CD] Test failure in GeoHashGridIT#testMultivaluedGeoPointsAggregation Apr 11, 2023
@nknize
Copy link
Collaborator Author

nknize commented Apr 11, 2023

/cc @navneet1v

@navneet1v
Copy link
Contributor

@nknize will look into this. This is really interesting to see GeoPoints Aggregation Tests getting failed. Will see if there were some changes in the tests that lead to this failure. because these tests are written when OS got forked from ES.

@navneet1v
Copy link
Contributor

navneet1v commented Apr 14, 2023

@nknize I found out the issue and will be raising the PR soon. The issue was happening mainly because of the way we encode the GeoPoint and error that comes in the precision due to that encoding. The error was happening for a tile: 13/1627/7465

The idea to fix this is simple enough, while generating the expected buckets for geo-points I will encode and decode the lat-lon values. This will make sure that the precision loss comes in during the Tile creation, as showed in the below snippet.

I just have 1 question, should I do this for GeoHex also? I think I should, but need your input here.

Code ref:

protected Set<String> generateBucketsForGeoPoint(final GeoPoint geoPoint) {
Set<String> buckets = new HashSet<>();
for (int precision = GEOPOINT_MAX_PRECISION; precision > 0; precision--) {
final String tile = GeoTileUtils.stringEncode(geoPoint.getLon(), geoPoint.getLat(), precision);
buckets.add(tile);
}
return buckets;

protected Set<String> generateBucketsForGeoPoint(final GeoPoint geoPoint) {
        Set<String> buckets = new HashSet<>();
        for (int precision = GEOPOINT_MAX_PRECISION; precision > 0; precision--) {
            final String tile =
                    GeoTileUtils.stringEncode(GeoEncodingUtils.decodeLongitude(GeoEncodingUtils.encodeLongitude(geoPoint.getLon())), GeoEncodingUtils.decodeLatitude(GeoEncodingUtils.encodeLatitude(geoPoint.getLat())), precision);
            buckets.add(tile);
        }
        return buckets;
    }

@navneet1v
Copy link
Contributor

navneet1v commented Apr 14, 2023

@nknize

I just have 1 question, should I do this for GeoHex also? I think I should, but need your input here.

On doing some more deep-dive what I can see is this encoding of geo points to long values is already happening as part of creating Geohash for a geo-point. Hence the issue will not happen for Geohash buckets and not required for GeoHashAggregationIT.

Code reference:

long interleaved = encodeLatLon(lat, lon);

private static long encodeLatLon(final double lat, final double lon) {
// encode lat/lon flipping the sign bit so negative ints sort before positive ints
final int latEnc = encodeLatitude(lat) ^ 0x80000000;
final int lonEnc = encodeLongitude(lon) ^ 0x80000000;
return BitUtil.interleave(latEnc, lonEnc) >>> 2;
}

public static int encodeLatitude(double latitude) {
// the maximum possible value cannot be encoded without overflow
if (latitude == 90.0D) {
latitude = Math.nextDown(latitude);
}
return (int) Math.floor(latitude / LAT_DECODE);

Encoding of geo-points in lucene just before storing the points:
https://github.com/apache/lucene/blob/main/lucene/core/src/java/org/apache/lucene/geo/GeoEncodingUtils.java#L58-L64

navneet1v added a commit to navneet1v/OpenSearch that referenced this issue Apr 14, 2023
…tsAggregation test case.

The issue was happening because we encode the GeoPoint as long and error comes in the precision due to that encoding. The error was not taken care while generating the exepected tiles count for execpected output.

Signed-off-by: Navneet Verma <[email protected]>
@navneet1v
Copy link
Contributor

PR for the fix: #7166

@nknize

navneet1v added a commit to navneet1v/OpenSearch that referenced this issue Apr 17, 2023
…tsAggregation test case.

The issue was happening because we encode the GeoPoint as long and error comes in the precision due to that encoding. The error was not taken care while generating the exepected tiles count for execpected output.

Signed-off-by: Navneet Verma <[email protected]>
navneet1v added a commit to navneet1v/OpenSearch that referenced this issue Apr 17, 2023
…tsAggregation test case.

The issue was happening because we encode the GeoPoint as long and error comes in the precision due to that encoding. The error was not taken care while generating the exepected tiles count for execpected output.

Signed-off-by: Navneet Verma <[email protected]>
navneet1v added a commit to navneet1v/OpenSearch that referenced this issue Apr 17, 2023
…tsAggregation test case.

The issue was happening because we encode the GeoPoint as long and error comes in the precision due to that encoding. The error was not taken care while generating the exepected tiles count for execpected output.

Signed-off-by: Navneet Verma <[email protected]>
nknize pushed a commit that referenced this issue Apr 17, 2023
… case. (#7166)

The issue was happening because we encode the GeoPoint as long and error comes in the precision due to that encoding. The error was not taken care while generating the exepected tiles count for execpected output.

Signed-off-by: Navneet Verma <[email protected]>
@navneet1v
Copy link
Contributor

PR is merged. Resolving the issue.

austintlee pushed a commit to austintlee/OpenSearch that referenced this issue Apr 28, 2023
…tsAggregation test case. (opensearch-project#7166)

The issue was happening because we encode the GeoPoint as long and error comes in the precision due to that encoding. The error was not taken care while generating the exepected tiles count for execpected output.

Signed-off-by: Navneet Verma <[email protected]>
heemin32 pushed a commit to heemin32/OpenSearch that referenced this issue Jun 27, 2023
…tsAggregation test case. (opensearch-project#7166)

The issue was happening because we encode the GeoPoint as long and error comes in the precision due to that encoding. The error was not taken care while generating the exepected tiles count for execpected output.

Signed-off-by: Navneet Verma <[email protected]>
heemin32 pushed a commit to heemin32/OpenSearch that referenced this issue Jun 28, 2023
…tsAggregation test case. (opensearch-project#7166)

The issue was happening because we encode the GeoPoint as long and error comes in the precision due to that encoding. The error was not taken care while generating the exepected tiles count for execpected output.

Signed-off-by: Navneet Verma <[email protected]>
andrross pushed a commit that referenced this issue Jun 30, 2023
* Add GeoTile and GeoHash Grid aggregations on GeoShapes. (#5589)

Src files for GeoTile and GeoHash Aggregations on GeoShape with integration
tests.

Signed-off-by: Navneet Verma <[email protected]>

* [opensearch-project/geospatial#212] Fixing the IT for GeoTilesAggrega… (#6120)

Fixing the IT for GeoTilesAggregation.

Signed-off-by: Navneet Verma <[email protected]>

* [#6187, #6222] Fixing the GeoShapes GeoHash and GeoTile Aggregations Integration tests. (#6242)

Changes done:
* Fixed the ArrayIndexOutOfBoundsException.
* Reduced the precision for GeoShapes Aggregation IT testing.

Signed-off-by: Navneet Verma <[email protected]>

* [#7101] Fixing the GeoTileIT#testMultivaluedGeoPointsAggregation test case. (#7166)

The issue was happening because we encode the GeoPoint as long and error comes in the precision due to that encoding. The error was not taken care while generating the exepected tiles count for execpected output.

Signed-off-by: Navneet Verma <[email protected]>

---------

Signed-off-by: Navneet Verma <[email protected]>
Signed-off-by: Heemin Kim <[email protected]>
Co-authored-by: Navneet Verma <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Geospatial v3.0.0 Issues and PRs related to version 3.0.0
Projects
None yet
Development

No branches or pull requests

2 participants