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

[Data] optimize dataset.unique() #49296

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

wingkitlee0
Copy link
Contributor

@wingkitlee0 wingkitlee0 commented Dec 17, 2024

Why are these changes needed?

The current implementation uses groupby(column).count() that causes a full sort. The new implementation uses AggregateFn which uses groupby(None) and set() to aggregate unique values.

The time complexity should be O(N / parallelism) according to ds.aggregate().

It's about 10x faster in my local test.

Some part of test_unique is removed because it was designed for the original implementation.

Related issue number

Closes #49298

Checks

  • I've signed off every commit(by using the -s flag, i.e., git commit -s) in this PR.
  • I've run scripts/format.sh to lint the changes in this PR.
  • I've included any doc changes needed for https://docs.ray.io/en/master/.
    • I've added any new APIs to the API Reference. For example, if I added a
      method in Tune, I've added it in doc/source/tune/api/ under the
      corresponding .rst file.
  • I've made sure the tests are passing. Note that there might be a few flaky tests, see the recent failures at https://flakey-tests.ray.io/
  • Testing Strategy
    • Unit tests
    • Release tests
    • This PR is not tested :(

@wingkitlee0 wingkitlee0 force-pushed the optimize-dataset-unique branch 2 times, most recently from f21dbeb to a2270a7 Compare December 17, 2024 03:42
@wingkitlee0 wingkitlee0 force-pushed the optimize-dataset-unique branch 4 times, most recently from 91c0e5a to 3802155 Compare December 19, 2024 03:09
@wingkitlee0 wingkitlee0 marked this pull request as ready for review December 19, 2024 03:10
@wingkitlee0 wingkitlee0 requested a review from a team as a code owner December 19, 2024 03:10
@wingkitlee0 wingkitlee0 force-pushed the optimize-dataset-unique branch from 2882ed5 to 5c5cc7f Compare December 19, 2024 03:47
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.

[Data] Use AggregateFn instead of groupby.count for unique()
2 participants