metrohash-64
MetroHash checksum

Next:metrohash-128


Vocabulary
checksums.metrohash

Class description
MetroHash 64-bit checksum algorithm.

Definition


Methods

M:: metrohash-64 checksum-bytes ( bytes checksum -- value )
3603962101 :> k0 2729050939 :> k1 1654206401 :> k2 817650473
:> 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 k2 W+ k0 W*
:> h h h h h :> ( v0! v1! v2! 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+ -37 bitroll-64 k1 W*
v2 bitxor v2! v1 v2 W+ k1 W* v0 W+ -37 bitroll-64 k0 W*
v3 bitxor v3! v0 v2 W+ k0 W* v3 W+ -37 bitroll-64 k1 W*
v0 bitxor v0! v1 v3 W+ k1 W* v2 W+ -37 bitroll-64 k0 W*
v1 bitxor v1! v0 v1 bitxor h W+ v0!
] when len/32 len/16 bytes uint64_t native-mapper [
first2
[ k2 W* v0 W+ -29 bitroll-64 k3 W* v1! ]
[ k2 W* v0 W+ -29 bitroll-64 k3 W* v2! ] bi* v1 k0 W*
-21 bitroll-64 v2 W+ v1 bitxor v1! v2 k3 W*
-21 bitroll-64 v1 W+ v2 bitxor v2! v2 v0 W+ v0!
] unless-empty len/16 len/8 bytes uint64_t native-mapper [
first k3 W* v0 W+ v0! v0 -55 bitroll-64 k1 W* v0 bitxor
v0!
] unless-empty len/8 len/4 bytes uint32_t native-mapper [
first k3 W* v0 W+ v0! v0 -26 bitroll-64 k1 W* v0 bitxor
v0!
] unless-empty len/4 len/2 bytes uint16_t native-mapper [
first k3 W* v0 W+ v0! v0 -48 bitroll-64 k1 W* v0 bitxor
v0!
] unless-empty bytes len/2 tail-slice [
first k3 W* v0 W+ v0! v0 -37 bitroll-64 k1 W* v0 bitxor
v0!
] unless-empty v0 -28 bitroll-64 v0 bitxor v0! ~11 more~ ;