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

Function isKeyValueInSample

fdbserver/storageserver.actor.cpp:9549–9565  ·  view source on GitHub ↗

Determines whether a key-value pair should be included in a byte sample Also returns size information about the sample

Source from the content-addressed store, hash-verified

9547// Determines whether a key-value pair should be included in a byte sample
9548// Also returns size information about the sample
9549ByteSampleInfo isKeyValueInSample(KeyValueRef keyValue) {
9550 ByteSampleInfo info;
9551
9552 const KeyRef key = keyValue.key;
9553 info.size = key.size() + keyValue.value.size();
9554
9555 uint32_t a = 0;
9556 uint32_t b = 0;
9557 hashlittle2(key.begin(), key.size(), &a, &b);
9558
9559 double probability =
9560 (double)info.size / (key.size() + SERVER_KNOBS->BYTE_SAMPLING_OVERHEAD) / SERVER_KNOBS->BYTE_SAMPLING_FACTOR;
9561 info.inSample = a / ((1 << 30) * 4.0) < probability;
9562 info.sampledSize = info.size / std::min(1.0, probability);
9563
9564 return info;
9565}
9566
9567void StorageServer::addMutationToMutationLogOrStorage(Version ver, MutationRef m) {
9568 if (ver != invalidVersion) {

Calls 3

hashlittle2Function · 0.85
sizeMethod · 0.45
beginMethod · 0.45

Tested by

no test coverage detected