envzn
0.8 · beta · not released

Library / Hashing / Hashing / HashConstants

CLASS

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_64
uint64 FNV_PRIME_64
int32 FNV_OFFSET_BASIS_32
int32 FNV_PRIME_32
int64 SIZES_LEN
int64 SIZES
int64 POW2_MAX_LEVEL
int64 SHALLOW_PRIMES_LEN
int64 SHALLOW_PRIMES

Methods 8

METHOD initialBucketCount() RETURNS int64
reads

Bucket count for growth level 0 (the initial table size).

METHOD bucketCountAtLevel(int64 level) RETURNS int64
reads

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 boolean
reads

TRUE while there is a larger prime to grow into.

METHOD pow2CountAtLevel(int64 level) RETURNS int64
reads

Power-of-two bucket count at level — 16 << level, clamped to the cap.

METHOD indexForHash(uint64 hash, int64 count) RETURNS int64
reads

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 int64
reads

(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 int64
reads

Smallest ladder prime >= target (clamped to the top prime).

METHOD primeModIndex(uint64 hash, uint64 mult, uint64 p) RETURNS int64
reads

(mult * hash) % p — the prime-mode index (fallback tier).