Query::Plan::ExpandVariable - graph state bugfix
Reviewers: buda, teon.banek, mislav.bradac Reviewed By: mislav.bradac Subscribers: pullbot Differential Revision: https://phabricator.memgraph.io/D631
This commit is contained in:
parent
7939b04117
commit
0f73c2451b
@ -691,6 +691,7 @@ class ExpandVariableCursor : public Cursor {
|
||||
: std::numeric_limits<int64_t>::max();
|
||||
|
||||
if (upper_bound_ > 0) {
|
||||
SwitchAccessor(vertex, self_.graph_view_);
|
||||
edges_.emplace_back(ExpandFromVertex(vertex, self_.direction_));
|
||||
edges_it_.emplace_back(edges_.back().begin());
|
||||
}
|
||||
@ -828,6 +829,7 @@ class ExpandVariableCursor : public Cursor {
|
||||
// we are doing depth-first search, so place the current
|
||||
// edge's expansions onto the stack, if we should continue to expand
|
||||
if (upper_bound_ > static_cast<int64_t>(edges_.size())) {
|
||||
SwitchAccessor(current_vertex, self_.graph_view_);
|
||||
edges_.emplace_back(ExpandFromVertex(current_vertex, self_.direction_));
|
||||
edges_it_.emplace_back(edges_.back().begin());
|
||||
}
|
||||
|
@ -346,7 +346,8 @@ class QueryPlanExpandVariable : public testing::Test {
|
||||
int layer, EdgeAtom::Direction direction,
|
||||
std::experimental::optional<size_t> lower,
|
||||
std::experimental::optional<size_t> upper, Symbol edge_sym,
|
||||
bool existing_edge, const std::string &node_to) {
|
||||
bool existing_edge, const std::string &node_to,
|
||||
GraphView graph_view = GraphView::AS_IS) {
|
||||
auto n_from = MakeScanAll(storage, symbol_table, node_from, input_op);
|
||||
auto filter_op = std::make_shared<Filter>(
|
||||
n_from.op_, storage.Create<query::LabelsTest>(
|
||||
@ -364,11 +365,11 @@ class QueryPlanExpandVariable : public testing::Test {
|
||||
};
|
||||
return std::make_shared<ExpandVariable>(
|
||||
n_to_sym, edge_sym, direction, convert(lower), convert(upper),
|
||||
filter_op, n_from.sym_, false, existing_edge, GraphView::OLD);
|
||||
filter_op, n_from.sym_, false, existing_edge, graph_view);
|
||||
} else
|
||||
return std::make_shared<Expand>(n_to_sym, edge_sym, direction, filter_op,
|
||||
n_from.sym_, false, existing_edge,
|
||||
GraphView::OLD);
|
||||
graph_view);
|
||||
}
|
||||
|
||||
/* Creates an edge (in the frame and symbol table). Returns the symbol. */
|
||||
@ -550,6 +551,31 @@ TEST_F(QueryPlanExpandVariable, ExistingEdges) {
|
||||
(map_int{{1, 4}, {2, 12}}));
|
||||
}
|
||||
|
||||
TEST_F(QueryPlanExpandVariable, GraphState) {
|
||||
auto test_expand = [&](GraphView graph_view) {
|
||||
auto e = Edge("r", EdgeAtom::Direction::OUT);
|
||||
return GetResults(AddMatch<ExpandVariable>(nullptr, "n", 0, EdgeAtom::Direction::OUT,
|
||||
2, 2, e, false, "m", graph_view), e);
|
||||
};
|
||||
|
||||
EXPECT_EQ(test_expand(GraphView::OLD), (map_int{{2, 8}}));
|
||||
|
||||
// add two vertices branching out from the second layer
|
||||
for (VertexAccessor &vertex : dba->vertices(true))
|
||||
if (vertex.has_label(labels[1])) {
|
||||
auto new_vertex = dba->insert_vertex();
|
||||
dba->insert_edge(vertex, new_vertex, dba->edge_type("some_type"));
|
||||
}
|
||||
ASSERT_EQ(CountIterable(dba->vertices(false)), 6);
|
||||
ASSERT_EQ(CountIterable(dba->vertices(true)), 8);
|
||||
|
||||
EXPECT_EQ(test_expand(GraphView::OLD), (map_int{{2, 8}}));
|
||||
EXPECT_EQ(test_expand(GraphView::NEW), (map_int{{2, 12}}));
|
||||
dba->advance_command();
|
||||
EXPECT_EQ(test_expand(GraphView::OLD), (map_int{{2, 12}}));
|
||||
EXPECT_EQ(test_expand(GraphView::NEW), (map_int{{2, 12}}));
|
||||
}
|
||||
|
||||
namespace std {
|
||||
template <>
|
||||
struct hash<std::pair<int, int>> {
|
||||
|
Loading…
Reference in New Issue
Block a user