Reformat SpecialKeyRangeBaseImpl constructor

This commit is contained in:
chaoguang 2020-04-14 09:10:40 -07:00
parent ffc8b60bf8
commit ae1de060c2
4 changed files with 12 additions and 14 deletions

View File

@ -539,7 +539,7 @@ DatabaseContext::DatabaseContext(Reference<AsyncVar<Reference<ClusterConnectionF
commitLatencies(1000), GRVLatencies(1000), mutationsPerCommit(1000), bytesPerCommit(1000), mvCacheInsertLocation(0),
healthMetricsLastUpdated(0), detailedHealthMetricsLastUpdated(0), internal(internal),
specialKeySpace(std::make_shared<SpecialKeySpace>(normalKeys.begin, specialKeys.end)),
cKImpl(std::make_shared<ConflictingKeysImpl>(conflictingKeysRange.begin, conflictingKeysRange.end)) {
cKImpl(std::make_shared<ConflictingKeysImpl>(conflictingKeysRange)) {
dbId = deterministicRandom()->randomUniqueID();
connected = clientInfo->get().proxies.size() ? Void() : clientInfo->onChange();

View File

@ -243,7 +243,7 @@ Future<Optional<Value>> SpecialKeySpace::get(Reference<ReadYourWritesTransaction
return getActor(this, ryw, key);
}
ConflictingKeysImpl::ConflictingKeysImpl(KeyRef start, KeyRef end) : SpecialKeyRangeBaseImpl(start, end) {}
ConflictingKeysImpl::ConflictingKeysImpl(KeyRangeRef kr) : SpecialKeyRangeBaseImpl(kr) {}
Future<Standalone<RangeResultRef>> ConflictingKeysImpl::getRange(Reference<ReadYourWritesTransaction> ryw,
KeyRangeRef kr) const {
@ -267,8 +267,8 @@ Future<Standalone<RangeResultRef>> ConflictingKeysImpl::getRange(Reference<ReadY
class SpecialKeyRangeTestImpl : public SpecialKeyRangeBaseImpl {
public:
explicit SpecialKeyRangeTestImpl(KeyRef start, KeyRef end, const std::string& prefix, int size)
: SpecialKeyRangeBaseImpl(start, end), prefix(prefix), size(size) {
explicit SpecialKeyRangeTestImpl(KeyRangeRef kr, const std::string& prefix, int size)
: SpecialKeyRangeBaseImpl(kr), prefix(prefix), size(size) {
ASSERT(size > 0);
for (int i = 0; i < size; ++i) {
kvs.push_back_deep(kvs.arena(),
@ -299,9 +299,9 @@ private:
TEST_CASE("/fdbclient/SpecialKeySpace/Unittest") {
SpecialKeySpace pks(normalKeys.begin, normalKeys.end);
SpecialKeyRangeTestImpl pkr1(LiteralStringRef("/cat/"), LiteralStringRef("/cat/\xff"), "small", 10);
SpecialKeyRangeTestImpl pkr2(LiteralStringRef("/dog/"), LiteralStringRef("/dog/\xff"), "medium", 100);
SpecialKeyRangeTestImpl pkr3(LiteralStringRef("/pig/"), LiteralStringRef("/pig/\xff"), "large", 1000);
SpecialKeyRangeTestImpl pkr1(KeyRangeRef(LiteralStringRef("/cat/"), LiteralStringRef("/cat/\xff")), "small", 10);
SpecialKeyRangeTestImpl pkr2(KeyRangeRef(LiteralStringRef("/dog/"), LiteralStringRef("/dog/\xff")), "medium", 100);
SpecialKeyRangeTestImpl pkr3(KeyRangeRef(LiteralStringRef("/pig/"), LiteralStringRef("/pig/\xff")), "large", 1000);
pks.registerKeyRange(pkr1.getKeyRange(), &pkr1);
pks.registerKeyRange(pkr2.getKeyRange(), &pkr2);
pks.registerKeyRange(pkr3.getKeyRange(), &pkr3);
@ -374,4 +374,4 @@ TEST_CASE("/fdbclient/SpecialKeySpace/Unittest") {
ASSERT(result[i + pkr3.getSize()] == pkr2.getKeyValueForIndex(pkr2.getSize() - 1 - i));
}
return Void();
}
}

View File

@ -39,9 +39,7 @@ public:
virtual Future<Standalone<RangeResultRef>> getRange(Reference<ReadYourWritesTransaction> ryw,
KeyRangeRef kr) const = 0;
explicit SpecialKeyRangeBaseImpl(KeyRef start, KeyRef end) {
range = KeyRangeRef(range.arena(), KeyRangeRef(start, end));
}
explicit SpecialKeyRangeBaseImpl(KeyRangeRef kr) : range(kr) {}
KeyRangeRef getKeyRange() const { return range; }
ACTOR Future<Void> normalizeKeySelectorActor(const SpecialKeyRangeBaseImpl* pkrImpl,
Reference<ReadYourWritesTransaction> ryw, KeySelector* ks);
@ -92,7 +90,7 @@ private:
// Currently, the conflicting keyranges returned are original read_conflict_ranges or union of them.
class ConflictingKeysImpl : public SpecialKeyRangeBaseImpl {
public:
explicit ConflictingKeysImpl(KeyRef start, KeyRef end);
explicit ConflictingKeysImpl(KeyRangeRef kr);
Future<Standalone<RangeResultRef>> getRange(Reference<ReadYourWritesTransaction> ryw,
KeyRangeRef kr) const override;
};

View File

@ -27,7 +27,7 @@
class SKSCTestImpl : public SpecialKeyRangeBaseImpl {
public:
explicit SKSCTestImpl(KeyRef start, KeyRef end) : SpecialKeyRangeBaseImpl(start, end) {}
explicit SKSCTestImpl(KeyRangeRef kr) : SpecialKeyRangeBaseImpl(kr) {}
virtual Future<Standalone<RangeResultRef>> getRange(Reference<ReadYourWritesTransaction> ryw,
KeyRangeRef kr) const {
ASSERT(range.contains(kr));
@ -82,7 +82,7 @@ struct SpecialKeySpaceCorrectnessWorkload : TestWorkload {
Key startKey(baseKey + "/");
Key endKey(baseKey + "/\xff");
self->keys.push_back_deep(self->keys.arena(), KeyRangeRef(startKey, endKey));
self->impls.push_back(std::make_shared<SKSCTestImpl>(startKey, endKey));
self->impls.push_back(std::make_shared<SKSCTestImpl>(KeyRangeRef(startKey, endKey)));
// Although there are already ranges registered, the testing range will replace them
cx->specialKeySpace->registerKeyRange(self->keys.back(), self->impls.back().get());
// generate keys in each key range