github.com/sequix/cortex@v1.1.6/pkg/chunk/gcp/fnv.go (about) 1 // Modified from github.com/prometheus/common/model/fnv.go 2 // Copyright 2015 The Prometheus Authors 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 package gcp 16 17 // Inline and byte-free variant of hash/fnv's fnv64a. 18 19 const ( 20 offset64 = 14695981039346656037 21 prime64 = 1099511628211 22 ) 23 24 // hashNew initializies a new fnv64a hash value. 25 func hashNew() uint64 { 26 return offset64 27 } 28 29 // hashAdd adds a string to a fnv64a hash value, returning the updated hash. 30 func hashAdd(h uint64, s string) uint64 { 31 for i := 0; i < len(s); i++ { 32 h ^= uint64(s[i]) 33 h *= prime64 34 } 35 return h 36 }