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

Refactor common parts from the Rounding class into a separate 'round' package #11023

Merged
merged 6 commits into from
Nov 15, 2023

Conversation

ketanv3
Copy link
Contributor

@ketanv3 ketanv3 commented Oct 31, 2023

Description

The Rounding class (permalink) is a 1.5K SLOC monolith which is closely tied to rounding down timestamp values. This PR aims to simplify this class by:

  • Decoupling generic rounding classes (i.e., the ones not related to rounding of timestamp values) into a separate common package.
  • Creating the common package under the :libs:opensearch-common module as it's no longer tied to the :server module.

Related Issues

This is a prerequisite for #10392 which requires parts of the Rounding class to be overridden with SIMD features on supported JDKs. Since Multi-Release JAR replaces the entire class file (no way to replace just the inner classes), it creates too much code duplication. Splitting the Rounding class into smaller pieces and overriding them is much better.

relates #5910 - refactor to support modularity
relates #8110 - JPMS meta issue

Check List

  • New functionality includes testing.
    • All tests pass
  • New functionality has been documented.
    • New functionality has javadoc added
  • Failing checks are inspected and point to the corresponding known issue(s) (See: Troubleshooting Failing Builds)
  • Commits are signed per the DCO using --signoff
  • Commit changes are listed out in CHANGELOG.md file (See: Changelog)
  • Public documentation issue/PR created

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.

@github-actions
Copy link
Contributor

github-actions bot commented Oct 31, 2023

Compatibility status:

Checks if related components are compatible with change 370cdad

Incompatible components

Incompatible components: [https:/opensearch-project/performance-analyzer.git]

Skipped components

Compatible components

Compatible components: [https:/opensearch-project/geospatial.git, https:/opensearch-project/security-analytics.git, https:/opensearch-project/observability.git, https:/opensearch-project/notifications.git, https:/opensearch-project/job-scheduler.git, https:/opensearch-project/neural-search.git, https:/opensearch-project/custom-codecs.git, https:/opensearch-project/asynchronous-search.git, https:/opensearch-project/opensearch-oci-object-storage.git, https:/opensearch-project/reporting.git, https:/opensearch-project/ml-commons.git, https:/opensearch-project/index-management.git, https:/opensearch-project/common-utils.git, https:/opensearch-project/cross-cluster-replication.git, https:/opensearch-project/anomaly-detection.git, https:/opensearch-project/sql.git, https:/opensearch-project/alerting.git, https:/opensearch-project/security.git, https:/opensearch-project/k-nn.git, https:/opensearch-project/performance-analyzer-rca.git]

@github-actions
Copy link
Contributor

Gradle Check (Jenkins) Run Completed with:

Copy link
Contributor

github-actions bot commented Nov 1, 2023

Gradle Check (Jenkins) Run Completed with:

Copy link
Contributor

@kkmr kkmr left a comment

Choose a reason for hiding this comment

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

My memory of this is that if number of elements is < 64, we use LinearSearch, if number of elements < 128, we use BinarySearch. Is that not accurate? I think I added a comment to that effect in the previous PR.

@ketanv3
Copy link
Contributor Author

ketanv3 commented Nov 3, 2023

My memory of this is that if number of elements is < 64, we use LinearSearch, if number of elements < 128, we use BinarySearch. Is that not accurate? I think I added a comment to that effect in the previous PR.

@kkmr Yes, that still holds true for the date_histogram aggregation.

This PR refactors out the common parts that aren't related to timestamps or aggregations. It simply provides the fastest implementation of Roundable for any input size. The responsibility of using array-based prepared rounding if the size is <= 128 is kept with the caller (here).

@ketanv3
Copy link
Contributor Author

ketanv3 commented Nov 7, 2023

@nknize @reta Are we good to merge this PR?

@ketanv3
Copy link
Contributor Author

ketanv3 commented Nov 9, 2023

Ping @nknize

Copy link
Contributor

✅ Gradle check result for 370cdad: SUCCESS

@ketanv3
Copy link
Contributor Author

ketanv3 commented Nov 15, 2023

@andrross Are we all set to merge this PR? I have another draft PR (#11194) that hinges upon these changes.

@andrross andrross dismissed nknize’s stale review November 15, 2023 21:58

Nick's comment has been addressed

@andrross andrross added the backport 2.x Backport to 2.x branch label Nov 15, 2023
@andrross andrross merged commit 08db961 into opensearch-project:main Nov 15, 2023
41 checks passed
@opensearch-trigger-bot
Copy link
Contributor

The backport to 2.x failed:

The process '/usr/bin/git' failed with exit code 128

To backport manually, run these commands in your terminal:

# Navigate to the root of your repository
cd $(git rev-parse --show-toplevel)
# Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add ../.worktrees/OpenSearch/backport-2.x 2.x
# Navigate to the new working tree
pushd ../.worktrees/OpenSearch/backport-2.x
# Create a new branch
git switch --create backport/backport-11023-to-2.x
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 08db961e1914d93ce9d81e6da84e6e232b8d37e2
# Push it to GitHub
git push --set-upstream origin backport/backport-11023-to-2.x
# Go back to the original working tree
popd
# Delete the working tree
git worktree remove ../.worktrees/OpenSearch/backport-2.x

Then, create a pull request where the base branch is 2.x and the compare/head branch is backport/backport-11023-to-2.x.

ketanv3 added a commit to ketanv3/OpenSearch that referenced this pull request Nov 15, 2023
…eparate 'round' package (opensearch-project#11023)

(cherry picked from commit 08db961)

Signed-off-by: Ketan Verma <[email protected]>
ketanv3 added a commit to ketanv3/OpenSearch that referenced this pull request Nov 15, 2023
…eparate 'round' package (opensearch-project#11023)

(cherry picked from commit 08db961)

Signed-off-by: Ketan Verma <[email protected]>
reta pushed a commit that referenced this pull request Nov 16, 2023
…eparate 'round' package (#11023) (#11223)

(cherry picked from commit 08db961)

Signed-off-by: Ketan Verma <[email protected]>
fahadshamiinsta pushed a commit to fahadshamiinsta/OpenSearch270 that referenced this pull request Dec 4, 2023
… package (opensearch-project#11023)

* Refactor common parts from the Rounding class into a separate 'round' package

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

* Move RoundableTests from :server to :libs:opensearch-common module

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

* Address PR comments

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

* Replace assert with IllegalArgumentException for size checks

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

---------

Signed-off-by: Ketan Verma <[email protected]>
rayshrey pushed a commit to rayshrey/OpenSearch that referenced this pull request Mar 18, 2024
… package (opensearch-project#11023)

* Refactor common parts from the Rounding class into a separate 'round' package

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

* Move RoundableTests from :server to :libs:opensearch-common module

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

* Address PR comments

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

* Replace assert with IllegalArgumentException for size checks

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

---------

Signed-off-by: Ketan Verma <[email protected]>
shiv0408 pushed a commit to Gaurav614/OpenSearch that referenced this pull request Apr 25, 2024
… package (opensearch-project#11023)

* Refactor common parts from the Rounding class into a separate 'round' package

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

* Move RoundableTests from :server to :libs:opensearch-common module

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

* Address PR comments

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

* Replace assert with IllegalArgumentException for size checks

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

---------

Signed-off-by: Ketan Verma <[email protected]>
Signed-off-by: Shivansh Arora <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport 2.x Backport to 2.x branch backport-failed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants