github.com/whtcorpsinc/MilevaDB-Prod@v0.0.0-20211104133533-f57f4be3b597/soliton/mvmap/fnv.go (about) 1 // Copyright 2011 The Go Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 // Copyright 2020 WHTCORPS INC 6 // 7 // Licensed under the Apache License, Version 2.0 (the "License"); 8 // you may not use this file except in compliance with the License. 9 // You may obtain a copy of the License at 10 // 11 // http://www.apache.org/licenses/LICENSE-2.0 12 // 13 // Unless required by applicable law or agreed to in writing, software 14 // distributed under the License is distributed on an "AS IS" BASIS, 15 // See the License for the specific language governing permissions and 16 // limitations under the License. 17 18 package mvmap 19 20 const ( 21 offset64 uint64 = 14695981039346656037 22 prime64 uint64 = 1099511628211 23 ) 24 25 // fnvHash64 is ported from go library, which is thread-safe. 26 func fnvHash64(data []byte) uint64 { 27 hash := offset64 28 for _, c := range data { 29 hash *= prime64 30 hash ^= uint64(c) 31 } 32 return hash 33 }