FastRestore:Cosmetic change to improve code readability

This commit is contained in:
Meng Xu 2020-02-19 15:43:38 -08:00
parent 7897b1658f
commit d5d26f589f
2 changed files with 8 additions and 5 deletions

View File

@ -131,7 +131,7 @@ ACTOR static Future<Void> handleSendMutationVectorRequest(RestoreSendVersionedMu
for (int mIndex = 0; mIndex < mutations.size(); mIndex++) {
MutationRef mutation = mutations[mIndex];
TraceEvent(SevFRMutationInfo, "FastRestoreApplierPhaseReceiveMutations")
TraceEvent(SevFRMutationInfo, "FastRestoreApplierPhaseReceiveMutations", self->id())
.detail("ApplierNode", self->id())
.detail("RestoreAsset", req.asset.toString())
.detail("Version", commitVersion)
@ -195,7 +195,6 @@ ACTOR static Future<Void> applyClearRangeMutations(Standalone<VectorRef<KeyRange
ACTOR static Future<Void> getAndComputeStagingKeys(
std::map<Key, std::map<Key, StagingKey>::iterator> imcompleteStagingKeys, Database cx, UID applierID) {
state Reference<ReadYourWritesTransaction> tr(new ReadYourWritesTransaction(cx));
// state std::vector<std::pair<Key, Future<Optional<Value>>>> fKVs;
state std::vector<Future<Optional<Value>>> fValues;
state std::vector<Optional<Value>> values;
state int i = 0;
@ -207,8 +206,6 @@ ACTOR static Future<Void> getAndComputeStagingKeys(
tr->setOption(FDBTransactionOptions::ACCESS_SYSTEM_KEYS);
tr->setOption(FDBTransactionOptions::LOCK_AWARE);
for (auto& key : imcompleteStagingKeys) {
// fKVs.push_back(std::make_pair(key.first, tr->get(key.first)));
// fValues.push_back(fKVs.back().second);
fValues.push_back(tr->get(key.first));
}
for (i = 0; i < fValues.size(); i++) {
@ -227,7 +224,6 @@ ACTOR static Future<Void> getAndComputeStagingKeys(
}
ASSERT(values.size() == imcompleteStagingKeys.size());
// TODO: Optimize the performance by reducing map lookup: making getKey's future a field in the input map
int i = 0;
for (auto& key : imcompleteStagingKeys) {
if (!values[i].present()) {

View File

@ -43,6 +43,10 @@
Value applyAtomicOp(Optional<StringRef> existingValue, Value value, MutationRef::Type type);
// Key whose mutations are buffered on applier.
// key, value, type and version defines the parsed mutation at version.
// pendingMutations has all versioned mutations to be applied.
// Mutations in pendingMutations whose version is below the version in StagingKey can be ignored in applying phase.
struct StagingKey {
Key key; // TODO: Maybe not needed?
Value val;
@ -87,6 +91,7 @@ struct StagingKey {
} // else input mutation is old and can be ignored
}
// Precompute the final value of the key.
void precomputeResult() {
TraceEvent(SevDebug, "FastRestoreApplierPrecomputeResult")
.detail("Key", key)
@ -164,6 +169,8 @@ struct StagingKey {
int expectedMutationSize() { return key.size() + val.size(); }
};
// The range mutation received on applier.
// Range mutations should be applied both to the destination DB and to the StagingKeys
struct StagingKeyRange {
Standalone<MutationRef> mutation;
Version version;