From a4afefb4fe7be2ad905ff2181314a2ecbdfeeac7 Mon Sep 17 00:00:00 2001 From: Bryan Boreham Date: Tue, 23 Apr 2019 13:03:58 +0000 Subject: [PATCH 1/2] Put Distributor hash algorithm back the way it was before 922a3b989a Signed-off-by: Bryan Boreham --- pkg/ingester/client/fnv.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pkg/ingester/client/fnv.go b/pkg/ingester/client/fnv.go index f151186f0e3..a2d0012f331 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]) @@ -50,10 +51,11 @@ func HashNew32() uint32 { } // HashAdd32 adds a string to a fnv64a 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 } From 6c0451aa6eb68400110e738869aa4fb67d1471c6 Mon Sep 17 00:00:00 2001 From: Bryan Boreham Date: Tue, 23 Apr 2019 13:30:21 +0000 Subject: [PATCH 2/2] Fix comment typos Signed-off-by: Bryan Boreham --- pkg/ingester/client/fnv.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/ingester/client/fnv.go b/pkg/ingester/client/fnv.go index a2d0012f331..c4150859506 100644 --- a/pkg/ingester/client/fnv.go +++ b/pkg/ingester/client/fnv.go @@ -45,12 +45,12 @@ 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++ {