@@ -30,41 +30,41 @@ func (s requestCounts) Less(i, j int) bool {
30
30
}
31
31
func (s requestCounts ) Swap (i , j int ) { s [i ], s [j ] = s [j ], s [i ] }
32
32
33
- func evenDistribution (n int ) []float64 {
33
+ func evenDistribution (numOfStores int ) []float64 {
34
34
distribution := []float64 {}
35
- frac := 1.0 / float64 (n )
36
- for i := 0 ; i < n ; i ++ {
35
+ frac := 1.0 / float64 (numOfStores )
36
+ for i := 0 ; i < numOfStores ; i ++ {
37
37
distribution = append (distribution , frac )
38
38
}
39
39
return distribution
40
40
}
41
41
42
- func skewedDistribution (n , k int ) []float64 {
43
- weights := make ([]float64 , n )
42
+ func skewedDistribution (numOfStores , k int ) []float64 {
43
+ weights := make ([]float64 , numOfStores )
44
44
var total float64
45
45
// Compute weights.
46
- for i := 0 ; i < n ; i ++ {
46
+ for i := 0 ; i < numOfStores ; i ++ {
47
47
// weight[0] = 2^(n-1)
48
48
// weight[1] = 2^(n-2)
49
49
// ...
50
50
// weight[n-1] = 2^0
51
- weights [i ] = math .Pow (2 , float64 (n - i - 1 ))
51
+ weights [i ] = math .Pow (2 , float64 (numOfStores - i - 1 ))
52
52
total += weights [i ]
53
53
}
54
54
// Normalize to get ratios.
55
- for i := 0 ; i < n ; i ++ {
55
+ for i := 0 ; i < numOfStores ; i ++ {
56
56
weights [i ] /= total
57
57
}
58
58
return weights
59
59
}
60
60
61
- func exactDistribution (counts []int ) []float64 {
62
- distribution := make ([]float64 , len (counts ))
61
+ func exactDistribution (storeReplicaCount []int ) []float64 {
62
+ distribution := make ([]float64 , len (storeReplicaCount ))
63
63
total := 0
64
- for _ , count := range counts {
64
+ for _ , count := range storeReplicaCount {
65
65
total += count
66
66
}
67
- for i , count := range counts {
67
+ for i , count := range storeReplicaCount {
68
68
distribution [i ] = float64 (count ) / float64 (total )
69
69
}
70
70
return distribution
@@ -135,16 +135,16 @@ func weightedRandDistribution(randSource *rand.Rand, weightedStores []float64) [
135
135
// randDistribution generates a random distribution across stores. It achieves
136
136
// this by creating an array of size n, selecting random numbers from [0, 10)
137
137
// for each index, and returning the exact distribution of this result.
138
- func randDistribution (randSource * rand.Rand , n int ) []float64 {
138
+ func randDistribution (randSource * rand.Rand , numOfStores int ) []float64 {
139
139
total := float64 (0 )
140
- distribution := make ([]float64 , n )
141
- for i := 0 ; i < n ; i ++ {
140
+ distribution := make ([]float64 , numOfStores )
141
+ for i := 0 ; i < numOfStores ; i ++ {
142
142
num := float64 (randSource .Intn (10 ))
143
143
distribution [i ] = num
144
144
total += num
145
145
}
146
146
147
- for i := 0 ; i < n ; i ++ {
147
+ for i := 0 ; i < numOfStores ; i ++ {
148
148
distribution [i ] = distribution [i ] / total
149
149
}
150
150
return distribution
0 commit comments