code wiki / (root) / murmur3.nx

murmur3.nx

buildroot/runtime/murmur3.nx

3144 B97 linesdepth 3pulls 3 transitivereach 52 importersview sourcekind tool
docsdependenciesstructsconstsfunctions

about

murmur3.nx -- MurmurHash3 (Austin Appleby 2008/2011). Fast non-cryptographic hash. Distributes well across the output range, fast (4-byte chunks), suitable for hash tables when adversarial inputs aren't a concern (otherwise use siphash.nx). Used by: ClickHouse, Cassandra, Hadoop, Lucene, RocksDB secondary indices, Bloom filters, sketch data structures. We ship only the 32-bit variant (MurmurHash3_x86_32) because it's the most widely deployed. 64-bit and 128-bit variants exist (x86_128, x64_128) and produce different output. Invariants: MM1 Pure function: hash(seed, bytes) is deterministic; no global state, no random. MM2 Output is exactly 32 bits packed into i64's low half. MM3 NOT cryptographically secure. An attacker can craft keys that collide; never use as a MAC or to defend against algorithmic-complexity attacks on hash tables in adversarial contexts.

dependencies 1 imports · 14 importers

syscalls.nx murmur3.nx bloom.nx sketch_bloom.nx sketch_cms.nx sketch_counting_bloom.nx sketch_cpc.nx sketch_cpc_dense.nx sketch_hll.nx sketch_hll4.nx sketch_hll_packed.nx sketch_hllmap.nx

diagram shows first 10 each side; +0 more imports, +4 more importers in the complete lists below.

imports: syscalls.nx

imported by: bloom.nxsketch_bloom.nxsketch_cms.nxsketch_counting_bloom.nxsketch_cpc.nxsketch_cpc_dense.nxsketch_hll.nxsketch_hll4.nxsketch_hll_packed.nxsketch_hllmap.nxsketch_kmv.nxsketch_linear_counter.nxsketch_theta.nxsketch_tuple.nx

call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown

main murmur3_32 mm_load_u32_le mm_rotl32

structs

none

consts

26const MM_C1: i64 = 0xCC9E2D51
27const MM_C2: i64 = 0x1B873593
28const U32_BITS: i64 = 0xFFFFFFFF

functions

31func mm_rotl32(x: i64, r: i64) -> i64 {
called by 1: murmur3_32
38func mm_load_u32_le(buf: *u8, off: i64) -> i64 {
called by 1: murmur3_32
48func murmur3_32(seed: i64, key: *u8, len: i64) -> i64 {
90func main() -> i64 {
calls 1: murmur3_32