Library / Hashing / Hashing / HashConstants
HashConstants
A stateless utility namespace (like Math) holding the
FNV-1a magic numbers that the Hashable kernel types reach into when
building their hash() implementations.
Fields 9
uint64 FNV_OFFSET_BASIS_64uint64 FNV_PRIME_64int32 FNV_OFFSET_BASIS_32int32 FNV_PRIME_32int64 SIZES_LENint64 SIZESint64 POW2_MAX_LEVELint64 SHALLOW_PRIMES_LENint64 SHALLOW_PRIMESMethods 8
METHOD initialBucketCount() RETURNS int64reads
Bucket count for growth level 0 (the initial table size).
METHOD bucketCountAtLevel(int64 level) RETURNS int64reads
Bucket count at level, clamped to the ends of the ladder. Past
the top prime the table stops growing (V1 cap ~196k buckets).
METHOD canGrow(int64 level) RETURNS booleanreads
TRUE while there is a larger prime to grow into.
METHOD pow2CountAtLevel(int64 level) RETURNS int64reads
Power-of-two bucket count at level — 16 << level, clamped to the cap.
METHOD indexForHash(uint64 hash, int64 count) RETURNS int64reads
Bucket index for hash given a power-of-two count: hash & (count - 1).
The low bits carry the masked index, so truncating the uint64 hash to int64
first (the mask < 2^31 keeps the result in [0, count)) avoids an int→uint
sign-cross while preserving every bit the mask reads.
METHOD mulShiftIndex(uint64 hash, uint64 mult, int64 shift) RETURNS int64reads
(mult * hash) >> shift — the top 64-shift bits of the product mix ALL
input bits (unlike the low-bit mask above), so it distributes a
well-mixed hash without a mod. mult is an odd 64-bit constant chosen
key-set-aware; shift = 64 - log2(capacity).
METHOD primeAtLeast(int64 target) RETURNS int64reads
Smallest ladder prime >= target (clamped to the top prime).
METHOD primeModIndex(uint64 hash, uint64 mult, uint64 p) RETURNS int64reads
(mult * hash) % p — the prime-mode index (fallback tier).