MCPcopy Create free account
hub / github.com/FoundationDB/fdb-document-layer / replacementActor

Method replacementActor

src/ExtMsg.actor.cpp:1364–1392  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1362 std::string describe() override { return "ReplaceWith(" + replaceWith.toString() + ")"; }
1363
1364 ACTOR static Future<Void> replacementActor(ExtReplaceUpdate* self, Reference<IReadWriteContext> document) {
1365 state Standalone<StringRef> keyEncodedId = wait(document->getKeyEncodedId());
1366 Optional<IdInfo> encodedIds = extractEncodedIds(self->replaceWith);
1367 if (encodedIds.present() && encodedIds.get().keyEncoded != keyEncodedId) {
1368 throw replace_with_id();
1369 }
1370
1371 Optional<DataValue> iddv2 =
1372 wait(document->get(DataValue(DocLayerConstants::ID_FIELD, DVTypeCode::STRING).encode_key_part()));
1373 document->clearDescendants();
1374
1375 if (iddv2.get().getBSONType() == bson::BSONType::Object) {
1376 DataValue iddv = DataValue::decode_key_part(keyEncodedId);
1377 if (iddv.getBSONType() == bson::BSONType::Object) {
1378 insertElementRecursive(iddv.wrap(DocLayerConstants::ID_FIELD).getField(DocLayerConstants::ID_FIELD),
1379 document);
1380 }
1381 } else {
1382 document->set(DataValue(DocLayerConstants::ID_FIELD, DVTypeCode::STRING).encode_key_part(),
1383 iddv2.get().encode_value());
1384 }
1385
1386 for (auto i = self->replaceWith.begin(); i.more();) {
1387 auto e = i.next();
1388 insertElementRecursive(e, document);
1389 }
1390 document->set(StringRef(), DataValue::subObject().encode_value());
1391 return Void();
1392 }
1393};
1394
1395struct ExtOperatorUpsert : ConcreteInsertOp<ExtOperatorUpsert> {

Callers

nothing calls this directly

Calls 12

extractEncodedIdsFunction · 0.85
DataValueClass · 0.85
insertElementRecursiveFunction · 0.85
encode_key_partMethod · 0.80
getBSONTypeMethod · 0.80
wrapMethod · 0.80
encode_valueMethod · 0.80
beginMethod · 0.80
getKeyEncodedIdMethod · 0.45
getMethod · 0.45
clearDescendantsMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected