code wiki / (root) / nx_murmur3.nx

nx_murmur3.nx

buildroot/runtime/nx_murmur3.nx

3301 B103 linesdepth 2pulls 2 transitivereach 63 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

nx_syscalls.nx nx_murmur3.nx nx_bloom.nx nx_sketch_bloom.nx nx_sketch_cms.nx nx_sketch_counting_bloom.nx nx_sketch_cpc.nx nx_sketch_cpc_dense.nx nx_sketch_hll.nx nx_sketch_hll4.nx nx_sketch_hll_packed.nx nx_sketch_hllmap.nx

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

imports: nx_syscalls.nx

imported by: nx_bloom.nxnx_sketch_bloom.nxnx_sketch_cms.nxnx_sketch_counting_bloom.nxnx_sketch_cpc.nxnx_sketch_cpc_dense.nxnx_sketch_hll.nxnx_sketch_hll4.nxnx_sketch_hll_packed.nxnx_sketch_hllmap.nxnx_sketch_kmv.nxnx_sketch_linear_counter.nxnx_sketch_theta.nxnx_sketch_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

32const MM_C1: i64 = 0xCC9E2D51
33const MM_C2: i64 = 0x1B873593
34const U32_BITS: i64 = 0xFFFFFFFF

functions

37func mm_rotl32(x: i64, r: i64) -> i64
called by 1: murmur3_32
44func mm_load_u32_le(buf: *u8, off: i64) -> i64
called by 1: murmur3_32
54func murmur3_32(seed: i64, key: *u8, len: i64) -> i64
96func main() -> i64
calls 1: murmur3_32