mirror of
https://github.com/apple/foundationdb.git
synced 2025-05-15 02:18:39 +08:00
Return keys from range read in lexicographic order
This commit is contained in:
parent
3669615e4b
commit
76142549e0
@ -948,12 +948,12 @@ DatabaseContext::DatabaseContext(Reference<AsyncVar<Reference<ClusterConnectionF
|
||||
.withPrefix(SpecialKeySpace::getModuleRange(SpecialKeySpace::MODULE::MANAGEMENT).begin)));
|
||||
registerSpecialKeySpaceModule(
|
||||
SpecialKeySpace::MODULE::TRACING, SpecialKeySpace::IMPLTYPE::READWRITE,
|
||||
std::make_unique<TracingOptionsImpl>(
|
||||
SpecialKeySpace::getModuleRange(SpecialKeySpace::MODULE::TRACING)));
|
||||
// Uncomment this and communt out the above instantiation of TracingOptionsImpl successfully read from \xff\xff/tracing/test/
|
||||
// std::make_unique<TracingOptionsImpl>(
|
||||
// KeyRangeRef(LiteralStringRef("test/"), LiteralStringRef("test0"))
|
||||
// .withPrefix(SpecialKeySpace::getModuleRange(SpecialKeySpace::MODULE::TRACING).begin)));
|
||||
// SpecialKeySpace::getModuleRange(SpecialKeySpace::MODULE::TRACING)));
|
||||
// TODO: Temporary fix for an issue with special-key top level ranges.
|
||||
std::make_unique<TracingOptionsImpl>(
|
||||
KeyRangeRef(LiteralStringRef("a/"), LiteralStringRef("a0"))
|
||||
.withPrefix(SpecialKeySpace::getModuleRange(SpecialKeySpace::MODULE::TRACING).begin)));
|
||||
}
|
||||
if (apiVersionAtLeast(630)) {
|
||||
registerSpecialKeySpaceModule(SpecialKeySpace::MODULE::TRANSACTION, SpecialKeySpace::IMPLTYPE::READONLY,
|
||||
|
@ -60,6 +60,8 @@ std::unordered_map<std::string, KeyRange> SpecialKeySpace::managementApiCommandT
|
||||
|
||||
std::set<std::string> SpecialKeySpace::options = { "excluded/force", "failed/force" };
|
||||
|
||||
std::set<std::string> SpecialKeySpace::tracingOptions = { kTracingTransactionIdKey, kTracingTokenKey };
|
||||
|
||||
Standalone<RangeResultRef> rywGetRange(ReadYourWritesTransaction* ryw, const KeyRangeRef& kr,
|
||||
const Standalone<RangeResultRef>& res);
|
||||
|
||||
@ -1278,11 +1280,17 @@ TracingOptionsImpl::TracingOptionsImpl(KeyRangeRef kr) : SpecialKeyRangeRWImpl(k
|
||||
Future<Standalone<RangeResultRef>> TracingOptionsImpl::getRange(ReadYourWritesTransaction* ryw,
|
||||
KeyRangeRef kr) const {
|
||||
Standalone<RangeResultRef> result;
|
||||
if (kr.contains(getKeyRange().begin.withSuffix(kTracingTransactionIdKey))) {
|
||||
result.push_back_deep(result.arena(), KeyValueRef(kr.begin, std::to_string(ryw->getTransactionInfo().spanID.first())));
|
||||
for (const auto& option : SpecialKeySpace::getTracingOptions()) {
|
||||
auto key = getKeyRange().begin.withSuffix(option);
|
||||
if (!kr.contains(key)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (key.endsWith(kTracingTransactionIdKey)) {
|
||||
result.push_back_deep(result.arena(), KeyValueRef(key, std::to_string(ryw->getTransactionInfo().spanID.first())));
|
||||
} else if (key.endsWith(kTracingTokenKey)) {
|
||||
result.push_back_deep(result.arena(), KeyValueRef(key, std::to_string(ryw->getTransactionInfo().spanID.second())));
|
||||
}
|
||||
if (kr.contains(getKeyRange().begin.withSuffix(kTracingTokenKey))) {
|
||||
result.push_back_deep(result.arena(), KeyValueRef(kr.begin, std::to_string(ryw->getTransactionInfo().spanID.second())));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
@ -191,6 +191,7 @@ public:
|
||||
}
|
||||
static Key getManagementApiCommandOptionSpecialKey(const std::string& command, const std::string& option);
|
||||
static const std::set<std::string>& getManagementApiOptionsSet() { return options; }
|
||||
static const std::set<std::string>& getTracingOptions() { return tracingOptions; }
|
||||
|
||||
private:
|
||||
ACTOR static Future<Optional<Value>> getActor(SpecialKeySpace* sks, ReadYourWritesTransaction* ryw, KeyRef key);
|
||||
@ -212,6 +213,7 @@ private:
|
||||
static std::unordered_map<std::string, KeyRange>
|
||||
managementApiCommandToRange; // management command to its special keys' range
|
||||
static std::set<std::string> options; // "<command>/<option>"
|
||||
static std::set<std::string> tracingOptions;
|
||||
|
||||
// Initialize module boundaries, used to handle cross_module_read
|
||||
void modulesBoundaryInit();
|
||||
|
Loading…
x
Reference in New Issue
Block a user