bugfix:convert the range of k from [1,17] to [1,16]

This commit is contained in:
luqinwen
2023-02-07 20:18:15 +08:00
committed by finley
parent 20f6307dca
commit fe20c6c9e1

View File

@@ -58,7 +58,7 @@ func makeSkiplist() *skiplist {
func randomLevel() int16 {
total := uint64(1)<<uint64(maxLevel) - 1
k := rand.Uint64() % total
return maxLevel - int16(bits.Len64(k)) + 1
return maxLevel - int16(bits.Len64(k+1)) + 1
}
func (skiplist *skiplist) insert(member string, score float64) *node {