Skip to content
This repository has been archived by the owner on Feb 18, 2024. It is now read-only.

Commit

Permalink
Multi-versioning (30% speed up)
Browse files Browse the repository at this point in the history
  • Loading branch information
Dandandan committed Sep 19, 2021
1 parent 2616d1a commit b8db919
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/compute/hash.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use ahash::{CallHasher, RandomState};
use multiversion::multiversion;
use std::hash::Hash;

macro_rules! new_state {
Expand All @@ -18,13 +19,17 @@ use crate::{
use super::arity::unary;

/// Element-wise hash of a [`PrimitiveArray`]. Validity is preserved.
#[multiversion]
#[clone(target = "x86_64+aes+sse3+ssse3+avx+avx2")]
pub fn hash_primitive<T: NativeType + Hash>(array: &PrimitiveArray<T>) -> PrimitiveArray<u64> {
let state = new_state!();

unary(array, |x| T::get_hash(&x, &state), DataType::UInt64)
}

/// Element-wise hash of a [`BooleanArray`]. Validity is preserved.
#[multiversion]
#[clone(target = "x86_64+aes+sse3+ssse3+avx+avx2")]
pub fn hash_boolean(array: &BooleanArray) -> PrimitiveArray<u64> {
let state = new_state!();

Expand All @@ -33,6 +38,8 @@ pub fn hash_boolean(array: &BooleanArray) -> PrimitiveArray<u64> {
PrimitiveArray::<u64>::from_data(DataType::UInt64, values, array.validity().clone())
}

#[multiversion]
#[clone(target = "x86_64+aes+sse3+ssse3+avx+avx2")]
/// Element-wise hash of a [`Utf8Array`]. Validity is preserved.
pub fn hash_utf8<O: Offset>(array: &Utf8Array<O>) -> PrimitiveArray<u64> {
let state = new_state!();
Expand Down

0 comments on commit b8db919

Please sign in to comment.