Skip to content

Commit

Permalink
fix getNChooseKLowerBound
Browse files Browse the repository at this point in the history
  • Loading branch information
kakaiu committed Nov 5, 2024
1 parent 59a6c5c commit e8f7c61
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion fdbclient/ServerKnobs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ void ServerKnobs::initialize(Randomize randomize, ClientKnobs* clientKnobs, IsSi
init( DD_LARGE_TEAM_DELAY, 60.0 );
init( DD_FIX_WRONG_REPLICAS_DELAY, 60.0 );
init (DD_VALIDATE_SERVER_TEAM_COUNT_AFTER_BUILD_TEAM, false ); if (isSimulated) DD_VALIDATE_SERVER_TEAM_COUNT_AFTER_BUILD_TEAM = true;
init( DD_BUILD_TEAMS_FAILED_TIMESPAN_AS_ERROR, 0 ); if (isSimulated) DD_BUILD_TEAMS_FAILED_TIMESPAN_AS_ERROR = 15 * 60;
init( DD_BUILD_TEAMS_FAILED_TIMESPAN_AS_ERROR, 0 ); if (isSimulated) DD_BUILD_TEAMS_FAILED_TIMESPAN_AS_ERROR = 5 * 60;

// TeamRemover
init( TR_LOW_SPACE_PIVOT_DELAY_SEC, 0 ); if (isSimulated) TR_LOW_SPACE_PIVOT_DELAY_SEC = deterministicRandom()->randomInt(0, 3);
Expand Down
20 changes: 10 additions & 10 deletions fdbserver/DDTeamCollection.actor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,21 +74,21 @@ unsigned EligibilityCounter::getCount(int combinedType) const {

} // namespace data_distribution

size_t getNChooseKLowerBound(size_t n, size_t k) {
if (k > n)
return 0;
if (k == 0)
size_t getNChooseKLowerBound(int n, int k) {
ASSERT(k >= 0 && k <= n);
if (k == 0 || k == n) {
return 1;
if (k * 2 > n)
}
// Take advantage of symmetry C(n, k) = C(n, n - k)
if (k > n - k) {
k = n - k;

double result = n;
for (size_t i = 2; i <= k; ++i) {
result *= ((n - i + 1) * 1.0 / i);
}
double result = 1;
for (int i = 1; i <= k; ++i) {
result *= ((n - k + i) * 1.0 / i); // avoid overflow
}
return static_cast<size_t>(floor(result));
}

class DDTeamCollectionImpl {
ACTOR static Future<Void> checkAndRemoveInvalidLocalityAddr(DDTeamCollection* self) {
state double start = now();
Expand Down

0 comments on commit e8f7c61

Please sign in to comment.