diff --git a/pkg/ingester/client/fnv.go b/pkg/ingester/client/fnv.go index f151186f0e3..c4150859506 100644 --- a/pkg/ingester/client/fnv.go +++ b/pkg/ingester/client/fnv.go @@ -29,6 +29,7 @@ func hashNew() uint64 { } // hashAdd adds a string to a fnv64a hash value, returning the updated hash. +// Note this is the same algorithm as Go stdlib `sum64a.Write()` func hashAdd(h uint64, s string) uint64 { for i := 0; i < len(s); i++ { h ^= uint64(s[i]) @@ -44,16 +45,17 @@ func hashAddByte(h uint64, b byte) uint64 { return h } -// HashNew32 initializies a new fnv64a hash value. +// HashNew32 initializies a new fnv32 hash value. func HashNew32() uint32 { return offset32 } -// HashAdd32 adds a string to a fnv64a hash value, returning the updated hash. +// HashAdd32 adds a string to a fnv32 hash value, returning the updated hash. +// Note this is the same algorithm as Go stdlib `sum32.Write()` func HashAdd32(h uint32, s string) uint32 { for i := 0; i < len(s); i++ { - h ^= uint32(s[i]) h *= prime32 + h ^= uint32(s[i]) } return h }