Vocabulary
checksums.metrohash

Class description
MetroHash 128-bit checksum algorithm.

Definition


Methods

M:: metrohash-128 checksum-bytes ( bytes checksum -- value )
3359281633 :> k0 2252921819 :> k1 2078195771 :> k2 794325157
:> k3 checksum seed>> :> seed bytes length :> len len dup 32
mod - :> len/32 len dup 16 mod - :> len/16 len dup 8 mod -
:> len/8 len dup 4 mod - :> len/4 len dup 2 mod -
:> len/2 seed k0 W- k3 W* :> v0! seed k1 W+ k2 W*
:> v1! seed k0 W+ k2 W* :> v2! seed k1 W- k3 W*
:> v3! len 32 >= [
0 len/32 bytes uint64_t native-mapper 4 <groups> [
first4 {
[ k0 W* v0 W+ -29 bitroll-64 v2 W+ v0! ]
[ k1 W* v1 W+ -29 bitroll-64 v3 W+ v1! ]
[ k2 W* v2 W+ -29 bitroll-64 v0 W+ v2! ]
[ k3 W* v3 W+ -29 bitroll-64 v1 W+ v3! ]
} spread
] each v0 v3 W+ k0 W* v1 W+ -21 bitroll-64 k1 W*
v2 bitxor v2! v1 v2 W+ k1 W* v0 W+ -21 bitroll-64 k0 W*
v3 bitxor v3! v0 v2 W+ k0 W* v3 W+ -21 bitroll-64 k1 W*
v0 bitxor v0! v1 v3 W+ k1 W* v2 W+ -21 bitroll-64 k0 W*
v1 bitxor v1!
] when len/32 len/16 bytes uint64_t native-mapper [
first2
[ k2 W* v0 W+ -33 bitroll-64 k3 W* v0! ]
[ k2 W* v1 W+ -33 bitroll-64 k3 W* v1! ] bi* v0 k2 W*
v1 W+ -45 bitroll-64 k1 W* v0 bitxor v0! v1 k3 W* v0 W+
-45 bitroll-64 k0 W* v1 bitxor v1!
] unless-empty len/16 len/8 bytes uint64_t native-mapper [
first k2 W* v0 W+ -33 bitroll-64 k3 W* v0! v0 k2 W*
v1 W+ -27 bitroll-64 k1 W* v0 bitxor v0!
] unless-empty len/8 len/4 bytes uint32_t native-mapper [
first k2 W* v1 W+ -33 bitroll-64 k3 W* v1! v1 k3 W*
v0 W+ -46 bitroll-64 k0 W* v1 bitxor v1!
] unless-empty len/4 len/2 bytes uint16_t native-mapper
~52 more~ ;