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

Method addConflictRange

fdbclient/WriteMap.cpp:244–303  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

242}
243
244void WriteMap::addConflictRange(KeyRangeRef keys) {
245 writeMapEmpty = false;
246 auto& it = scratch_iterator;
247 it.reset(writes, ver);
248 it.skip(keys.begin);
249
250 std::vector<ExtStringRef> removals;
251 std::vector<WriteMapEntry> insertions;
252
253 if (!it.entry().following_keys_conflict || !it.entry().is_conflict) {
254 if (it.keyAtBegin() && it.beginKey() == keys.begin) {
255 removals.push_back(keys.begin);
256 }
257 insertions.push_back(WriteMapEntry(keys.begin,
258 it.is_operation() ? OperationStack(it.op()) : OperationStack(),
259 it.entry().following_keys_cleared,
260 true,
261 true,
262 it.entry().following_keys_unreadable,
263 it.entry().is_unreadable));
264 }
265
266 while (it.endKey() < keys.end) {
267 ++it;
268 if (it.keyAtBegin() && (!it.entry().following_keys_conflict || !it.entry().is_conflict)) {
269 WriteMapEntry e(it.entry());
270 e.following_keys_conflict = true;
271 e.is_conflict = true;
272 removals.push_back(e.key);
273 insertions.push_back(std::move(e));
274 }
275 }
276
277 ASSERT(it.beginKey() != keys.end);
278 if (!it.entry().following_keys_conflict || !it.entry().is_conflict) {
279 bool isCleared = it.entry().following_keys_cleared;
280 bool isUnreadable = it.entry().is_unreadable;
281 bool followingUnreadable = it.entry().following_keys_unreadable;
282 ++it;
283
284 if (!it.keyAtBegin() || it.beginKey() != keys.end) {
285 insertions.push_back(
286 WriteMapEntry(keys.end, OperationStack(), isCleared, false, false, followingUnreadable, isUnreadable));
287 }
288 }
289
290 it.tree.clear();
291
292 // SOMEDAY: optimize this code by having a PTree removal/insertion that takes and returns an iterator
293 for (int i = 0; i < removals.size(); i++) {
294 PTreeImpl::remove(
295 writes,
296 ver,
297 removals[i]); // FIXME: Make PTreeImpl::insert do this automatically (see also VersionedMap.h FIXME)
298 }
299
300 for (int i = 0; i < insertions.size(); i++) {
301 PTreeImpl::insert(writes, ver, std::move(insertions[i]));

Callers 1

RYWIterator.cppFile · 0.45

Calls 15

WriteMapEntryClass · 0.85
OperationStackClass · 0.85
moveFunction · 0.85
insertFunction · 0.85
keyAtBeginMethod · 0.80
is_operationMethod · 0.80
clearMethod · 0.65
removeFunction · 0.50
resetMethod · 0.45
skipMethod · 0.45
entryMethod · 0.45
beginKeyMethod · 0.45

Tested by

no test coverage detected