PR changes
This commit is contained in:
@@ -255,14 +255,14 @@ inline mgp_edge *graph_create_edge(mgp_graph *graph, mgp_vertex *from, mgp_verte
|
||||
return MgInvoke<mgp_edge *>(mgp_graph_create_edge, graph, from, to, type, memory);
|
||||
}
|
||||
|
||||
inline mgp_edge *graph_change_edge_from(struct mgp_graph *graph, struct mgp_edge *e, struct mgp_vertex *new_from,
|
||||
mgp_memory *memory) {
|
||||
return MgInvoke<mgp_edge *>(mgp_graph_change_edge_from, graph, e, new_from, memory);
|
||||
inline mgp_edge *graph_edge_set_from(struct mgp_graph *graph, struct mgp_edge *e, struct mgp_vertex *new_from,
|
||||
mgp_memory *memory) {
|
||||
return MgInvoke<mgp_edge *>(mgp_graph_edge_set_from, graph, e, new_from, memory);
|
||||
}
|
||||
|
||||
inline mgp_edge *graph_change_edge_to(struct mgp_graph *graph, struct mgp_edge *e, struct mgp_vertex *new_to,
|
||||
mgp_memory *memory) {
|
||||
return MgInvoke<mgp_edge *>(mgp_graph_change_edge_to, graph, e, new_to, memory);
|
||||
inline mgp_edge *graph_edge_set_to(struct mgp_graph *graph, struct mgp_edge *e, struct mgp_vertex *new_to,
|
||||
mgp_memory *memory) {
|
||||
return MgInvoke<mgp_edge *>(mgp_graph_edge_set_to, graph, e, new_to, memory);
|
||||
}
|
||||
|
||||
inline void graph_delete_edge(mgp_graph *graph, mgp_edge *edge) { MgInvokeVoid(mgp_graph_delete_edge, graph, edge); }
|
||||
|
||||
@@ -887,16 +887,16 @@ enum mgp_error mgp_graph_create_edge(struct mgp_graph *graph, struct mgp_vertex
|
||||
/// Return mgp_error::MGP_ERROR_UNABLE_TO_ALLOCATE if unable to allocate a mgp_edge.
|
||||
/// Return mgp_error::MGP_ERROR_DELETED_OBJECT if `from` or `to` has been deleted.
|
||||
/// Return mgp_error::MGP_ERROR_SERIALIZATION_ERROR if `from` or `to` has been modified by another transaction.
|
||||
enum mgp_error mgp_graph_change_edge_from(struct mgp_graph *graph, struct mgp_edge *e, struct mgp_vertex *new_from,
|
||||
struct mgp_memory *memory, struct mgp_edge **result);
|
||||
enum mgp_error mgp_graph_edge_set_from(struct mgp_graph *graph, struct mgp_edge *e, struct mgp_vertex *new_from,
|
||||
struct mgp_memory *memory, struct mgp_edge **result);
|
||||
|
||||
/// Change edge to vertex
|
||||
/// Return mgp_error::MGP_ERROR_IMMUTABLE_OBJECT if `graph` is immutable.
|
||||
/// Return mgp_error::MGP_ERROR_UNABLE_TO_ALLOCATE if unable to allocate a mgp_edge.
|
||||
/// Return mgp_error::MGP_ERROR_DELETED_OBJECT if `from` or `to` has been deleted.
|
||||
/// Return mgp_error::MGP_ERROR_SERIALIZATION_ERROR if `from` or `to` has been modified by another transaction.
|
||||
enum mgp_error mgp_graph_change_edge_to(struct mgp_graph *graph, struct mgp_edge *e, struct mgp_vertex *new_to,
|
||||
struct mgp_memory *memory, struct mgp_edge **result);
|
||||
enum mgp_error mgp_graph_edge_set_to(struct mgp_graph *graph, struct mgp_edge *e, struct mgp_vertex *new_to,
|
||||
struct mgp_memory *memory, struct mgp_edge **result);
|
||||
|
||||
/// Delete an edge from the graph.
|
||||
/// Return mgp_error::MGP_ERROR_IMMUTABLE_OBJECT if `graph` is immutable.
|
||||
|
||||
@@ -251,9 +251,9 @@ class Graph {
|
||||
/// @brief Creates a relationship of type `type` between nodes `from` and `to` and adds it to the graph.
|
||||
Relationship CreateRelationship(const Node &from, const Node &to, const std::string_view type);
|
||||
/// @brief Changes a relationship from node.
|
||||
void ChangeRelationshipFrom(Relationship &relationship, const Node &new_from);
|
||||
void SetFrom(Relationship &relationship, const Node &new_from);
|
||||
/// @brief Changes a relationship to node.
|
||||
void ChangeRelationshipTo(Relationship &relationship, const Node &new_to);
|
||||
void SetTo(Relationship &relationship, const Node &new_to);
|
||||
/// @brief Deletes a relationship from the graph.
|
||||
void DeleteRelationship(const Relationship &relationship);
|
||||
|
||||
@@ -1989,14 +1989,14 @@ inline Relationship Graph::CreateRelationship(const Node &from, const Node &to,
|
||||
return relationship;
|
||||
}
|
||||
|
||||
inline void Graph::ChangeRelationshipFrom(Relationship &relationship, const Node &new_from) {
|
||||
mgp_edge *edge = mgp::MemHandlerCallback(mgp::graph_change_edge_from, graph_, relationship.ptr_, new_from.ptr_);
|
||||
inline void Graph::SetFrom(Relationship &relationship, const Node &new_from) {
|
||||
mgp_edge *edge = mgp::MemHandlerCallback(mgp::graph_edge_set_from, graph_, relationship.ptr_, new_from.ptr_);
|
||||
relationship = Relationship(edge);
|
||||
mgp::edge_destroy(edge);
|
||||
}
|
||||
|
||||
inline void Graph::ChangeRelationshipTo(Relationship &relationship, const Node &new_to) {
|
||||
mgp_edge *edge = mgp::MemHandlerCallback(mgp::graph_change_edge_to, graph_, relationship.ptr_, new_to.ptr_);
|
||||
inline void Graph::SetTo(Relationship &relationship, const Node &new_to) {
|
||||
mgp_edge *edge = mgp::MemHandlerCallback(mgp::graph_edge_set_to, graph_, relationship.ptr_, new_to.ptr_);
|
||||
relationship = Relationship(edge);
|
||||
mgp::edge_destroy(edge);
|
||||
}
|
||||
|
||||
@@ -76,21 +76,21 @@ SubgraphDbAccessor::DetachRemoveVertex( // NOLINT(readability-convert-member-fu
|
||||
"Vertex holds only partial information about edges. Cannot detach delete safely while using projected graph."};
|
||||
}
|
||||
|
||||
storage::Result<EdgeAccessor> SubgraphDbAccessor::ChangeEdgeFrom(EdgeAccessor *edge, SubgraphVertexAccessor *new_from) {
|
||||
storage::Result<EdgeAccessor> SubgraphDbAccessor::EdgeSetFrom(EdgeAccessor *edge, SubgraphVertexAccessor *new_from) {
|
||||
VertexAccessor *new_from_impl = &new_from->impl_;
|
||||
if (!this->graph_->ContainsVertex(*new_from_impl)) {
|
||||
throw std::logic_error{"Projected graph must contain the new from vertex!"};
|
||||
throw std::logic_error{"Projected graph must contain the new `from` vertex!"};
|
||||
}
|
||||
auto result = db_accessor_.ChangeEdgeFrom(edge, new_from_impl);
|
||||
auto result = db_accessor_.EdgeSetFrom(edge, new_from_impl);
|
||||
return result;
|
||||
}
|
||||
|
||||
storage::Result<EdgeAccessor> SubgraphDbAccessor::ChangeEdgeTo(EdgeAccessor *edge, SubgraphVertexAccessor *new_to) {
|
||||
storage::Result<EdgeAccessor> SubgraphDbAccessor::EdgeSetTo(EdgeAccessor *edge, SubgraphVertexAccessor *new_to) {
|
||||
VertexAccessor *new_to_impl = &new_to->impl_;
|
||||
if (!this->graph_->ContainsVertex(*new_to_impl)) {
|
||||
throw std::logic_error{"Projected graph must contain the new to vertex!"};
|
||||
throw std::logic_error{"Projected graph must contain the new `to` vertex!"};
|
||||
}
|
||||
auto result = db_accessor_.ChangeEdgeFrom(edge, new_to_impl);
|
||||
auto result = db_accessor_.EdgeSetTo(edge, new_to_impl);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@@ -19,7 +19,6 @@
|
||||
#include "query/exceptions.hpp"
|
||||
#include "storage/v2/edge_accessor.hpp"
|
||||
#include "storage/v2/id_types.hpp"
|
||||
#include "storage/v2/inmemory/storage.hpp"
|
||||
#include "storage/v2/property_value.hpp"
|
||||
#include "storage/v2/result.hpp"
|
||||
#include "storage/v2/storage_mode.hpp"
|
||||
@@ -377,16 +376,14 @@ class DbAccessor final {
|
||||
return EdgeAccessor(*maybe_edge);
|
||||
}
|
||||
|
||||
storage::Result<EdgeAccessor> ChangeEdgeFrom(EdgeAccessor *edge, VertexAccessor *new_from) {
|
||||
auto changed_edge = static_cast<storage::InMemoryStorage::InMemoryAccessor *>(accessor_)->ChangeEdgeFrom(
|
||||
&edge->impl_, &new_from->impl_);
|
||||
storage::Result<EdgeAccessor> EdgeSetFrom(EdgeAccessor *edge, VertexAccessor *new_from) {
|
||||
auto changed_edge = accessor_->EdgeSetFrom(&edge->impl_, &new_from->impl_);
|
||||
if (changed_edge.HasError()) return storage::Result<EdgeAccessor>(changed_edge.GetError());
|
||||
return EdgeAccessor(*changed_edge);
|
||||
}
|
||||
|
||||
storage::Result<EdgeAccessor> ChangeEdgeTo(EdgeAccessor *edge, VertexAccessor *new_to) {
|
||||
auto changed_edge = static_cast<storage::InMemoryStorage::InMemoryAccessor *>(accessor_)->ChangeEdgeTo(
|
||||
&edge->impl_, &new_to->impl_);
|
||||
storage::Result<EdgeAccessor> EdgeSetTo(EdgeAccessor *edge, VertexAccessor *new_to) {
|
||||
auto changed_edge = accessor_->EdgeSetTo(&edge->impl_, &new_to->impl_);
|
||||
if (changed_edge.HasError()) return storage::Result<EdgeAccessor>(changed_edge.GetError());
|
||||
return EdgeAccessor(*changed_edge);
|
||||
}
|
||||
@@ -560,9 +557,9 @@ class SubgraphDbAccessor final {
|
||||
storage::Result<EdgeAccessor> InsertEdge(SubgraphVertexAccessor *from, SubgraphVertexAccessor *to,
|
||||
const storage::EdgeTypeId &edge_type);
|
||||
|
||||
storage::Result<EdgeAccessor> ChangeEdgeFrom(EdgeAccessor *edge, SubgraphVertexAccessor *new_from);
|
||||
storage::Result<EdgeAccessor> EdgeSetFrom(EdgeAccessor *edge, SubgraphVertexAccessor *new_from);
|
||||
|
||||
storage::Result<EdgeAccessor> ChangeEdgeTo(EdgeAccessor *edge, SubgraphVertexAccessor *new_to);
|
||||
storage::Result<EdgeAccessor> EdgeSetTo(EdgeAccessor *edge, SubgraphVertexAccessor *new_to);
|
||||
|
||||
storage::Result<std::optional<std::pair<VertexAccessor, std::vector<EdgeAccessor>>>> DetachRemoveVertex(
|
||||
SubgraphVertexAccessor *vertex_accessor);
|
||||
|
||||
@@ -2679,126 +2679,81 @@ mgp_error mgp_graph_create_edge(mgp_graph *graph, mgp_vertex *from, mgp_vertex *
|
||||
result);
|
||||
}
|
||||
|
||||
mgp_error mgp_graph_change_edge_from(struct mgp_graph *graph, struct mgp_edge *e, struct mgp_vertex *new_from,
|
||||
mgp_memory *memory, mgp_edge **result) {
|
||||
return WrapExceptions(
|
||||
[&]() -> mgp_edge * {
|
||||
auto *ctx = graph->ctx;
|
||||
namespace {
|
||||
|
||||
mgp_edge *EdgeSet(auto *e, auto *new_vertex, auto *memory, auto *graph, bool set_from) {
|
||||
auto *ctx = graph->ctx;
|
||||
#ifdef MG_ENTERPRISE
|
||||
if (memgraph::license::global_license_checker.IsEnterpriseValidFast() && ctx && ctx->auth_checker &&
|
||||
!ctx->auth_checker->Has(e->impl, memgraph::query::AuthQuery::FineGrainedPrivilege::CREATE_DELETE)) {
|
||||
throw AuthorizationException{"Insufficient permissions for changing an edge!"};
|
||||
}
|
||||
if (memgraph::license::global_license_checker.IsEnterpriseValidFast() && ctx && ctx->auth_checker &&
|
||||
!ctx->auth_checker->Has(e->impl, memgraph::query::AuthQuery::FineGrainedPrivilege::CREATE_DELETE)) {
|
||||
throw AuthorizationException{"Insufficient permissions for changing an edge!"};
|
||||
}
|
||||
#endif
|
||||
if (!MgpGraphIsMutable(*graph)) {
|
||||
throw ImmutableObjectException{"Cannot remove an edge from an immutable graph!"};
|
||||
}
|
||||
if (!MgpGraphIsMutable(*graph)) {
|
||||
throw ImmutableObjectException{"Cannot change the edge because the graph is immutable!"};
|
||||
}
|
||||
|
||||
auto edge = std::visit(memgraph::utils::Overloaded{
|
||||
[&](memgraph::query::DbAccessor *accessor) {
|
||||
return accessor->ChangeEdgeFrom(
|
||||
&e->impl, &std::get<memgraph::query::VertexAccessor>(new_from->impl));
|
||||
},
|
||||
[&](memgraph::query::SubgraphDbAccessor *accessor) {
|
||||
return accessor->ChangeEdgeFrom(
|
||||
&e->impl, &std::get<memgraph::query::SubgraphVertexAccessor>(new_from->impl));
|
||||
}},
|
||||
graph->impl);
|
||||
auto edge = std::visit(
|
||||
memgraph::utils::Overloaded{
|
||||
[&e, &new_vertex, &set_from](
|
||||
memgraph::query::DbAccessor *accessor) -> memgraph::storage::Result<memgraph::query::EdgeAccessor> {
|
||||
if (set_from) {
|
||||
return accessor->EdgeSetFrom(&e->impl, &std::get<memgraph::query::VertexAccessor>(new_vertex->impl));
|
||||
}
|
||||
return accessor->EdgeSetTo(&e->impl, &std::get<memgraph::query::VertexAccessor>(new_vertex->impl));
|
||||
},
|
||||
[&e, &new_vertex, &set_from](memgraph::query::SubgraphDbAccessor *accessor)
|
||||
-> memgraph::storage::Result<memgraph::query::EdgeAccessor> {
|
||||
if (set_from) {
|
||||
return accessor->EdgeSetFrom(&e->impl,
|
||||
&std::get<memgraph::query::SubgraphVertexAccessor>(new_vertex->impl));
|
||||
}
|
||||
return accessor->EdgeSetTo(&e->impl, &std::get<memgraph::query::SubgraphVertexAccessor>(new_vertex->impl));
|
||||
}},
|
||||
graph->impl);
|
||||
|
||||
if (edge.HasError()) {
|
||||
switch (edge.GetError()) {
|
||||
case memgraph::storage::Error::NONEXISTENT_OBJECT:
|
||||
LOG_FATAL("Query modules shouldn't have access to nonexistent objects when changing an edge!");
|
||||
case memgraph::storage::Error::DELETED_OBJECT:
|
||||
LOG_FATAL("The edge was already deleted.");
|
||||
case memgraph::storage::Error::PROPERTIES_DISABLED:
|
||||
case memgraph::storage::Error::VERTEX_HAS_EDGES:
|
||||
LOG_FATAL("Unexpected error when removing an edge.");
|
||||
case memgraph::storage::Error::SERIALIZATION_ERROR:
|
||||
throw SerializationException{"Cannot serialize changing an edge."};
|
||||
}
|
||||
}
|
||||
if (edge.HasError()) {
|
||||
switch (edge.GetError()) {
|
||||
case memgraph::storage::Error::NONEXISTENT_OBJECT:
|
||||
LOG_FATAL("Query modules shouldn't have access to nonexistent objects when changing an edge!");
|
||||
case memgraph::storage::Error::DELETED_OBJECT:
|
||||
LOG_FATAL("The edge was already deleted.");
|
||||
case memgraph::storage::Error::PROPERTIES_DISABLED:
|
||||
case memgraph::storage::Error::VERTEX_HAS_EDGES:
|
||||
LOG_FATAL("Unexpected error when removing an edge.");
|
||||
case memgraph::storage::Error::SERIALIZATION_ERROR:
|
||||
throw SerializationException{"Cannot serialize changing an edge."};
|
||||
}
|
||||
}
|
||||
|
||||
if (ctx->trigger_context_collector) {
|
||||
ctx->trigger_context_collector->RegisterDeletedObject(e->impl);
|
||||
ctx->trigger_context_collector->RegisterCreatedObject(*edge);
|
||||
}
|
||||
if (ctx->trigger_context_collector) {
|
||||
ctx->trigger_context_collector->RegisterDeletedObject(e->impl);
|
||||
ctx->trigger_context_collector->RegisterCreatedObject(*edge);
|
||||
}
|
||||
|
||||
return std::visit(
|
||||
memgraph::utils::Overloaded{
|
||||
[memory, edge, new_from](memgraph::query::DbAccessor *) {
|
||||
return NewRawMgpObject<mgp_edge>(memory->impl, edge.GetValue(), new_from->graph);
|
||||
},
|
||||
[memory, edge, new_from](memgraph::query::SubgraphDbAccessor *db_impl) {
|
||||
const auto &v_from =
|
||||
memgraph::query::SubgraphVertexAccessor(edge.GetValue().From(), db_impl->getGraph());
|
||||
const auto &v_to = memgraph::query::SubgraphVertexAccessor(edge.GetValue().To(), db_impl->getGraph());
|
||||
return NewRawMgpObject<mgp_edge>(memory->impl, edge.GetValue(), v_from, v_to, new_from->graph);
|
||||
}},
|
||||
new_from->graph->impl);
|
||||
},
|
||||
result);
|
||||
return std::visit(
|
||||
memgraph::utils::Overloaded{
|
||||
[&memory, &edge, &new_vertex](memgraph::query::DbAccessor *) -> mgp_edge * {
|
||||
return NewRawMgpObject<mgp_edge>(memory->impl, edge.GetValue(), new_vertex->graph);
|
||||
},
|
||||
[&memory, &edge, &new_vertex](memgraph::query::SubgraphDbAccessor *db_impl) -> mgp_edge * {
|
||||
const auto v_from = memgraph::query::SubgraphVertexAccessor(edge.GetValue().From(), db_impl->getGraph());
|
||||
const auto v_to = memgraph::query::SubgraphVertexAccessor(edge.GetValue().To(), db_impl->getGraph());
|
||||
return NewRawMgpObject<mgp_edge>(memory->impl, edge.GetValue(), v_from, v_to, new_vertex->graph);
|
||||
}},
|
||||
new_vertex->graph->impl);
|
||||
}
|
||||
|
||||
mgp_error mgp_graph_change_edge_to(struct mgp_graph *graph, struct mgp_edge *e, struct mgp_vertex *new_to,
|
||||
mgp_memory *memory, mgp_edge **result) {
|
||||
return WrapExceptions(
|
||||
[&]() -> mgp_edge * {
|
||||
auto *ctx = graph->ctx;
|
||||
#ifdef MG_ENTERPRISE
|
||||
if (memgraph::license::global_license_checker.IsEnterpriseValidFast() && ctx && ctx->auth_checker &&
|
||||
!ctx->auth_checker->Has(e->impl, memgraph::query::AuthQuery::FineGrainedPrivilege::CREATE_DELETE)) {
|
||||
throw AuthorizationException{"Insufficient permissions for changing an edge!"};
|
||||
}
|
||||
#endif
|
||||
if (!MgpGraphIsMutable(*graph)) {
|
||||
throw ImmutableObjectException{"Cannot remove an edge from an immutable graph!"};
|
||||
}
|
||||
} // namespace
|
||||
|
||||
auto edge = std::visit(memgraph::utils::Overloaded{
|
||||
[&](memgraph::query::DbAccessor *accessor) {
|
||||
return accessor->ChangeEdgeTo(
|
||||
&e->impl, &std::get<memgraph::query::VertexAccessor>(new_to->impl));
|
||||
},
|
||||
[&](memgraph::query::SubgraphDbAccessor *accessor) {
|
||||
return accessor->ChangeEdgeTo(
|
||||
&e->impl, &std::get<memgraph::query::SubgraphVertexAccessor>(new_to->impl));
|
||||
}},
|
||||
graph->impl);
|
||||
mgp_error mgp_graph_edge_set_from(struct mgp_graph *graph, struct mgp_edge *e, struct mgp_vertex *new_from,
|
||||
mgp_memory *memory, mgp_edge **result) {
|
||||
return WrapExceptions([&]() -> mgp_edge * { return EdgeSet(e, new_from, memory, graph, true); }, result);
|
||||
}
|
||||
|
||||
if (edge.HasError()) {
|
||||
switch (edge.GetError()) {
|
||||
case memgraph::storage::Error::NONEXISTENT_OBJECT:
|
||||
LOG_FATAL("Query modules shouldn't have access to nonexistent objects when changing an edge!");
|
||||
case memgraph::storage::Error::DELETED_OBJECT:
|
||||
LOG_FATAL("The edge was already deleted.");
|
||||
case memgraph::storage::Error::PROPERTIES_DISABLED:
|
||||
case memgraph::storage::Error::VERTEX_HAS_EDGES:
|
||||
LOG_FATAL("Unexpected error when removing an edge.");
|
||||
case memgraph::storage::Error::SERIALIZATION_ERROR:
|
||||
throw SerializationException{"Cannot serialize changing an edge."};
|
||||
}
|
||||
}
|
||||
|
||||
if (ctx->trigger_context_collector) {
|
||||
ctx->trigger_context_collector->RegisterDeletedObject(e->impl);
|
||||
ctx->trigger_context_collector->RegisterCreatedObject(*edge);
|
||||
}
|
||||
|
||||
return std::visit(
|
||||
memgraph::utils::Overloaded{
|
||||
[memory, edge, new_to](memgraph::query::DbAccessor *) {
|
||||
return NewRawMgpObject<mgp_edge>(memory->impl, edge.GetValue(), new_to->graph);
|
||||
},
|
||||
[memory, edge, new_to](memgraph::query::SubgraphDbAccessor *db_impl) {
|
||||
const auto &v_from =
|
||||
memgraph::query::SubgraphVertexAccessor(edge.GetValue().From(), db_impl->getGraph());
|
||||
const auto &v_to = memgraph::query::SubgraphVertexAccessor(edge.GetValue().To(), db_impl->getGraph());
|
||||
return NewRawMgpObject<mgp_edge>(memory->impl, edge.GetValue(), v_from, v_to, new_to->graph);
|
||||
}},
|
||||
new_to->graph->impl);
|
||||
},
|
||||
result);
|
||||
mgp_error mgp_graph_edge_set_to(struct mgp_graph *graph, struct mgp_edge *e, struct mgp_vertex *new_to,
|
||||
mgp_memory *memory, mgp_edge **result) {
|
||||
return WrapExceptions([&]() -> mgp_edge * { return EdgeSet(e, new_to, memory, graph, false); }, result);
|
||||
}
|
||||
|
||||
mgp_error mgp_graph_delete_edge(struct mgp_graph *graph, mgp_edge *edge) {
|
||||
|
||||
@@ -36,6 +36,7 @@
|
||||
#include "storage/v2/disk/rocksdb_storage.hpp"
|
||||
#include "storage/v2/disk/storage.hpp"
|
||||
#include "storage/v2/disk/unique_constraints.hpp"
|
||||
#include "storage/v2/edge_accessor.hpp"
|
||||
#include "storage/v2/edge_import_mode.hpp"
|
||||
#include "storage/v2/edge_ref.hpp"
|
||||
#include "storage/v2/id_types.hpp"
|
||||
@@ -1366,6 +1367,16 @@ Result<std::optional<EdgeAccessor>> DiskStorage::DiskAccessor::DeleteEdge(EdgeAc
|
||||
&storage_->indices_, &storage_->constraints_, config_, true);
|
||||
}
|
||||
|
||||
Result<EdgeAccessor> DiskStorage::DiskAccessor::EdgeSetFrom(EdgeAccessor *edge, VertexAccessor *new_from) {
|
||||
MG_ASSERT(false, "EdgeSetFrom is currently only implemented for InMemory storage");
|
||||
return Error::NONEXISTENT_OBJECT;
|
||||
}
|
||||
|
||||
Result<EdgeAccessor> DiskStorage::DiskAccessor::EdgeSetTo(EdgeAccessor *edge, VertexAccessor *new_to) {
|
||||
MG_ASSERT(false, "EdgeSetTo is currently only implemented for InMemory storage");
|
||||
return Error::NONEXISTENT_OBJECT;
|
||||
}
|
||||
|
||||
/// TODO: at which storage naming
|
||||
/// TODO: this method should also delete the old key
|
||||
bool DiskStorage::DiskAccessor::WriteVertexToDisk(const Vertex &vertex) {
|
||||
|
||||
@@ -184,6 +184,10 @@ class DiskStorage final : public Storage {
|
||||
|
||||
Result<EdgeAccessor> CreateEdge(VertexAccessor *from, VertexAccessor *to, EdgeTypeId edge_type) override;
|
||||
|
||||
Result<EdgeAccessor> EdgeSetFrom(EdgeAccessor *edge, VertexAccessor *new_from) override;
|
||||
|
||||
Result<EdgeAccessor> EdgeSetTo(EdgeAccessor *edge, VertexAccessor *new_to) override;
|
||||
|
||||
Result<std::optional<EdgeAccessor>> DeleteEdge(EdgeAccessor *edge) override;
|
||||
|
||||
bool LabelIndexExists(LabelId label) const override {
|
||||
|
||||
@@ -496,7 +496,7 @@ Result<EdgeAccessor> InMemoryStorage::InMemoryAccessor::CreateEdgeEx(VertexAcces
|
||||
&storage_->constraints_, config_);
|
||||
}
|
||||
|
||||
Result<EdgeAccessor> InMemoryStorage::InMemoryAccessor::ChangeEdgeFrom(EdgeAccessor *edge, VertexAccessor *new_from) {
|
||||
Result<EdgeAccessor> InMemoryStorage::InMemoryAccessor::EdgeSetFrom(EdgeAccessor *edge, VertexAccessor *new_from) {
|
||||
MG_ASSERT(edge->transaction_ == new_from->transaction_,
|
||||
"EdgeAccessor must be from the same transaction as the new from vertex "
|
||||
"accessor when deleting an edge!");
|
||||
@@ -598,7 +598,7 @@ Result<EdgeAccessor> InMemoryStorage::InMemoryAccessor::ChangeEdgeFrom(EdgeAcces
|
||||
&storage_->constraints_, config_);
|
||||
}
|
||||
|
||||
Result<EdgeAccessor> InMemoryStorage::InMemoryAccessor::ChangeEdgeTo(EdgeAccessor *edge, VertexAccessor *new_to) {
|
||||
Result<EdgeAccessor> InMemoryStorage::InMemoryAccessor::EdgeSetTo(EdgeAccessor *edge, VertexAccessor *new_to) {
|
||||
MG_ASSERT(edge->transaction_ == new_to->transaction_,
|
||||
"EdgeAccessor must be from the same transaction as the new to vertex "
|
||||
"accessor when deleting an edge!");
|
||||
@@ -612,8 +612,8 @@ Result<EdgeAccessor> InMemoryStorage::InMemoryAccessor::ChangeEdgeTo(EdgeAccesso
|
||||
|
||||
if (old_to_vertex->gid == new_to_vertex->gid) return *edge;
|
||||
|
||||
auto edge_ref = edge->edge_;
|
||||
auto edge_type = edge->edge_type_;
|
||||
auto &edge_ref = edge->edge_;
|
||||
auto &edge_type = edge->edge_type_;
|
||||
|
||||
std::unique_lock<utils::RWSpinLock> guard;
|
||||
if (config_.properties_on_edges) {
|
||||
@@ -704,8 +704,8 @@ Result<std::optional<EdgeAccessor>> InMemoryStorage::InMemoryAccessor::DeleteEdg
|
||||
MG_ASSERT(edge->transaction_ == &transaction_,
|
||||
"EdgeAccessor must be from the same transaction as the storage "
|
||||
"accessor when deleting an edge!");
|
||||
auto edge_ref = edge->edge_;
|
||||
auto edge_type = edge->edge_type_;
|
||||
auto &edge_ref = edge->edge_;
|
||||
auto &edge_type = edge->edge_type_;
|
||||
|
||||
std::unique_lock<utils::RWSpinLock> guard;
|
||||
if (config_.properties_on_edges) {
|
||||
|
||||
@@ -221,9 +221,9 @@ class InMemoryStorage final : public Storage {
|
||||
/// @throw std::bad_alloc
|
||||
Result<EdgeAccessor> CreateEdge(VertexAccessor *from, VertexAccessor *to, EdgeTypeId edge_type) override;
|
||||
|
||||
Result<EdgeAccessor> ChangeEdgeFrom(EdgeAccessor *edge, VertexAccessor *new_from);
|
||||
Result<EdgeAccessor> EdgeSetFrom(EdgeAccessor *edge, VertexAccessor *new_from) override;
|
||||
|
||||
Result<EdgeAccessor> ChangeEdgeTo(EdgeAccessor *edge, VertexAccessor *new_to);
|
||||
Result<EdgeAccessor> EdgeSetTo(EdgeAccessor *edge, VertexAccessor *new_to) override;
|
||||
|
||||
/// Accessor to the deleted edge if a deletion took place, std::nullopt otherwise
|
||||
/// @throw std::bad_alloc
|
||||
|
||||
@@ -153,6 +153,10 @@ class Storage {
|
||||
|
||||
virtual Result<EdgeAccessor> CreateEdge(VertexAccessor *from, VertexAccessor *to, EdgeTypeId edge_type) = 0;
|
||||
|
||||
virtual Result<EdgeAccessor> EdgeSetFrom(EdgeAccessor *edge, VertexAccessor *new_from) = 0;
|
||||
|
||||
virtual Result<EdgeAccessor> EdgeSetTo(EdgeAccessor *edge, VertexAccessor *new_to) = 0;
|
||||
|
||||
virtual Result<std::optional<EdgeAccessor>> DeleteEdge(EdgeAccessor *edge) = 0;
|
||||
|
||||
virtual bool LabelIndexExists(LabelId label) const = 0;
|
||||
|
||||
@@ -701,7 +701,7 @@ TYPED_TEST(CppApiTestFixture, TestRelationshipChangeFrom) {
|
||||
auto relationship = graph.CreateRelationship(node_1, node_2, "Edge");
|
||||
|
||||
ASSERT_EQ(relationship.From().Id(), node_1.Id());
|
||||
graph.ChangeRelationshipFrom(relationship, node_3);
|
||||
graph.SetFrom(relationship, node_3);
|
||||
|
||||
ASSERT_EQ(std::string(relationship.Type()), "Edge");
|
||||
ASSERT_EQ(relationship.From().Id(), node_3.Id());
|
||||
@@ -719,7 +719,7 @@ TYPED_TEST(CppApiTestFixture, TestRelationshipChangeTo) {
|
||||
auto relationship = graph.CreateRelationship(node_1, node_2, "Edge");
|
||||
|
||||
ASSERT_EQ(relationship.To().Id(), node_2.Id());
|
||||
graph.ChangeRelationshipTo(relationship, node_3);
|
||||
graph.SetTo(relationship, node_3);
|
||||
|
||||
ASSERT_EQ(std::string(relationship.Type()), "Edge");
|
||||
ASSERT_EQ(relationship.From().Id(), node_1.Id());
|
||||
|
||||
Reference in New Issue
Block a user