BilldogEng.Murmur (BilldogEng v1.0.0-beta.1)

Copy Markdown View Source

murmurhash3 (32-bit, x86, seed-able) — ported verbatim from the canonical web reference packages/ab-testing/src/ABTest.ts.

This is the cross-platform bucketing primitive for local feature-flag evaluation. The exact same algorithm runs on web / iOS / Android / every server SDK so that murmurhash3("{key}.{distinctId}") % 100 produces an identical bucket everywhere — a user is deterministically in or out of a rollout regardless of which platform evaluated the flag.

Implementation notes (must not change without re-pinning the vectors):

  • UTF-8 bytes (Elixir binaries are already UTF-8)
  • all arithmetic is masked to 32 bits (&&& 0xFFFFFFFF)
  • the result is the unsigned 32-bit integer

Summary

Functions

Deterministic 0..99 bucket for a "{key}.{distinctId}" style seed. Convenience wrapper around hash/2.

Compute the unsigned 32-bit murmurhash3 of key with the given seed (default 0).

Functions

bucket_of(seed)

@spec bucket_of(binary()) :: non_neg_integer()

Deterministic 0..99 bucket for a "{key}.{distinctId}" style seed. Convenience wrapper around hash/2.

hash(key, seed \\ 0)

@spec hash(binary(), non_neg_integer()) :: non_neg_integer()

Compute the unsigned 32-bit murmurhash3 of key with the given seed (default 0).