From f497bb3bc3d785b6fcf8ac046aeebb5d485257c8 Mon Sep 17 00:00:00 2001 From: Stijn de Gooijer Date: Thu, 14 Sep 2023 11:42:51 +0200 Subject: [PATCH] Minor refactor --- .../logical/categorical/string_cache.rs | 2 +- crates/polars-io/src/parquet/read_impl.rs | 2 +- crates/polars-plan/src/logical_plan/functions/mod.rs | 2 +- crates/polars/tests/it/core/joins.rs | 2 +- py-polars/polars/string_cache.py | 12 +++++------- 5 files changed, 9 insertions(+), 11 deletions(-) diff --git a/crates/polars-core/src/chunked_array/logical/categorical/string_cache.rs b/crates/polars-core/src/chunked_array/logical/categorical/string_cache.rs index 687cf329767fc..c074f6c403fd4 100644 --- a/crates/polars-core/src/chunked_array/logical/categorical/string_cache.rs +++ b/crates/polars-core/src/chunked_array/logical/categorical/string_cache.rs @@ -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. diff --git a/crates/polars-io/src/parquet/read_impl.rs b/crates/polars-io/src/parquet/read_impl.rs index f9a4a6546cde9..a5612751557f1 100644 --- a/crates/polars-io/src/parquet/read_impl.rs +++ b/crates/polars-io/src/parquet/read_impl.rs @@ -251,7 +251,7 @@ pub fn read_parquet( // 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()) diff --git a/crates/polars-plan/src/logical_plan/functions/mod.rs b/crates/polars-plan/src/logical_plan/functions/mod.rs index 9d46a3cd528de..72efcf252c39d 100644 --- a/crates/polars-plan/src/logical_plan/functions/mod.rs +++ b/crates/polars-plan/src/logical_plan/functions/mod.rs @@ -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) } diff --git a/crates/polars/tests/it/core/joins.rs b/crates/polars/tests/it/core/joins.rs index f4da92ebd1424..4dee55d2080d7 100644 --- a/crates/polars/tests/it/core/joins.rs +++ b/crates/polars/tests/it/core/joins.rs @@ -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::*; diff --git a/py-polars/polars/string_cache.py b/py-polars/polars/string_cache.py index 43c23dbf268ba..8903ad886e4b8 100644 --- a/py-polars/polars/string_cache.py +++ b/py-polars/polars/string_cache.py @@ -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.