wooden-country-60054
03/04/2023, 2:27 AMfresh-football-47124
wooden-country-60054
03/04/2023, 4:22 AMCREATE OR REPLACE FUNCTION fnv1a32(str TEXT) RETURNS BIGINT AS $$
DECLARE
hval BIGINT := 2166136261;
prime BIGINT := 16777619;
uint32_max BIGINT := 2 ^ 32;
BEGIN
FOR i IN 1..length(str) LOOP
hval := (hval # ASCII(SUBSTR(str, i, 1))) * prime % uint32_max;
END LOOP;
RETURN hval::BIGINT;
END;
$$ LANGUAGE plpgsql IMMUTABLE;
fresh-football-47124
wooden-country-60054
03/04/2023, 4:23 AMfresh-football-47124
wooden-country-60054
03/04/2023, 4:29 AM%%sql
with t1 as (
select random_between(a, a*50000) n
from unnest(array(select * from generate_series(10000,20000))) a
)
select n, fnv1a32(n::TEXT) h from t1
and then by
df['hp']=df['n'].apply(lambda x: fnv1a32(str(x)))
df['h'].equals(df['hp'])
narrow-tomato-61607
03/05/2023, 7:24 PMcolossal-petabyte-61345
03/05/2023, 7:53 PMwooden-country-60054
03/06/2023, 3:56 AM