Merge from reading deltas
This commit is contained in:
@@ -170,7 +170,12 @@ bool CurrentVersionHasLabel(const Vertex &vertex, LabelId label, Transaction *tr
|
||||
deleted = vertex.deleted;
|
||||
has_label = utils::Contains(vertex.labels, label);
|
||||
delta = vertex.delta;
|
||||
|
||||
if (!vertex.label_changed) {
|
||||
return !deleted && has_label;
|
||||
}
|
||||
}
|
||||
|
||||
ApplyDeltasForRead(transaction, delta, view, [&deleted, &has_label, label](const Delta &delta) {
|
||||
switch (delta.action) {
|
||||
case Delta::Action::REMOVE_LABEL: {
|
||||
@@ -223,7 +228,12 @@ bool CurrentVersionHasLabelProperty(const Vertex &vertex, LabelId label, Propert
|
||||
has_label = utils::Contains(vertex.labels, label);
|
||||
current_value_equal_to_value = vertex.properties.IsPropertyEqual(key, value);
|
||||
delta = vertex.delta;
|
||||
|
||||
if (!vertex.label_changed && !vertex.property_changed) {
|
||||
return !deleted && has_label && current_value_equal_to_value;
|
||||
}
|
||||
}
|
||||
|
||||
ApplyDeltasForRead(transaction, delta, view,
|
||||
[&deleted, &has_label, ¤t_value_equal_to_value, key, label, &value](const Delta &delta) {
|
||||
switch (delta.action) {
|
||||
|
||||
@@ -1015,6 +1015,8 @@ void Storage::Accessor::Abort() {
|
||||
auto vertex = prev.vertex;
|
||||
std::lock_guard<utils::SpinLock> guard(vertex->lock);
|
||||
Delta *current = vertex->delta;
|
||||
vertex->label_changed = false;
|
||||
vertex->property_changed = false;
|
||||
while (current != nullptr && current->timestamp->load(std::memory_order_acquire) ==
|
||||
transaction_.transaction_id.load(std::memory_order_acquire)) {
|
||||
switch (current->action) {
|
||||
@@ -1551,6 +1553,8 @@ void Storage::CollectGarbage() {
|
||||
continue;
|
||||
}
|
||||
vertex->delta = nullptr;
|
||||
vertex->label_changed = false;
|
||||
vertex->property_changed = false;
|
||||
if (vertex->deleted) {
|
||||
current_deleted_vertices.push_back(vertex->gid);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2022 Memgraph Ltd.
|
||||
// Copyright 2023 Memgraph Ltd.
|
||||
//
|
||||
// Use of this software is governed by the Business Source License
|
||||
// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
|
||||
@@ -39,8 +39,9 @@ struct Vertex {
|
||||
|
||||
mutable utils::SpinLock lock;
|
||||
bool deleted;
|
||||
bool label_changed;
|
||||
bool property_changed;
|
||||
// uint8_t PAD;
|
||||
// uint16_t PAD;
|
||||
|
||||
Delta *delta;
|
||||
};
|
||||
|
||||
@@ -85,6 +85,7 @@ Result<bool> VertexAccessor::AddLabel(LabelId label) {
|
||||
if (std::find(vertex_->labels.begin(), vertex_->labels.end(), label) != vertex_->labels.end()) return false;
|
||||
|
||||
CreateAndLinkDelta(transaction_, vertex_, Delta::RemoveLabelTag(), label);
|
||||
vertex_->label_changed = true;
|
||||
|
||||
vertex_->labels.push_back(label);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user