MCPcopy Create free account
hub / github.com/apple/foundationdb / getCachedLocation

Method getCachedLocation

fdbclient/NativeAPI.actor.cpp:1829–1853  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1827}
1828
1829Optional<KeyRangeLocationInfo> DatabaseContext::getCachedLocation(const Optional<TenantNameRef>& tenantName,
1830 const KeyRef& key,
1831 Reverse isBackward) {
1832 TenantMapEntry tenantEntry;
1833 Arena arena;
1834 KeyRef resolvedKey = key;
1835
1836 if (tenantName.present()) {
1837 auto itr = tenantCache.find(tenantName.get());
1838 if (itr != tenantCache.end()) {
1839 tenantEntry = itr->second;
1840 resolvedKey = resolvedKey.withPrefix(tenantEntry.prefix, arena);
1841 } else {
1842 return Optional<KeyRangeLocationInfo>();
1843 }
1844 }
1845
1846 auto range =
1847 isBackward ? locationCache.rangeContainingKeyBefore(resolvedKey) : locationCache.rangeContaining(resolvedKey);
1848 if (range->value()) {
1849 return KeyRangeLocationInfo(tenantEntry, toRelativeRange(range->range(), tenantEntry.prefix), range->value());
1850 }
1851
1852 return Optional<KeyRangeLocationInfo>();
1853}
1854
1855bool DatabaseContext::getCachedLocations(const Optional<TenantNameRef>& tenantName,
1856 const KeyRangeRef& range,

Calls 11

toRelativeRangeFunction · 0.85
rangeContainingMethod · 0.80
getMethod · 0.65
presentMethod · 0.45
findMethod · 0.45
endMethod · 0.45
withPrefixMethod · 0.45
valueMethod · 0.45
rangeMethod · 0.45

Tested by

no test coverage detected