Determines whether a key-value pair should be included in a byte sample Also returns size information about the sample
| 9547 | // Determines whether a key-value pair should be included in a byte sample |
| 9548 | // Also returns size information about the sample |
| 9549 | ByteSampleInfo 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 | |
| 9567 | void StorageServer::addMutationToMutationLogOrStorage(Version ver, MutationRef m) { |
| 9568 | if (ver != invalidVersion) { |
no test coverage detected