add impl of insert vertex
This commit is contained in:
parent
b776313c80
commit
026ccc85ee
src/query
@ -77,10 +77,10 @@ storage::Result<std::optional<VertexAccessor>> SubgraphDbAccessor::RemoveVertex(
|
||||
return result;
|
||||
}
|
||||
|
||||
VertexAccessor SubgraphDbAccessor::InsertVertex() {
|
||||
auto result = db_accessor_->InsertVertex();
|
||||
// todo antoniofilipovic add vertex to subgraph
|
||||
return result;
|
||||
SubgraphVertexAccessor SubgraphDbAccessor::InsertVertex() {
|
||||
VertexAccessor vertex = db_accessor_->InsertVertex();
|
||||
this->graph_->InsertVertex(vertex);
|
||||
return SubgraphVertexAccessor(vertex, this->getGraph());
|
||||
}
|
||||
|
||||
VerticesIterable SubgraphDbAccessor::Vertices(storage::View view) {
|
||||
|
@ -486,7 +486,7 @@ class SubgraphDbAccessor final {
|
||||
|
||||
storage::Result<std::optional<VertexAccessor>> RemoveVertex(VertexAccessor *vertex_accessor);
|
||||
|
||||
VertexAccessor InsertVertex();
|
||||
SubgraphVertexAccessor InsertVertex();
|
||||
|
||||
VerticesIterable Vertices(storage::View view);
|
||||
|
||||
|
@ -31,6 +31,10 @@ void Graph::Expand(const Path &path) {
|
||||
std::for_each(path_edges_.begin(), path_edges_.end(), [this](const EdgeAccessor e) { edges_.insert(e); });
|
||||
}
|
||||
|
||||
void Graph::InsertVertex(const VertexAccessor &vertex) { vertices_.insert(vertex); }
|
||||
|
||||
void Graph::InsertEdge(const EdgeAccessor &edge) { edges_.insert(edge); }
|
||||
|
||||
std::vector<query::EdgeAccessor> Graph::OutEdges(query::VertexAccessor vertex_accessor) {
|
||||
std::vector<query::EdgeAccessor> out_edges;
|
||||
for (auto it = edges_.begin(); it != edges_.end(); ++it) {
|
||||
|
@ -57,6 +57,9 @@ class Graph final {
|
||||
|
||||
/** Expands the graph with the given path. */
|
||||
void Expand(const Path &path);
|
||||
void InsertVertex(const VertexAccessor &vertex);
|
||||
void InsertEdge(const EdgeAccessor &edge);
|
||||
|
||||
std::vector<EdgeAccessor> OutEdges(VertexAccessor vertex_accessor);
|
||||
|
||||
/** Move assign other, utils::MemoryResource of `this` is used. */
|
||||
|
@ -2222,6 +2222,7 @@ mgp_error mgp_graph_get_vertex_by_id(mgp_graph *graph, mgp_vertex_id id, mgp_mem
|
||||
},
|
||||
graph->impl);
|
||||
if (maybe_vertex) {
|
||||
// todo antoniofilipovic change this to set proper vertexAccessro
|
||||
return NewRawMgpObject<mgp_vertex>(memory, *maybe_vertex, graph);
|
||||
}
|
||||
return nullptr;
|
||||
@ -2240,16 +2241,18 @@ mgp_error mgp_graph_create_vertex(struct mgp_graph *graph, mgp_memory *memory, m
|
||||
if (!MgpGraphIsMutable(*graph)) {
|
||||
throw ImmutableObjectException{"Cannot create a vertex in an immutable graph!"};
|
||||
}
|
||||
auto vertex =
|
||||
std::visit(memgraph::utils::Overloaded{[](auto *impl) { return impl->InsertVertex(); }}, graph->impl);
|
||||
auto vertex = std::visit(memgraph::utils::Overloaded{[=](auto *impl) {
|
||||
return NewRawMgpObject<mgp_vertex>(memory, impl->InsertVertex(), graph);
|
||||
}},
|
||||
graph->impl);
|
||||
|
||||
auto &ctx = graph->ctx;
|
||||
ctx->execution_stats[memgraph::query::ExecutionStats::Key::CREATED_NODES] += 1;
|
||||
|
||||
if (ctx->trigger_context_collector) {
|
||||
ctx->trigger_context_collector->RegisterCreatedObject(vertex);
|
||||
ctx->trigger_context_collector->RegisterCreatedObject(vertex->getImpl());
|
||||
}
|
||||
return NewRawMgpObject<mgp_vertex>(memory, vertex, graph);
|
||||
return vertex;
|
||||
},
|
||||
result);
|
||||
}
|
||||
@ -2417,6 +2420,7 @@ mgp_error mgp_graph_create_edge(mgp_graph *graph, mgp_vertex *from, mgp_vertex *
|
||||
if (ctx->trigger_context_collector) {
|
||||
ctx->trigger_context_collector->RegisterCreatedObject(*edge);
|
||||
}
|
||||
// check what does this method call
|
||||
return NewRawMgpObject<mgp_edge>(memory, edge.GetValue(), from->graph);
|
||||
},
|
||||
result);
|
||||
|
Loading…
Reference in New Issue
Block a user