MCPcopy Create free account
hub / github.com/Snapchat/Valdi / populate

Method populate

valdi/src/valdi/runtime/Resources/KeyValueStore.cpp:240–273  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

238}
239
240Result<Void> KeyValueStore::populate(const BytesView& data) {
241 auto manifestParser = Parser<Byte>(nullptr, nullptr);
242
243 uint64_t idSequence = 0;
244
245 auto archive = ValdiArchive(data.begin(), data.end());
246 auto entries = archive.getEntries();
247 if (!entries) {
248 return entries.error();
249 }
250
251 for (const auto& entry : entries.value()) {
252 if (manifestParser.getBegin() == nullptr) {
253 auto manifestResult = parseManifest(entry, &idSequence);
254 if (!manifestResult) {
255 return manifestResult.error();
256 }
257
258 manifestParser = manifestResult.moveValue();
259 } else {
260 auto entryResult = parseEntry(manifestParser, entry, data.getSource());
261 if (!entryResult) {
262 return entryResult.error();
263 }
264
265 if (!isEntryExpired(entryResult.value())) {
266 _entries[entry.filePath] = entryResult.moveValue();
267 }
268 }
269 }
270
271 _mutationId = idSequence;
272 return Void();
273}
274
275uint64_t KeyValueStore::getMutationId() const {
276 return _mutationId;

Callers 1

TESTFunction · 0.45

Calls 10

ValdiArchiveClass · 0.85
parseManifestFunction · 0.85
parseEntryFunction · 0.85
getBeginMethod · 0.80
endMethod · 0.65
errorMethod · 0.65
valueMethod · 0.65
VoidClass · 0.50
beginMethod · 0.45
getEntriesMethod · 0.45

Tested by 1

TESTFunction · 0.36