Skip to content

Commit

Permalink
Minor refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
stinodego committed Sep 25, 2023
1 parent 3f3e323 commit f497bb3
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ static STRING_CACHE_UUID_CTR: AtomicU32 = AtomicU32::new(0);
/// ```
/// use polars_core::StringCacheHolder;
///
/// let handle = StringCacheHolder::hold();
/// let _sc = StringCacheHolder::hold();
/// ```
///
/// The string cache is enabled until `handle` is dropped.
Expand Down
2 changes: 1 addition & 1 deletion crates/polars-io/src/parquet/read_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ pub fn read_parquet<R: MmapBytesReader>(
// if there are multiple row groups and categorical data
// we need a string cache
// we keep it alive until the end of the function
let _string_cache = if n_row_groups > 1 {
let _sc = if n_row_groups > 1 {
#[cfg(feature = "dtype-categorical")]
{
Some(polars_core::StringCacheHolder::hold())
Expand Down
2 changes: 1 addition & 1 deletion crates/polars-plan/src/logical_plan/functions/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ impl FunctionNode {
// we use a global string cache here as streaming chunks all have different rev maps
#[cfg(feature = "dtype-categorical")]
{
let _hold = StringCacheHolder::hold();
let _sc = StringCacheHolder::hold();
Arc::get_mut(function).unwrap().call_udf(df)
}

Expand Down
2 changes: 1 addition & 1 deletion crates/polars/tests/it/core/joins.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use polars_core::utils::{accumulate_dataframes_vertical, split_df};
#[cfg(feature = "dtype-categorical")]
use polars_core::{disable_string_cache, StringCacheHolder};
use polars_core::{disable_string_cache, StringCacheHolder, SINGLE_LOCK};

use super::*;

Expand Down
12 changes: 5 additions & 7 deletions py-polars/polars/string_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,18 +154,16 @@ def disable_string_cache() -> bool:
"""
Disable and clear the global string cache.
Warnings
--------
Disabling the string cache this way may cause errors if there are other threads
that rely the global string cache being enabled.
Consider using the :class:`StringCache` context manager for a more reliable way of
enabling and disabling the string cache.
See Also
--------
enable_string_cache : Function to enable the string cache.
StringCache : Context manager for enabling and disabling the string cache.
Notes
-----
Consider using the :class:`StringCache` context manager for a more reliable way of
enabling and disabling the string cache.
Examples
--------
Construct two Series using the same global string cache.
Expand Down

0 comments on commit f497bb3

Please sign in to comment.