murmur_nif (murmur_nif v0.1.1)

View Source

MurmurHash3 x64_128 NIF, with a Cassandra/Scylla-compatible signed-byte variant.

Two functions:

  • murmur3_x64_128/1 -- standard MurmurHash3 x64_128 (Austin Appleby). Use for general non-cryptographic hashing.
  • murmur3_cassandra_x64_128/1 -- the same algorithm but with input bytes treated as signed (matching Java's signed byte type). The sign-extension on the tail-block accumulator differs from the standard variant, so the two return different hashes for any input that contains a byte with bit 7 set. Use this for Cassandra/Scylla partition-token routing.

Both functions take a binary and return a fixed 16-byte binary <<H1:64, H2:64>>. Seed is hardcoded to 0 (matching Cassandra's default); callers needing a different seed should vendor MurmurHash3 directly. Inputs over 20 KB are dispatched to a dirty CPU scheduler; smaller inputs run inline with timeslice accounting.

Summary

Functions

Cassandra/Scylla-compatible variant of MurmurHash3 x64_128. Identical to murmur3_x64_128/1 except the input bytes are treated as signed (matching Java's signed byte type), which changes the sign-extension of the tail-block accumulator and produces hashes that match the partitioner used by Cassandra and Scylla.

MurmurHash3, 128-bit variant for 64-bit platforms (Austin Appleby's standard implementation). Hashes Bin with seed 0 and returns a 16-byte binary <<H1:64, H2:64>>.

Functions

murmur3_cassandra_x64_128(Bin)

-spec murmur3_cassandra_x64_128(binary()) -> binary().

Cassandra/Scylla-compatible variant of MurmurHash3 x64_128. Identical to murmur3_x64_128/1 except the input bytes are treated as signed (matching Java's signed byte type), which changes the sign-extension of the tail-block accumulator and produces hashes that match the partitioner used by Cassandra and Scylla.

Use this to compute partition tokens for token-aware routing.

murmur3_x64_128(Bin)

-spec murmur3_x64_128(binary()) -> binary().

MurmurHash3, 128-bit variant for 64-bit platforms (Austin Appleby's standard implementation). Hashes Bin with seed 0 and returns a 16-byte binary <<H1:64, H2:64>>.