Skip to content

Commit f350341

Browse files
committed
asim: rename arguments
This commit renames parameters for distribution helper functions in pkg/kv/kvserver/asim/state/new_state.go.
1 parent e75b9de commit f350341

File tree

1 file changed

+16
-16
lines changed

1 file changed

+16
-16
lines changed

pkg/kv/kvserver/asim/state/new_state.go

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -30,41 +30,41 @@ func (s requestCounts) Less(i, j int) bool {
3030
}
3131
func (s requestCounts) Swap(i, j int) { s[i], s[j] = s[j], s[i] }
3232

33-
func evenDistribution(n int) []float64 {
33+
func evenDistribution(numOfStores int) []float64 {
3434
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++ {
3737
distribution = append(distribution, frac)
3838
}
3939
return distribution
4040
}
4141

42-
func skewedDistribution(n, k int) []float64 {
43-
weights := make([]float64, n)
42+
func skewedDistribution(numOfStores, k int) []float64 {
43+
weights := make([]float64, numOfStores)
4444
var total float64
4545
// Compute weights.
46-
for i := 0; i < n; i++ {
46+
for i := 0; i < numOfStores; i++ {
4747
// weight[0] = 2^(n-1)
4848
// weight[1] = 2^(n-2)
4949
// ...
5050
// 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))
5252
total += weights[i]
5353
}
5454
// Normalize to get ratios.
55-
for i := 0; i < n; i++ {
55+
for i := 0; i < numOfStores; i++ {
5656
weights[i] /= total
5757
}
5858
return weights
5959
}
6060

61-
func exactDistribution(counts []int) []float64 {
62-
distribution := make([]float64, len(counts))
61+
func exactDistribution(storeReplicaCount []int) []float64 {
62+
distribution := make([]float64, len(storeReplicaCount))
6363
total := 0
64-
for _, count := range counts {
64+
for _, count := range storeReplicaCount {
6565
total += count
6666
}
67-
for i, count := range counts {
67+
for i, count := range storeReplicaCount {
6868
distribution[i] = float64(count) / float64(total)
6969
}
7070
return distribution
@@ -135,16 +135,16 @@ func weightedRandDistribution(randSource *rand.Rand, weightedStores []float64) [
135135
// randDistribution generates a random distribution across stores. It achieves
136136
// this by creating an array of size n, selecting random numbers from [0, 10)
137137
// 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 {
139139
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++ {
142142
num := float64(randSource.Intn(10))
143143
distribution[i] = num
144144
total += num
145145
}
146146

147-
for i := 0; i < n; i++ {
147+
for i := 0; i < numOfStores; i++ {
148148
distribution[i] = distribution[i] / total
149149
}
150150
return distribution

0 commit comments

Comments
 (0)