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(rust): Remove once_cell in favor of std equivalents #21639

Merged
merged 1 commit into from
Mar 7, 2025

Conversation

nameexhaustion
Copy link
Collaborator

@nameexhaustion nameexhaustion commented Mar 7, 2025

Removes once_cell as a direct dependency, as the functions have been added and stabilized in std. Note that the names will differ:

once_cell (before) std (after)
once_cell::sync::Lazy std::sync::LazyLock
once_cell::sync::OnceCell std::sync::OnceLock

*edit, drafted on second thought

@github-actions github-actions bot added internal An internal refactor or improvement rust Related to Rust Polars labels Mar 7, 2025
@nameexhaustion nameexhaustion changed the title refactor(rust): Remove switch from once_cell to std refactor(rust): Remove once_cell Mar 7, 2025
@@ -101,7 +100,8 @@ impl From<u8> for StateFlags {
}
}

type CachedValue = Arc<(AtomicI64, OnceCell<DataFrame>)>;
// TODO: Replace with `OnceLock<DataFrame>` after `OnceLock::get_or_try_init` is stabilized.
type CachedValue = Arc<(AtomicI64, OnceLock<PolarsResult<DataFrame>>)>;
Copy link
Collaborator Author

@nameexhaustion nameexhaustion Mar 7, 2025

Choose a reason for hiding this comment

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

get_or_try_init is not stabilized, but this is the only use of it in the codebase. We instead directly store the result type in the oncelock.

Copy link
Member

Choose a reason for hiding this comment

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

I am rewriting the cache. That will remove this usage.

Copy link
Member

Choose a reason for hiding this comment

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

After this one, it should be good to go:

#21646

Copy link

codecov bot commented Mar 7, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 80.54%. Comparing base (251fab5) to head (fc20aee).
Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #21639   +/-   ##
=======================================
  Coverage   80.54%   80.54%           
=======================================
  Files        1603     1603           
  Lines      231258   231258           
  Branches     2650     2650           
=======================================
+ Hits       186265   186266    +1     
+ Misses      44376    44375    -1     
  Partials      617      617           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@nameexhaustion nameexhaustion marked this pull request as ready for review March 7, 2025 06:10
@nameexhaustion nameexhaustion marked this pull request as draft March 7, 2025 06:36
@nameexhaustion nameexhaustion force-pushed the std-cell branch 3 times, most recently from b218d7e to 4c676fe Compare March 7, 2025 14:33
@nameexhaustion nameexhaustion changed the title refactor(rust): Remove once_cell refactor(rust): Remove once_cell in favor of std equivalents Mar 7, 2025
@nameexhaustion nameexhaustion marked this pull request as ready for review March 7, 2025 15:15
@ritchie46 ritchie46 merged commit e0ab88a into pola-rs:main Mar 7, 2025
23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
internal An internal refactor or improvement rust Related to Rust Polars
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants