Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions pkg/ingester/client/fnv.go
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Expand All @@ -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
}