-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added enable_string_cache, disable_string_cache, and using_string_cac…
…he to Polars
- Loading branch information
Showing
3 changed files
with
70 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
module Polars | ||
module Functions | ||
# Enable the global string cache. | ||
# | ||
# `Categorical` columns created under the same global string cache have | ||
# the same underlying physical value when string values are equal. This allows the | ||
# columns to be concatenated or used in a join operation, for example. | ||
# | ||
# @return [nil] | ||
# | ||
# @example Construct two Series using the same global string cache. | ||
# Polars.enable_string_cache | ||
# s1 = Polars::Series.new("color", ["red", "green", "red"], dtype: Polars::Categorical) | ||
# s2 = Polars::Series.new("color", ["blue", "red", "green"], dtype: Polars::Categorical) | ||
# Polars.disable_string_cache | ||
# | ||
# @example As both Series are constructed under the same global string cache, they can be concatenated. | ||
# Polars.concat([s1, s2]) | ||
# # => | ||
# # shape: (6,) | ||
# # Series: 'color' [cat] | ||
# # [ | ||
# # "red" | ||
# # "green" | ||
# # "red" | ||
# # "blue" | ||
# # "red" | ||
# # "green" | ||
# # ] | ||
def enable_string_cache | ||
Plr.enable_string_cache | ||
end | ||
|
||
# Disable and clear the global string cache. | ||
# | ||
# @return [nil] | ||
# | ||
# @example Construct two Series using the same global string cache. | ||
# Polars.enable_string_cache | ||
# s1 = Polars::Series.new("color", ["red", "green", "red"], dtype: Polars::Categorical) | ||
# s2 = Polars::Series.new("color", ["blue", "red", "green"], dtype: Polars::Categorical) | ||
# Polars.disable_string_cache | ||
# | ||
# @example As both Series are constructed under the same global string cache, they can be concatenated. | ||
# Polars.concat([s1, s2]) | ||
# # => | ||
# # shape: (6,) | ||
# # Series: 'color' [cat] | ||
# # [ | ||
# # "red" | ||
# # "green" | ||
# # "red" | ||
# # "blue" | ||
# # "red" | ||
# # "green" | ||
# # ] | ||
def disable_string_cache | ||
Plr.disable_string_cache | ||
end | ||
|
||
# Check whether the global string cache is enabled. | ||
# | ||
# @return [Boolean] | ||
def using_string_cache | ||
Plr.using_string_cache | ||
end | ||
end | ||
end |