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

Method range

fdbclient/Subspace.cpp:58–78  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

56}
57
58KeyRange Subspace::range(Tuple const& tuple) const {
59 VectorRef<uint8_t> begin;
60 VectorRef<uint8_t> end;
61
62 KeyRange keyRange;
63
64 begin.reserve(keyRange.arena(), rawPrefix.size() + tuple.pack().size() + 1);
65 begin.append(keyRange.arena(), rawPrefix.begin(), rawPrefix.size());
66 begin.append(keyRange.arena(), tuple.pack().begin(), tuple.pack().size());
67 begin.push_back(keyRange.arena(), uint8_t('\x00'));
68
69 end.reserve(keyRange.arena(), rawPrefix.size() + tuple.pack().size() + 1);
70 end.append(keyRange.arena(), rawPrefix.begin(), rawPrefix.size());
71 end.append(keyRange.arena(), tuple.pack().begin(), tuple.pack().size());
72 end.push_back(keyRange.arena(), uint8_t('\xff'));
73
74 // FIXME: test that this uses the keyRange arena and doesn't create another one
75 keyRange.KeyRangeRef::operator=(
76 KeyRangeRef(StringRef(begin.begin(), begin.size()), StringRef(end.begin(), end.size())));
77 return keyRange;
78}
79
80bool Subspace::contains(KeyRef const& key) const {
81 return key.startsWith(StringRef(rawPrefix.begin(), rawPrefix.size()));

Callers

nothing calls this directly

Calls 7

StringRefClass · 0.50
reserveMethod · 0.45
sizeMethod · 0.45
packMethod · 0.45
appendMethod · 0.45
beginMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected