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

Method get

fdbserver/KeyValueStoreSQLite.actor.cpp:1111–1142  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1109 };
1110
1111 Optional<Value> get(KeyRef key) {
1112 int r = moveTo(key);
1113 if (db.fragment_values) {
1114 // Optimization - moveTo seeks to fragment (key, 0) so if it was exactly found then we
1115 // know we have a single fragment for key and can return it.
1116 if (r == 0) {
1117 Value result;
1118 ((ValueRef&)result) = decodeKVFragment(getEncodedRow(result.arena())).get().value;
1119 kvBytesRead += key.size() + result.size();
1120 return result;
1121 }
1122
1123 // Otherwise see if the fragments immediately after (key, 0) are for the key we want.
1124 if (r < 0)
1125 moveNext();
1126 Arena m;
1127 DefragmentingReader i(*this, m, true);
1128 if (i.peek() == key) {
1129 Optional<KeyValueRef> kv = i.getNext();
1130 kvBytesRead += key.size() + kv.get().value.size();
1131 return Value(kv.get().value, m);
1132 }
1133 } else if (r == 0) {
1134 Value result;
1135 KeyValueRef kv = decodeKV(getEncodedRow(result.arena()));
1136 ((ValueRef&)result) = kv.value;
1137 kvBytesRead += key.size() + result.size();
1138 return result;
1139 }
1140
1141 return Optional<Value>();
1142 }
1143 Optional<Value> getPrefix(KeyRef key, int maxLength) {
1144 if (db.fragment_values) {
1145 int r = moveTo(key);

Callers

nothing calls this directly

Calls 9

moveToFunction · 0.85
decodeKVFragmentFunction · 0.85
moveNextFunction · 0.85
decodeKVFunction · 0.85
getMethod · 0.65
ValueEnum · 0.50
sizeMethod · 0.45
peekMethod · 0.45
getNextMethod · 0.45

Tested by

no test coverage detected