Simplify count increments.

This commit is contained in:
Suraj Gupta 2021-09-17 17:25:58 -04:00 committed by Josh Slocum
parent 4530e746d6
commit 2b9dfc1371
1 changed files with 1 additions and 7 deletions

View File

@ -3453,11 +3453,7 @@ bool isHealthySingleton(ClusterControllerData* self,
std::map<Optional<Standalone<StringRef>>, int> getColocCounts(const vector<Optional<Standalone<StringRef>>>& pids) {
std::map<Optional<Standalone<StringRef>>, int> counts;
for (const auto& pid : pids) {
if (counts.find(pid) == counts.end()) {
counts[pid] = 1;
} else {
++counts[pid];
}
++counts[pid];
}
return counts;
}
@ -3473,7 +3469,6 @@ void checkBetterSingletons(ClusterControllerData* self) {
// note: this map doesn't consider pids used by existing singletons
std::map<Optional<Standalone<StringRef>>, int> id_used = self->getUsedIds();
// TODO: moved this amplification to before getWorker, verify this is valid.
// We prefer spreading out other roles more than separating singletons on their own process
// so we artificially amplify the pid count for the processes used by non-singleton roles.
// In other words, we make the processes used for other roles less desirable to be used
@ -3511,7 +3506,6 @@ void checkBetterSingletons(ClusterControllerData* self) {
// if we reach here, we know that the singletons are healthy so let's
// check if we can colocate the singletons in a more optimal way
// TODO: verify that we don't need to get the pid from the worker like we were doing before
Optional<Standalone<StringRef>> currRKProcessId = rkSingleton.interface.get().locality.processId();
Optional<Standalone<StringRef>> currDDProcessId = ddSingleton.interface.get().locality.processId();
Optional<Standalone<StringRef>> newRKProcessId = newRKWorker.interf.locality.processId();