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

Function keyBetween

fdbclient/FDBTypes.cpp:25–41  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

23#include "fdbclient/NativeAPI.actor.h"
24
25KeyRef keyBetween(const KeyRangeRef& keys) {
26 int pos = 0; // will be the position of the first difference between keys.begin and keys.end
27 int minSize = std::min(keys.begin.size(), keys.end.size());
28 for (; pos < minSize && pos < CLIENT_KNOBS->SPLIT_KEY_SIZE_LIMIT; pos++) {
29 if (keys.begin[pos] != keys.end[pos]) {
30 return keys.end.substr(0, pos + 1);
31 }
32 }
33
34 // If one more character keeps us in the limit, and the latter key is simply
35 // longer, then we only need one more byte of the end string.
36 if (pos < CLIENT_KNOBS->SPLIT_KEY_SIZE_LIMIT && keys.begin.size() < keys.end.size()) {
37 return keys.end.substr(0, pos + 1);
38 }
39
40 return keys.end;
41}
42
43void KeySelectorRef::setKey(KeyRef const& key) {
44 // There are no keys in the database with size greater than the max key size, so if this key selector has a key

Callers 2

splitEstimateMethod · 0.85

Calls 2

substrMethod · 0.80
sizeMethod · 0.45

Tested by 1