diff --git a/optd-cost-model/Cargo.lock b/optd-cost-model/Cargo.lock index f749199..a38097d 100644 --- a/optd-cost-model/Cargo.lock +++ b/optd-cost-model/Cargo.lock @@ -1799,7 +1799,6 @@ dependencies = [ "crossbeam", "datafusion-expr", "itertools 0.13.0", - "lazy_static", "optd-persistent", "ordered-float 4.5.0", "rand", diff --git a/optd-cost-model/Cargo.toml b/optd-cost-model/Cargo.toml index d37c72a..1d41af7 100644 --- a/optd-cost-model/Cargo.toml +++ b/optd-cost-model/Cargo.toml @@ -13,7 +13,6 @@ datafusion-expr = "32.0.0" ordered-float = "4.0" chrono = "0.4" itertools = "0.13" -lazy_static = "1.5" [dev-dependencies] crossbeam = "0.8" diff --git a/optd-cost-model/src/stats/arith_encoder.rs b/optd-cost-model/src/stats/arith_encoder.rs index 4285939..730fcdb 100644 --- a/optd-cost-model/src/stats/arith_encoder.rs +++ b/optd-cost-model/src/stats/arith_encoder.rs @@ -7,10 +7,7 @@ //! Non-alpha-numeric characters are relegated to the end of the encoded value, //! rendering them indistinguishable from one another in this context. -use std::collections::HashMap; - -// TODO: Use lazy cell instead of lazy static. -use lazy_static::lazy_static; +use std::{collections::HashMap, sync::LazyLock}; // The alphanumerical ordering. const ALPHANUMERIC_ORDER: [char; 95] = [ @@ -23,16 +20,14 @@ const ALPHANUMERIC_ORDER: [char; 95] = [ const PMF: f64 = 1.0 / (ALPHANUMERIC_ORDER.len() as f64); -lazy_static! { - static ref CDF: HashMap = { - let length = ALPHANUMERIC_ORDER.len() + 1; // To account for non-alpha-numeric characters. - let mut cdf = HashMap::with_capacity(length); - for (index, &char) in ALPHANUMERIC_ORDER.iter().enumerate() { - cdf.insert(char, (index as f64) / (length as f64)); - } - cdf - }; -} +static CDF: LazyLock> = LazyLock::new(|| { + let length = ALPHANUMERIC_ORDER.len() + 1; // To account for non-alpha-numeric characters. + let mut cdf = HashMap::with_capacity(length); + for (index, &char) in ALPHANUMERIC_ORDER.iter().enumerate() { + cdf.insert(char, (index as f64) / (length as f64)); + } + cdf +}); pub fn encode(string: &str) -> f64 { let mut left = 0.0;