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

Method makeKey

fdbserver/workloads/FuzzApiCorrectness.actor.cpp:532–556  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

530 : id(id_), workload(wl), contract(func, std::bind(&BaseTest::augmentTrace, this, ph::_1)) {}
531
532 static Key makeKey() {
533 double ksrv = deterministicRandom()->random01();
534
535 // 25% of the time it's empty, 25% it's above range.
536 if (ksrv < 0.25)
537 return Key();
538
539 int64_t key_size;
540 if (ksrv < 0.5)
541 key_size = deterministicRandom()->randomInt64(1, CLIENT_KNOBS->KEY_SIZE_LIMIT + 1) +
542 CLIENT_KNOBS->KEY_SIZE_LIMIT;
543 else
544 key_size = deterministicRandom()->randomInt64(1, CLIENT_KNOBS->KEY_SIZE_LIMIT + 1);
545
546 std::string skey;
547 skey.reserve(key_size);
548 for (size_t j = 0; j < key_size; ++j)
549 skey.append(1, (char)deterministicRandom()->randomInt(0, 256));
550
551 // 15% (= 20% * 75%) of the time generating keys after \xff\xff to test special keys code
552 if (deterministicRandom()->random01() < 0.2)
553 return Key(skey).withPrefix(specialKeys.begin);
554 else
555 return Key(skey);
556 }
557
558 static Value makeValue() {
559 double vrv = deterministicRandom()->random01();

Callers

nothing calls this directly

Calls 8

deterministicRandomFunction · 0.85
random01Method · 0.80
randomInt64Method · 0.80
KeyClass · 0.50
reserveMethod · 0.45
appendMethod · 0.45
randomIntMethod · 0.45
withPrefixMethod · 0.45

Tested by

no test coverage detected