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

Add geohex_grid aggregation #160

Merged

Conversation

VijayanB
Copy link
Member

@VijayanB VijayanB commented Oct 7, 2022

Description

This aggregation will use uber's h3 to group coordinates into H3 cell.
Created new aggregation type geohex_grid. The precision will be between 0 and 15. This aggreation has default precision as 5, similar to geohash and geotile.

Signed-off-by: Vijayan Balasubramanian [email protected]

Check List

  • Commits are signed per the DCO using --signoff

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

@VijayanB VijayanB requested a review from a team October 7, 2022 05:56
@VijayanB VijayanB self-assigned this Oct 7, 2022
@VijayanB VijayanB marked this pull request as draft October 7, 2022 05:57
@VijayanB VijayanB force-pushed the add-aggregation branch 5 times, most recently from af06606 to b0b350a Compare October 11, 2022 22:56
@VijayanB VijayanB marked this pull request as ready for review October 11, 2022 22:59
Copy link
Collaborator

@navneet1v navneet1v left a comment

Choose a reason for hiding this comment

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

I am not seeing IT tests for the new aggregation?

Copy link
Collaborator

@navneet1v navneet1v left a comment

Choose a reason for hiding this comment

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

[Nit-pick] Overall comment on the code:

  1. Can we consistent in use of var and classes while creating the local variables.
  2. Please move all the public functions at the start of the class followed by protected and then private function. This improves reading and reviewing of the code.
  3. Please be consistent in use of final key word. I would recommend to use final keyword in local variables and functions parameters. This aids that the variable reference will not be changed.

@VijayanB VijayanB force-pushed the add-aggregation branch 3 times, most recently from a94c396 to c4daf9e Compare October 12, 2022 05:51
@VijayanB VijayanB force-pushed the add-aggregation branch 3 times, most recently from 00547d7 to 7228275 Compare October 17, 2022 22:40
import org.opensearch.search.aggregations.ParsedMultiBucketAggregation;
import org.opensearch.test.InternalMultiBucketAggregationTestCase;

// This class is modified from https://github.com/opensearch-project/OpenSearch/blob/main/modules/geo/src/test/java/org/opensearch/geo/search/aggregations/bucket/geogrid/GeoGridTestCase.java
Copy link
Member

Choose a reason for hiding this comment

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

nit: I think we normally use block style comments for class:

/**
 * Class description
 */

Copy link
Member Author

Choose a reason for hiding this comment

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

Ack

JsonXContent.jsonXContent,
String.format(
Locale.getDefault(),
"{\"field\":\"my_loc\", \"precision\":\"%d\", \"size\": \"500\", \"shard_size\": \"550\"}",
Copy link
Member

Choose a reason for hiding this comment

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

looks like it's the same string we're using in multiple places, WDYT of making it a constant?

Copy link
Member Author

Choose a reason for hiding this comment

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

I refactored to a method in some places.

import org.opensearch.search.aggregations.bucket.terms.TermsAggregationBuilder;

// This class is modified from https://github.com/opensearch-project/OpenSearch/blob/main/modules/geo/src/test/java/org/opensearch/geo/search/aggregations/bucket/geogrid/GeoGridAggregatorTestCase.java
// to keep relevant test case required for GeoHex Grid Aggregation.
Copy link
Member

Choose a reason for hiding this comment

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

same as for other class, I think we use block comments for classes

Copy link
Member Author

Choose a reason for hiding this comment

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

Ack

/**
* Helper class for H3 library
*/
public class GeoHexHelper {
Copy link
Member

Choose a reason for hiding this comment

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

just want to make sure that in this repo we're using Helper class suffix. I think in k-NN it's usually Util, but I finer with either one as long as we're consistent

Copy link
Member Author

Choose a reason for hiding this comment

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

Right. We are calling it a helper than a utility everywhere.

This aggregation will use uber's h3 to group coordinates into H3 cell.
Created new aggregation type geohex_grid. The precision will be between
0 and 15. This aggreation has default precision as 5,
similar to geohash and geotile.

Signed-off-by: Vijayan Balasubramanian <[email protected]>
@VijayanB VijayanB merged commit 22285e3 into opensearch-project:feature/h3-grid Oct 18, 2022
VijayanB added a commit that referenced this pull request Oct 24, 2022
* Import h3 library (#154)

Made following changes to make it compatible:
1. Rename package from elasticsearch to opensearch.geospatial
2. Update License headers
3. Update build file
4. Update settings to include sub projects

* Use Transport Request (#164)

Remove usage of deprecated BaseNodeRequest

* Update http client package to resolve build failure (#168) (#171)

* Introduce H3 min resolution constant (#165)

H3 version 1 has 16 resolutions, numbered 0 through 15.
Introduced a constant to represent min value, similar
to max value.

* Add geohex aggregation (#160)

This aggregation will use uber's h3 to group coordinates into H3 cell.
Created new aggregation type geohex_grid. The precision will be between
0 and 15. This aggreation has default precision as 5,
similar to geohash and geotile.

Signed-off-by: Vijayan Balasubramanian <[email protected]>

* Add integration test (#176)

Included integration test for geohex_grid.

Signed-off-by: Vijayan Balasubramanian <[email protected]>
VijayanB added a commit to VijayanB/geospatial that referenced this pull request Oct 26, 2022
…ch-project#179)

* Import h3 library (opensearch-project#154)

Made following changes to make it compatible:
1. Rename package from elasticsearch to opensearch.geospatial
2. Update License headers
3. Update build file
4. Update settings to include sub projects

* Use Transport Request (opensearch-project#164)

Remove usage of deprecated BaseNodeRequest

* Update http client package to resolve build failure (opensearch-project#168) (opensearch-project#171)

* Introduce H3 min resolution constant (opensearch-project#165)

H3 version 1 has 16 resolutions, numbered 0 through 15.
Introduced a constant to represent min value, similar
to max value.

* Add geohex aggregation (opensearch-project#160)

This aggregation will use uber's h3 to group coordinates into H3 cell.
Created new aggregation type geohex_grid. The precision will be between
0 and 15. This aggreation has default precision as 5,
similar to geohash and geotile.

Signed-off-by: Vijayan Balasubramanian <[email protected]>

* Add integration test (opensearch-project#176)

Included integration test for geohex_grid.

Signed-off-by: Vijayan Balasubramanian <[email protected]>
VijayanB added a commit that referenced this pull request Oct 26, 2022
)

* Import h3 library (#154)

Made following changes to make it compatible:
1. Rename package from elasticsearch to opensearch.geospatial
2. Update License headers
3. Update build file
4. Update settings to include sub projects

* Use Transport Request (#164)

Remove usage of deprecated BaseNodeRequest

* Update http client package to resolve build failure (#168) (#171)

* Introduce H3 min resolution constant (#165)

H3 version 1 has 16 resolutions, numbered 0 through 15.
Introduced a constant to represent min value, similar
to max value.

* Add geohex aggregation (#160)

This aggregation will use uber's h3 to group coordinates into H3 cell.
Created new aggregation type geohex_grid. The precision will be between
0 and 15. This aggreation has default precision as 5,
similar to geohash and geotile.

Signed-off-by: Vijayan Balasubramanian <[email protected]>

* Add integration test (#176)

Included integration test for geohex_grid.

Signed-off-by: Vijayan Balasubramanian <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants