[StorageV2] Make delta list double linked
Summary: this is necessary for garbage collection Reviewers: teon.banek, mferencevic Reviewed By: mferencevic Subscribers: pullbot Differential Revision: https://phabricator.memgraph.io/D2156
This commit is contained in:
parent
a7fabe6109
commit
71c76cfb73
src/storage/v2
@ -17,6 +17,7 @@ struct Delta {
|
||||
value(value),
|
||||
timestamp(timestamp),
|
||||
command_id(command_id),
|
||||
prev(nullptr),
|
||||
next(nullptr) {}
|
||||
|
||||
Delta(Delta &&other) noexcept
|
||||
@ -24,6 +25,7 @@ struct Delta {
|
||||
value(other.value),
|
||||
timestamp(other.timestamp),
|
||||
command_id(other.command_id),
|
||||
prev(nullptr),
|
||||
next(other.next.load()) {}
|
||||
|
||||
Delta(const Delta &) = delete;
|
||||
@ -38,6 +40,7 @@ struct Delta {
|
||||
// TODO: optimize with in-place copy
|
||||
std::atomic<uint64_t> *timestamp;
|
||||
uint64_t command_id;
|
||||
Delta *prev;
|
||||
std::atomic<Delta *> next;
|
||||
};
|
||||
|
||||
|
@ -54,6 +54,9 @@ class VertexAccessor final {
|
||||
return Result<bool>{false};
|
||||
|
||||
auto delta = transaction_->CreateDelta(Delta::Action::REMOVE_LABEL, label);
|
||||
if (vertex_->delta) {
|
||||
vertex_->delta->prev = delta;
|
||||
}
|
||||
delta->next = vertex_->delta;
|
||||
vertex_->delta = delta;
|
||||
|
||||
@ -71,6 +74,9 @@ class VertexAccessor final {
|
||||
if (it == vertex_->labels.end()) return Result<bool>{false};
|
||||
|
||||
auto delta = transaction_->CreateDelta(Delta::Action::ADD_LABEL, label);
|
||||
if (vertex_->delta) {
|
||||
vertex_->delta->prev = delta;
|
||||
}
|
||||
delta->next = vertex_->delta;
|
||||
vertex_->delta = delta;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user