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

Function decodeMutationLogValue

fdbclient/FileBackupAgent.actor.cpp:3267–3300  ·  view source on GitHub ↗

Decodes an encoded list of mutations in the format of: [includeVersion:uint64_t][val_length:uint32_t][mutation_1][mutation_2]...[mutation_k], where a mutation is encoded as: [type:uint32_t][keyLength:uint32_t][valueLength:uint32_t][param1][param2]

Source from the content-addressed store, hash-verified

3265// where a mutation is encoded as:
3266// [type:uint32_t][keyLength:uint32_t][valueLength:uint32_t][param1][param2]
3267std::vector<MutationRef> decodeMutationLogValue(const StringRef& value) {
3268 StringRefReader reader(value, restore_corrupted_data());
3269
3270 Version protocolVersion = reader.consume<uint64_t>();
3271 if (protocolVersion <= 0x0FDB00A200090001) {
3272 throw incompatible_protocol_version();
3273 }
3274
3275 uint32_t val_length = reader.consume<uint32_t>();
3276 if (val_length != value.size() - sizeof(uint64_t) - sizeof(uint32_t)) {
3277 TraceEvent(SevError, "FileRestoreLogValueError")
3278 .detail("ValueLen", val_length)
3279 .detail("ValueSize", value.size())
3280 .detail("Value", printable(value));
3281 }
3282
3283 std::vector<MutationRef> mutations;
3284 while (1) {
3285 if (reader.eof())
3286 break;
3287
3288 // Deserialization of a MutationRef, which was packed by MutationListRef::push_back_deep()
3289 uint32_t type, p1len, p2len;
3290 type = reader.consume<uint32_t>();
3291 p1len = reader.consume<uint32_t>();
3292 p2len = reader.consume<uint32_t>();
3293
3294 const uint8_t* key = reader.consume(p1len);
3295 const uint8_t* val = reader.consume(p2len);
3296
3297 mutations.emplace_back((MutationRef::Type)type, StringRef(key, p1len), StringRef(val, p2len));
3298 }
3299 return mutations;
3300}
3301
3302void AccumulatedMutations::addChunk(int chunkNumber, const KeyValueRef& kv) {
3303 if (chunkNumber == lastChunkNumber + 1) {

Callers 2

getNextBatchMethod · 0.85
matchesAnyRangeMethod · 0.85

Calls 8

TraceEventClass · 0.85
detailMethod · 0.80
eofMethod · 0.80
emplace_backMethod · 0.80
printableFunction · 0.70
StringRefClass · 0.50
sizeMethod · 0.45
consumeMethod · 0.45

Tested by

no test coverage detected