From ba36b192515508fc6bcab7ae8439be12750b76f7 Mon Sep 17 00:00:00 2001 From: Nikhil Benesch Date: Tue, 11 Oct 2022 02:07:03 -0400 Subject: [PATCH] Upgrade to ahash v0.8 This is a resubmission of #1271, which was reverted in 6e46651, due to compilation errors with the wasm32 target. It builds on #1274 to fix those compilation errors. Closes #1274. Co-authored-by: "Jorge C. Leitao" --- Cargo.toml | 11 +++++++++-- src/compute/hash.rs | 10 +++++----- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index a076210d4b8..63730f116ca 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -30,9 +30,16 @@ ethnum = "1" hash_hasher = "^2.0.3" # For SIMD utf8 validation simdutf8 = "0.1.3" + # faster hashing -ahash = { version = "0.7" } -# A Rust port of SwissTable +[target.'cfg(target_arch = "wasm32")'.dependencies] +ahash = { version = "0.8", features=["compile-time-rng"] } +getrandom = { version = "0.2", features = ["js"] } + +[target.'cfg(not(target_arch = "wasm32"))'.dependencies] +ahash = { version = "0.8", features=["runtime-rng"] } + +# A Rust port of SwissTable hashbrown = { version = "0.12", default-features = false, optional = true } # for timezone support diff --git a/src/compute/hash.rs b/src/compute/hash.rs index 3387ac9bbd7..68232b4d015 100644 --- a/src/compute/hash.rs +++ b/src/compute/hash.rs @@ -1,7 +1,7 @@ //! Contains the [`hash`] and typed (e.g. [`hash_primitive`]) operators. // multiversion does not copy documentation, causing a false positive #![allow(missing_docs)] -use ahash::{CallHasher, RandomState}; +use ahash::RandomState; use multiversion::multiversion; use std::hash::Hash; @@ -26,7 +26,7 @@ use super::arity::unary; pub fn hash_primitive(array: &PrimitiveArray) -> PrimitiveArray { let state = new_state!(); - unary(array, |x| T::get_hash(&x, &state), DataType::UInt64) + unary(array, |x| state.hash_one(x), DataType::UInt64) } #[multiversion] @@ -37,7 +37,7 @@ pub fn hash_boolean(array: &BooleanArray) -> PrimitiveArray { let values = array .values_iter() - .map(|x| u8::get_hash(&x, &state)) + .map(|x| state.hash_one(x)) .collect::>() .into(); @@ -52,7 +52,7 @@ pub fn hash_utf8(array: &Utf8Array) -> PrimitiveArray { let values = array .values_iter() - .map(|x| <[u8]>::get_hash(&x.as_bytes(), &state)) + .map(|x| state.hash_one(x.as_bytes())) .collect::>() .into(); @@ -64,7 +64,7 @@ pub fn hash_binary(array: &BinaryArray) -> PrimitiveArray { let state = new_state!(); let values = array .values_iter() - .map(|x| <[u8]>::get_hash(&x, &state)) + .map(|x| state.hash_one(x)) .collect::>() .into();