github.com/scottcagno/storage@v1.8.0/pkg/hashmap/openaddr/global.go (about)

     1  package openaddr
     2  
     3  const (
     4  	DefaultLoadFactor = 0.90 // load factor must exceed 50%
     5  	DefaultMapSize    = 16
     6  )
     7  
     8  // alignBucketCount aligns buckets to ensure all sizes are powers of two
     9  func alignBucketCount(size uint) uint64 {
    10  	count := uint(DefaultMapSize)
    11  	for count < size {
    12  		count *= 2
    13  	}
    14  	return uint64(count)
    15  }