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

Method addWriteConflictRange

fdbclient/NativeAPI.actor.cpp:5717–5742  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5715 t.write_conflict_ranges.emplace_back(req.arena, KeyRef(data, key.size()), KeyRef(data, key.size() + 1));
5716}
5717void Transaction::addWriteConflictRange(const KeyRangeRef& keys) {
5718 ASSERT(!keys.empty());
5719 auto& req = tr;
5720 auto& t = req.transaction;
5721
5722 // There aren't any keys in the database with size larger than the max key size, so if range contains large keys
5723 // we can translate it to an equivalent one with smaller keys
5724 KeyRef begin = keys.begin;
5725 KeyRef end = keys.end;
5726
5727 int64_t beginMaxSize = getMaxKeySize(begin);
5728 int64_t endMaxSize = getMaxKeySize(end);
5729 if (begin.size() > beginMaxSize) {
5730 begin = begin.substr(0, beginMaxSize + 1);
5731 }
5732 if (end.size() > endMaxSize) {
5733 end = end.substr(0, endMaxSize + 1);
5734 }
5735 KeyRangeRef r = KeyRangeRef(begin, end);
5736
5737 if (r.empty()) {
5738 return;
5739 }
5740
5741 t.write_conflict_ranges.push_back_deep(req.arena, r);
5742}
5743
5744double Transaction::getBackoff(int errCode) {
5745 double returnedBackoff = backoff;

Callers

nothing calls this directly

Calls 6

getMaxKeySizeFunction · 0.85
substrMethod · 0.80
KeyRangeRefClass · 0.50
emptyMethod · 0.45
sizeMethod · 0.45
push_back_deepMethod · 0.45

Tested by

no test coverage detected