A sketch maps each item to positions in its array, and that map is a hash function. We pin an exact, portable hash - FNV-1a over 64 bits - so every index, counter, and register in this project is reproducible in any language.
Implement the FNV-1a 64-bit hash and reproduce an exact value for a known input.
If a data structure asks the language runtime for a hash (the default map hash), its indices differ between languages and even between program runs, and none of this project’s exact bit positions would be reproducible. So we specify the hash ourselves. FNV-1a is a good choice: a handful of lines, no tables, and a byte-at-a-time loop that is identical in every language.
The rule is tiny. Start from a fixed offset basis, and for each input byte, XOR it into the running hash and then multiply by a fixed prime, letting the value wrap around modulo two to the sixty-fourth (unsigned 64-bit overflow). That wrap is the whole hash - there is nothing else to it. Every index this project pins traces back to this function, so confirm the exact value for "cat" before moving on.
const offset uint64 = 14695981039346656037const prime uint64 = 1099511628211func Hash1(data []byte) uint64 {h := offsetfor _, b := range data { h ^= uint64(b); h *= prime } // uint64 wraps mod 2^64return h}