add non working version of edge iterator
This commit is contained in:
parent
8fb770568f
commit
e4a3ba7a2b
src/query
@ -66,6 +66,16 @@ class Graph {
|
||||
std::for_each(path_edges_.begin(), path_edges_.end(), [this](const EdgeAccessor e) { edges_.push_back(e); });
|
||||
}
|
||||
|
||||
std::vector<query::EdgeAccessor> OutEdges(query::VertexAccessor vertex_accessor) {
|
||||
std::vector<query::EdgeAccessor> out_edges;
|
||||
for (auto it = edges_.begin(); it != edges_.end(); ++it) {
|
||||
if (it->From() == vertex_accessor) {
|
||||
out_edges.emplace_back(*it);
|
||||
}
|
||||
}
|
||||
return out_edges;
|
||||
}
|
||||
|
||||
/** Move assign other, utils::MemoryResource of `this` is used. */
|
||||
Graph &operator=(Graph &&) = default;
|
||||
|
||||
|
@ -3739,10 +3739,12 @@ void CallCustomProcedure(const std::string_view fully_qualified_procedure_name,
|
||||
for (auto *expression : args) {
|
||||
args_list.emplace_back(expression->Accept(*evaluator));
|
||||
}
|
||||
const query::Graph *subgraph;
|
||||
|
||||
if (!args_list.empty() && args_list.front().type() == TypedValue::Type::Graph) {
|
||||
subgraph = &args_list.front().ValueGraph();
|
||||
args_list.erase(args_list.begin());
|
||||
TypedValue subgraph = TypedValue(args_list.front(), args_list.front().ValueGraph().GetMemoryResource());
|
||||
|
||||
args_list.erase(args_list.begin()); // ova linija obrise vertexe
|
||||
graph.subgraph = &subgraph.ValueGraph();
|
||||
}
|
||||
|
||||
// if we have graph at first element, it is okay to have 1+ element here
|
||||
|
@ -1866,6 +1866,24 @@ mgp_error mgp_vertex_iter_out_edges(mgp_vertex *v, mgp_memory *memory, mgp_edges
|
||||
[v, memory] {
|
||||
auto it = NewMgpObject<mgp_edges_iterator>(memory, *v);
|
||||
MG_ASSERT(it != nullptr);
|
||||
if (v->graph->subgraph) {
|
||||
spdlog::info("works here");
|
||||
auto edges = v->graph->subgraph->OutEdges(v->impl);
|
||||
std::vector<mgp_edge> edges_;
|
||||
edges_.reserve(edges.size());
|
||||
|
||||
for (auto it = edges.begin(); it != edges.end(); ++it) {
|
||||
edges_.emplace_back(mgp_edge(*it, v->graph, memory->impl));
|
||||
}
|
||||
|
||||
// it->out.emplace(std::move(edges_));
|
||||
// it->out_it.emplace(it->out->begin());
|
||||
// if (*it->out_it != it->out->end()) {
|
||||
// it->current_e.emplace(**it->out_it, v->graph, it->GetMemoryResource());
|
||||
// }
|
||||
|
||||
// return it.release();
|
||||
}
|
||||
|
||||
auto maybe_edges = v->impl.OutEdges(v->graph->view);
|
||||
if (maybe_edges.HasError()) {
|
||||
|
@ -576,16 +576,17 @@ struct mgp_graph {
|
||||
// TODO: Merge `mgp_graph` and `mgp_memory` into a single `mgp_context`. The
|
||||
// `ctx` field is out of place here.
|
||||
memgraph::query::ExecutionContext *ctx;
|
||||
memgraph::query::Graph *subgraph;
|
||||
|
||||
// memgraph:::query::Graph *subraph;
|
||||
|
||||
static mgp_graph WritableGraph(memgraph::query::DbAccessor &acc, memgraph::storage::View view,
|
||||
memgraph::query::ExecutionContext &ctx) {
|
||||
return mgp_graph{&acc, view, &ctx};
|
||||
return mgp_graph{&acc, view, &ctx, nullptr};
|
||||
}
|
||||
|
||||
static mgp_graph NonWritableGraph(memgraph::query::DbAccessor &acc, memgraph::storage::View view) {
|
||||
return mgp_graph{&acc, view, nullptr};
|
||||
return mgp_graph{&acc, view, nullptr, nullptr};
|
||||
}
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user