更新hash文件
This commit is contained in:
parent
82dbcf92d3
commit
8fae26e662
14
hash.go
14
hash.go
@ -13,12 +13,20 @@ import (
|
|||||||
"github.com/spaolacci/murmur3"
|
"github.com/spaolacci/murmur3"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// hash ...
|
||||||
|
//
|
||||||
|
// Author : go_developer@163.com<白茶清欢>
|
||||||
|
//
|
||||||
|
// Date : 14:41 2022/5/14
|
||||||
|
type hash struct {
|
||||||
|
}
|
||||||
|
|
||||||
// GetHashID ...
|
// GetHashID ...
|
||||||
//
|
//
|
||||||
// Author : go_developer@163.com<白茶清欢>
|
// Author : go_developer@163.com<白茶清欢>
|
||||||
//
|
//
|
||||||
// Date : 11:04 下午 2021/2/24
|
// Date : 11:04 下午 2021/2/24
|
||||||
func GetHashID(key interface{}) uint64 {
|
func (h *hash) GetHashID(key interface{}) uint64 {
|
||||||
return murmur3.Sum64([]byte(fmt.Sprintf("%v", key)))
|
return murmur3.Sum64([]byte(fmt.Sprintf("%v", key)))
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -27,6 +35,6 @@ func GetHashID(key interface{}) uint64 {
|
|||||||
// Author : go_developer@163.com<白茶清欢>
|
// Author : go_developer@163.com<白茶清欢>
|
||||||
//
|
//
|
||||||
// Date : 11:07 下午 2021/2/24
|
// Date : 11:07 下午 2021/2/24
|
||||||
func GetHashIDMod(key interface{}, shard int) int {
|
func (h *hash) GetHashIDMod(key interface{}, shard int) int {
|
||||||
return int(GetHashID(key) % uint64(shard))
|
return int(h.GetHashID(key) % uint64(shard))
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user