update special-key-space comments

This commit is contained in:
Chaoguang Lin 2020-05-14 23:49:57 -07:00
parent 4a13107805
commit 2b84c3224f
2 changed files with 15 additions and 16 deletions

View File

@ -45,7 +45,7 @@ ACTOR Future<Void> moveKeySelectorOverRangeActor(const SpecialKeyRangeBaseImpl*
if (ks->offset < 1) {
// less than the given key
if (skrImpl->getKeyRange().contains(ks->getKey())) endKey = ks->getKey(); // keyAfter(ks->getKey());
if (skrImpl->getKeyRange().contains(ks->getKey())) endKey = ks->getKey(); // TODO : add test for startKey equals endKey
} else {
// greater than the given key
if (skrImpl->getKeyRange().contains(ks->getKey())) startKey = ks->getKey();
@ -141,16 +141,11 @@ ACTOR Future<Standalone<RangeResultRef>> SpecialKeySpace::checkModuleFound(Speci
GetRangeLimits limits, bool reverse) {
std::pair<Standalone<RangeResultRef>, Optional<SpecialKeySpace::MODULE>> result =
wait(SpecialKeySpace::getRangeAggregationActor(sks, ryw, begin, end, limits, reverse));
// TODO : all cross_module_read or no_module_found error is better to check at the beginning, improve this later
if (ryw && !ryw->specialKeySpaceRelaxed()) {
auto module = result.second;
if (!module.present()) {
throw special_keys_no_module_found();
} /*else {
auto boundary = sks->moduleToBoundary.at(module.get());
if (!boundary.contains(begin.getKey()) || end.getKey() < boundary.begin || end.getKey() > boundary.end)
throw special_keys_cross_module_read();
}*/
}
}
return result.first;
}
@ -249,10 +244,10 @@ Future<Standalone<RangeResultRef>> SpecialKeySpace::getRange(Reference<ReadYourW
begin.removeOrEqual(begin.arena());
end.removeOrEqual(end.arena());
// if( begin.offset >= end.offset && begin.getKey() >= end.getKey() ) {
// TEST(true); // RYW range inverted
// return Standalone<RangeResultRef>();
// }
if( begin.offset >= end.offset && begin.getKey() >= end.getKey() ) {
TEST(true); // range inverted
return Standalone<RangeResultRef>();
}
return checkModuleFound(this, ryw, begin, end, limits, reverse);
}

View File

@ -66,22 +66,26 @@ public:
Future<Standalone<RangeResultRef>> getRange(Reference<ReadYourWritesTransaction> ryw, KeySelector begin,
KeySelector end, GetRangeLimits limits, bool reverse = false);
SpecialKeySpace(KeyRef spaceStartKey = Key(), KeyRef spaceEndKey = normalKeys.end, bool test = true) {
SpecialKeySpace(KeyRef spaceStartKey = Key(), KeyRef spaceEndKey = normalKeys.end, bool testOnly = true) {
// Default value is nullptr, begin of KeyRangeMap is Key()
impls = KeyRangeMap<SpecialKeyRangeBaseImpl*>(nullptr, spaceEndKey);
range = KeyRangeRef(spaceStartKey, spaceEndKey);
modules = KeyRangeMap<SpecialKeySpace::MODULE>(SpecialKeySpace::MODULE::UNKNOWN, spaceEndKey);
if (!test) modulesBoundaryInit();
if (!testOnly)
modulesBoundaryInit(); // testOnly is used in the correctness workload
// TODO : Handle testonly here
}
// Initialize module boundaries, used to handle cross_module_read
void modulesBoundaryInit() {
for (const auto& pair : moduleToBoundary) {
ASSERT(range.contains(pair.second));
// Make sure the module is not overlapping with any registered modules
// Note: same like ranges, one module's end cannot be another module's start, relax the condition if needed
ASSERT(modules.rangeContaining(pair.second.begin) == modules.rangeContaining(pair.second.end) &&
modules[pair.second.begin] == SpecialKeySpace::MODULE::UNKNOWN);
modules.insert(pair.second, pair.first);
impls.insert(pair.second, nullptr);
impls.insert(pair.second, nullptr); // Note: Due to underlying implementation, the insertion here is
// important to make cross_module_read being handled correctly
}
}
void registerKeyRange(SpecialKeySpace::MODULE module, const KeyRangeRef& kr, SpecialKeyRangeBaseImpl* impl) {
@ -90,10 +94,10 @@ public:
ASSERT(range.contains(kr));
// make sure the registered range is not overlapping with existing ones
// Note: kr.end should not be the same as another range's begin, although it should work even they are the same
// ASSERT(impls.rangeContaining(kr.begin) == impls.rangeContaining(kr.end) && impls[kr.begin] == nullptr);
for (auto iter = impls.rangeContaining(kr.begin); true; ++iter) {
ASSERT(iter->value() == nullptr);
if (iter == impls.rangeContaining(kr.end)) break; // relax the end to be another one's start if needed
if (iter == impls.rangeContaining(kr.end))
break; // relax the condition that the end can be another range's start, if needed
}
impls.insert(kr, impl);
// Set module for the range