Clean-up of storage v2 delta
Reviewers: teon.banek Reviewed By: teon.banek Subscribers: pullbot Differential Revision: https://phabricator.memgraph.io/D2451
This commit is contained in:
parent
f63a5e9de5
commit
8c7c593680
@ -109,11 +109,11 @@ struct Delta {
|
|||||||
// Used for both Vertex and Edge
|
// Used for both Vertex and Edge
|
||||||
struct DeleteObjectTag {};
|
struct DeleteObjectTag {};
|
||||||
struct RecreateObjectTag {};
|
struct RecreateObjectTag {};
|
||||||
struct AddLabelTag {};
|
|
||||||
struct RemoveLabelTag {};
|
|
||||||
struct SetPropertyTag {};
|
struct SetPropertyTag {};
|
||||||
|
|
||||||
// Used only for Vertex
|
// Used only for Vertex
|
||||||
|
struct AddLabelTag {};
|
||||||
|
struct RemoveLabelTag {};
|
||||||
struct AddInEdgeTag {};
|
struct AddInEdgeTag {};
|
||||||
struct AddOutEdgeTag {};
|
struct AddOutEdgeTag {};
|
||||||
struct RemoveInEdgeTag {};
|
struct RemoveInEdgeTag {};
|
||||||
@ -179,43 +179,28 @@ struct Delta {
|
|||||||
command_id(command_id),
|
command_id(command_id),
|
||||||
vertex_edge({edge_type, vertex, edge}) {}
|
vertex_edge({edge_type, vertex, edge}) {}
|
||||||
|
|
||||||
Delta(Delta &&other) noexcept
|
Delta(const Delta &) = delete;
|
||||||
: action(other.action),
|
Delta(Delta &&) = delete;
|
||||||
timestamp(other.timestamp),
|
Delta &operator=(const Delta &) = delete;
|
||||||
command_id(other.command_id),
|
Delta &operator=(Delta &&) = delete;
|
||||||
prev(other.prev),
|
|
||||||
next(other.next.load()) {
|
~Delta() {
|
||||||
switch (other.action) {
|
switch (action) {
|
||||||
case Action::DELETE_OBJECT:
|
case Action::DELETE_OBJECT:
|
||||||
case Action::RECREATE_OBJECT:
|
case Action::RECREATE_OBJECT:
|
||||||
break;
|
|
||||||
case Action::ADD_LABEL:
|
case Action::ADD_LABEL:
|
||||||
case Action::REMOVE_LABEL:
|
case Action::REMOVE_LABEL:
|
||||||
label = other.label;
|
|
||||||
break;
|
|
||||||
case Action::SET_PROPERTY:
|
|
||||||
property.key = other.property.key;
|
|
||||||
new (&property.value) PropertyValue(std::move(other.property.value));
|
|
||||||
break;
|
|
||||||
case Action::ADD_IN_EDGE:
|
case Action::ADD_IN_EDGE:
|
||||||
case Action::ADD_OUT_EDGE:
|
case Action::ADD_OUT_EDGE:
|
||||||
case Action::REMOVE_IN_EDGE:
|
case Action::REMOVE_IN_EDGE:
|
||||||
case Action::REMOVE_OUT_EDGE:
|
case Action::REMOVE_OUT_EDGE:
|
||||||
vertex_edge = other.vertex_edge;
|
break;
|
||||||
|
case Action::SET_PROPERTY:
|
||||||
|
property.value.~PropertyValue();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// reset the action of other
|
|
||||||
other.DestroyValue();
|
|
||||||
other.action = Action::DELETE_OBJECT;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Delta(const Delta &) = delete;
|
|
||||||
Delta &operator=(const Delta &) = delete;
|
|
||||||
Delta &operator=(Delta &&other) = delete;
|
|
||||||
|
|
||||||
~Delta() { DestroyValue(); }
|
|
||||||
|
|
||||||
Action action;
|
Action action;
|
||||||
|
|
||||||
// TODO: optimize with in-place copy
|
// TODO: optimize with in-place copy
|
||||||
@ -236,24 +221,6 @@ struct Delta {
|
|||||||
EdgeRef edge;
|
EdgeRef edge;
|
||||||
} vertex_edge;
|
} vertex_edge;
|
||||||
};
|
};
|
||||||
|
|
||||||
private:
|
|
||||||
void DestroyValue() {
|
|
||||||
switch (action) {
|
|
||||||
case Action::DELETE_OBJECT:
|
|
||||||
case Action::RECREATE_OBJECT:
|
|
||||||
case Action::ADD_LABEL:
|
|
||||||
case Action::REMOVE_LABEL:
|
|
||||||
case Action::ADD_IN_EDGE:
|
|
||||||
case Action::ADD_OUT_EDGE:
|
|
||||||
case Action::REMOVE_IN_EDGE:
|
|
||||||
case Action::REMOVE_OUT_EDGE:
|
|
||||||
break;
|
|
||||||
case Action::SET_PROPERTY:
|
|
||||||
property.value.~PropertyValue();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static_assert(alignof(Delta) >= 8,
|
static_assert(alignof(Delta) >= 8,
|
||||||
|
Loading…
Reference in New Issue
Block a user