update special-key-space comments
This commit is contained in:
parent
4a13107805
commit
2b84c3224f
|
@ -45,7 +45,7 @@ ACTOR Future<Void> moveKeySelectorOverRangeActor(const SpecialKeyRangeBaseImpl*
|
||||||
|
|
||||||
if (ks->offset < 1) {
|
if (ks->offset < 1) {
|
||||||
// less than the given key
|
// 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 {
|
} else {
|
||||||
// greater than the given key
|
// greater than the given key
|
||||||
if (skrImpl->getKeyRange().contains(ks->getKey())) startKey = ks->getKey();
|
if (skrImpl->getKeyRange().contains(ks->getKey())) startKey = ks->getKey();
|
||||||
|
@ -141,16 +141,11 @@ ACTOR Future<Standalone<RangeResultRef>> SpecialKeySpace::checkModuleFound(Speci
|
||||||
GetRangeLimits limits, bool reverse) {
|
GetRangeLimits limits, bool reverse) {
|
||||||
std::pair<Standalone<RangeResultRef>, Optional<SpecialKeySpace::MODULE>> result =
|
std::pair<Standalone<RangeResultRef>, Optional<SpecialKeySpace::MODULE>> result =
|
||||||
wait(SpecialKeySpace::getRangeAggregationActor(sks, ryw, begin, end, limits, reverse));
|
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()) {
|
if (ryw && !ryw->specialKeySpaceRelaxed()) {
|
||||||
auto module = result.second;
|
auto module = result.second;
|
||||||
if (!module.present()) {
|
if (!module.present()) {
|
||||||
throw special_keys_no_module_found();
|
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;
|
return result.first;
|
||||||
}
|
}
|
||||||
|
@ -249,10 +244,10 @@ Future<Standalone<RangeResultRef>> SpecialKeySpace::getRange(Reference<ReadYourW
|
||||||
begin.removeOrEqual(begin.arena());
|
begin.removeOrEqual(begin.arena());
|
||||||
end.removeOrEqual(end.arena());
|
end.removeOrEqual(end.arena());
|
||||||
|
|
||||||
// if( begin.offset >= end.offset && begin.getKey() >= end.getKey() ) {
|
if( begin.offset >= end.offset && begin.getKey() >= end.getKey() ) {
|
||||||
// TEST(true); // RYW range inverted
|
TEST(true); // range inverted
|
||||||
// return Standalone<RangeResultRef>();
|
return Standalone<RangeResultRef>();
|
||||||
// }
|
}
|
||||||
|
|
||||||
return checkModuleFound(this, ryw, begin, end, limits, reverse);
|
return checkModuleFound(this, ryw, begin, end, limits, reverse);
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,22 +66,26 @@ public:
|
||||||
Future<Standalone<RangeResultRef>> getRange(Reference<ReadYourWritesTransaction> ryw, KeySelector begin,
|
Future<Standalone<RangeResultRef>> getRange(Reference<ReadYourWritesTransaction> ryw, KeySelector begin,
|
||||||
KeySelector end, GetRangeLimits limits, bool reverse = false);
|
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()
|
// Default value is nullptr, begin of KeyRangeMap is Key()
|
||||||
impls = KeyRangeMap<SpecialKeyRangeBaseImpl*>(nullptr, spaceEndKey);
|
impls = KeyRangeMap<SpecialKeyRangeBaseImpl*>(nullptr, spaceEndKey);
|
||||||
range = KeyRangeRef(spaceStartKey, spaceEndKey);
|
range = KeyRangeRef(spaceStartKey, spaceEndKey);
|
||||||
modules = KeyRangeMap<SpecialKeySpace::MODULE>(SpecialKeySpace::MODULE::UNKNOWN, 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
|
// TODO : Handle testonly here
|
||||||
}
|
}
|
||||||
|
// Initialize module boundaries, used to handle cross_module_read
|
||||||
void modulesBoundaryInit() {
|
void modulesBoundaryInit() {
|
||||||
for (const auto& pair : moduleToBoundary) {
|
for (const auto& pair : moduleToBoundary) {
|
||||||
ASSERT(range.contains(pair.second));
|
ASSERT(range.contains(pair.second));
|
||||||
// Make sure the module is not overlapping with any registered modules
|
// 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) &&
|
ASSERT(modules.rangeContaining(pair.second.begin) == modules.rangeContaining(pair.second.end) &&
|
||||||
modules[pair.second.begin] == SpecialKeySpace::MODULE::UNKNOWN);
|
modules[pair.second.begin] == SpecialKeySpace::MODULE::UNKNOWN);
|
||||||
modules.insert(pair.second, pair.first);
|
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) {
|
void registerKeyRange(SpecialKeySpace::MODULE module, const KeyRangeRef& kr, SpecialKeyRangeBaseImpl* impl) {
|
||||||
|
@ -90,10 +94,10 @@ public:
|
||||||
ASSERT(range.contains(kr));
|
ASSERT(range.contains(kr));
|
||||||
// make sure the registered range is not overlapping with existing ones
|
// 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
|
// 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) {
|
for (auto iter = impls.rangeContaining(kr.begin); true; ++iter) {
|
||||||
ASSERT(iter->value() == nullptr);
|
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);
|
impls.insert(kr, impl);
|
||||||
// Set module for the range
|
// Set module for the range
|
||||||
|
|
Loading…
Reference in New Issue