| 9574 | } |
| 9575 | |
| 9576 | void 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 | |
| 9617 | void StorageServer::byteSampleApplyClear(KeyRangeRef range, Version ver) { |
| 9618 | // Update byteSample in memory and (eventually) on disk via the mutationLog and notify waiting metrics |
no test coverage detected