1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69
| DT_TEMPLATE void DT_CLASS::addDelete(const UInt64 rid) { checkId(rid);
EntryIterator leaf_end(this->end()); auto it = findRightLeaf<true>(rid); seekLeftId<true>(it, rid);
bool has_delete = false; while (it != leaf_end && it.getRid() == rid && it.isDelete()) { has_delete = true; ++it; }
bool has_insert = it != leaf_end && it.getRid() == rid && it.isInsert(); if (has_insert) {
--num_entries; --num_inserts;
auto leaf = it.getLeaf(); auto pos = it.getPos(); auto value = it.getValue();
insert_value_space->removeFromInsert(value); leaf->shiftEntries(pos + 1, -1); --(leaf->count); } else if (has_delete) {
++num_deletes;
--it;
auto leaf = it.getLeaf(); auto pos = it.getPos();
leaf->mutations[pos].setCount(leaf->mutations[pos].count() + 1); } else { ++num_deletes; ++num_entries;
auto leaf = it.getLeaf(); auto pos = it.getPos(); auto delta = it.getDelta();
leaf->shiftEntries(pos, 1); leaf->sids[pos] = checkId(rid - delta); leaf->mutations[pos] = DTMutation( false, 1, 0); ++(leaf->count); }
afterLeafUpdated(it.getLeaf());
if (unlikely(!isRootOnly() && !it.getLeaf()->legal())) throw Exception("Illegal leaf state: " + it.getLeaf()->state()); }
|