Skip to content

Commit c0fc380

Browse files
author
hero
committed
编写一致性hash
1 parent d05fa31 commit c0fc380

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

consistent_hash_code/consistent.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ func (c *Consistent) refreshHashSortNodes() {
7878

7979
func (c *Consistent) searchNearbyIndex(key string) int {
8080
hashKey := hashKey(key)
81-
index := sort.Search(len(c.hashSortNodes), func(i int) bool { //key算出的节点,距离最近的node节点下标
81+
index := sort.Search(len(c.hashSortNodes), func(i int) bool { //key算出的节点,距离最近的node节点下标 sort.Search数组需要升序排列好
8282
return c.hashSortNodes[i] >= hashKey
8383
})
8484
if index >= len(c.hashSortNodes) {

0 commit comments

Comments
 (0)