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

Method byteSampleApplySet

fdbserver/storageserver.actor.cpp:9576–9615  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

9574}
9575
9576void StorageServer::byteSampleApplySet(KeyValueRef kv, Version ver) {
9577 // Update byteSample in memory and (eventually) on disk and notify waiting metrics
9578
9579 ByteSampleInfo sampleInfo = isKeyValueInSample(kv);
9580 auto& byteSample = metrics.byteSample.sample;
9581
9582 int64_t delta = 0;
9583 const KeyRef key = kv.key;
9584
9585 auto old = byteSample.find(key);
9586 if (old != byteSample.end())
9587 delta = -byteSample.getMetric(old);
9588 if (sampleInfo.inSample) {
9589 delta += sampleInfo.sampledSize;
9590 byteSample.insert(key, sampleInfo.sampledSize);
9591 addMutationToMutationLogOrStorage(ver,
9592 MutationRef(MutationRef::SetValue,
9593 key.withPrefix(persistByteSampleKeys.begin),
9594 BinaryWriter::toValue(sampleInfo.sampledSize, Unversioned())));
9595 } else {
9596 bool any = old != byteSample.end();
9597 if (!byteSampleRecovery.isReady()) {
9598 if (!byteSampleClears.rangeContaining(key).value()) {
9599 byteSampleClears.insert(key, true);
9600 byteSampleClearsTooLarge.set(byteSampleClears.size() > SERVER_KNOBS->MAX_BYTE_SAMPLE_CLEAR_MAP_SIZE);
9601 any = true;
9602 }
9603 }
9604 if (any) {
9605 byteSample.erase(old);
9606 auto diskRange = singleKeyRange(key.withPrefix(persistByteSampleKeys.begin));
9607 addMutationToMutationLogOrStorage(ver,
9608 MutationRef(MutationRef::ClearRange, diskRange.begin, diskRange.end));
9609 ++counters.kvSystemClearRanges;
9610 }
9611 }
9612
9613 if (delta)
9614 metrics.notifyBytes(key, delta);
9615}
9616
9617void StorageServer::byteSampleApplyClear(KeyRangeRef range, Version ver) {
9618 // Update byteSample in memory and (eventually) on disk via the mutationLog and notify waiting metrics

Calls 15

isKeyValueInSampleFunction · 0.85
MutationRefClass · 0.85
UnversionedFunction · 0.85
singleKeyRangeFunction · 0.85
rangeContainingMethod · 0.80
notifyBytesMethod · 0.80
setMethod · 0.65
findMethod · 0.45
endMethod · 0.45
getMetricMethod · 0.45
insertMethod · 0.45
withPrefixMethod · 0.45

Tested by

no test coverage detected