@@ -1002,7 +1002,8 @@ func (ac *analyzedConstraints) analyzeFunc(
10021002 }
10031003}
10041004
1005- // diversityFunc computes the diversity score between two sets of stores.
1005+ // diversityOfTwoStoreSets computes the diversity score between two sets of
1006+ // stores.
10061007//
10071008// When sameStores is false, intersection between this and other is empty and no
10081009// de-duplication is needed. For example, given two sets of stores [1, 2, 3] and
@@ -1012,7 +1013,7 @@ func (ac *analyzedConstraints) analyzeFunc(
10121013// When sameStores is true, this and other are the same set and de-duplication
10131014// is needed. For example, given two sets of stores [1, 2, 3] and [1, 2, 3],
10141015// diversity score should be computed among pairs (1, 2), (1, 3), (2, 3) only.
1015- func diversityFunc (
1016+ func diversityOfTwoStoreSets (
10161017 this []storeAndLocality , other []storeAndLocality , sameStores bool ,
10171018) (sumScore float64 , numSamples int ) {
10181019 for i := range this {
@@ -1052,15 +1053,15 @@ func diversityScore(
10521053 return sumScore / float64 (numSamples )
10531054 }
10541055
1055- voterSum , voterSamples := diversityFunc (replicas [voterIndex ], replicas [voterIndex ], true )
1056+ voterSum , voterSamples := diversityOfTwoStoreSets (replicas [voterIndex ], replicas [voterIndex ], true )
10561057 totalSum := voterSum
10571058 totalSamples := voterSamples
10581059
1059- nonVoterSum , nonVoterSamples := diversityFunc (replicas [nonVoterIndex ], replicas [nonVoterIndex ], true )
1060+ nonVoterSum , nonVoterSamples := diversityOfTwoStoreSets (replicas [nonVoterIndex ], replicas [nonVoterIndex ], true )
10601061 totalSum += nonVoterSum
10611062 totalSamples += nonVoterSamples
10621063
1063- voterNonVoterSum , voterNonVoterSamples := diversityFunc (replicas [voterIndex ], replicas [nonVoterIndex ], false )
1064+ voterNonVoterSum , voterNonVoterSamples := diversityOfTwoStoreSets (replicas [voterIndex ], replicas [nonVoterIndex ], false )
10641065 totalSum += voterNonVoterSum
10651066 totalSamples += voterNonVoterSamples
10661067 return scoreFromSumAndSamples (voterSum , voterSamples ), scoreFromSumAndSamples (totalSum , totalSamples )
0 commit comments