Address GH comments and fix a bug in ValidFramesModifier postincrement
This commit is contained in:
parent
70200919cd
commit
a9eca651df
@ -168,7 +168,7 @@ class ValidFramesModifier {
|
||||
Iterator &operator++() {
|
||||
do {
|
||||
ptr_++;
|
||||
} while (*this != iterator_wrapper_->end() && ptr_->IsValid());
|
||||
} while (*this != iterator_wrapper_->end() && !ptr_->IsValid());
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
@ -2468,9 +2468,9 @@ class DistributedCreateExpandCursor : public Cursor {
|
||||
|
||||
std::vector<msgs::NewExpand> ExpandCreationInfoToRequests(MultiFrame &multi_frame, ExecutionContext &context) const {
|
||||
std::vector<msgs::NewExpand> edge_requests;
|
||||
auto reader = multi_frame.GetValidFramesModifier();
|
||||
auto frames_modifier = multi_frame.GetValidFramesModifier();
|
||||
|
||||
for (auto &frame : reader) {
|
||||
for (auto &frame : frames_modifier) {
|
||||
const auto &edge_info = self_.edge_info_;
|
||||
msgs::NewExpand request{.id = {context.edge_ids_alloc->AllocateId()}};
|
||||
ExpressionEvaluator evaluator(&frame, context.symbol_table, context.evaluation_context, nullptr,
|
||||
@ -2489,35 +2489,22 @@ class DistributedCreateExpandCursor : public Cursor {
|
||||
request.properties.emplace_back(property_id, storage::v3::TypedValueToValue(value));
|
||||
}
|
||||
}
|
||||
// src, dest
|
||||
|
||||
TypedValue &v1_value = frame[self_.input_symbol_];
|
||||
const auto &v1 = v1_value.ValueVertex();
|
||||
const auto &v2 = OtherVertex(frame);
|
||||
msgs::Edge edge{.src = request.src_vertex,
|
||||
.dst = request.dest_vertex,
|
||||
.properties = request.properties,
|
||||
.id = request.id,
|
||||
.type = request.type};
|
||||
frame[self_.edge_info_.symbol] = TypedValue(accessors::EdgeAccessor(std::move(edge), context.request_router));
|
||||
|
||||
// Set src and dest vertices
|
||||
// TODO(jbajic) Currently we are only handling scenario where vertices
|
||||
// are matched
|
||||
const auto set_vertex = [](const auto &vertex, auto &vertex_id) {
|
||||
vertex_id.first = vertex.PrimaryLabel();
|
||||
vertex_id.second = vertex.GetVertex().id.second;
|
||||
};
|
||||
|
||||
std::invoke([&]() {
|
||||
switch (edge_info.direction) {
|
||||
case EdgeAtom::Direction::IN: {
|
||||
set_vertex(v2, request.src_vertex);
|
||||
set_vertex(v1, request.dest_vertex);
|
||||
break;
|
||||
}
|
||||
case EdgeAtom::Direction::OUT: {
|
||||
set_vertex(v1, request.src_vertex);
|
||||
set_vertex(v2, request.dest_vertex);
|
||||
break;
|
||||
}
|
||||
case EdgeAtom::Direction::BOTH:
|
||||
LOG_FATAL("Must indicate exact expansion direction here");
|
||||
}
|
||||
});
|
||||
request.src_vertex = v1.Id();
|
||||
request.dest_vertex = v2.Id();
|
||||
|
||||
edge_requests.push_back(std::move(request));
|
||||
}
|
||||
|
@ -73,10 +73,10 @@ inline expr::ExecutionContext MakeContext(const expr::AstStorage &storage, const
|
||||
return context;
|
||||
}
|
||||
|
||||
inline MockedLogicalOperator &BaseToMock(plan::LogicalOperator *op) {
|
||||
return *static_cast<MockedLogicalOperator *>(op);
|
||||
inline MockedLogicalOperator &BaseToMock(plan::LogicalOperator &op) {
|
||||
return dynamic_cast<MockedLogicalOperator &>(op);
|
||||
}
|
||||
|
||||
inline MockedCursor &BaseToMock(plan::Cursor *cursor) { return *static_cast<MockedCursor *>(cursor); }
|
||||
inline MockedCursor &BaseToMock(plan::Cursor &cursor) { return dynamic_cast<MockedCursor &>(cursor); }
|
||||
|
||||
} // namespace memgraph::query::v2
|
||||
|
@ -55,25 +55,35 @@ TEST(CreateExpandTest, Cursor) {
|
||||
plan::EdgeCreationInfo edge;
|
||||
edge.edge_type = msgs::EdgeTypeId::FromUint(1);
|
||||
edge.direction = EdgeAtom::Direction::IN;
|
||||
edge.symbol = symbol_table.CreateSymbol("e", true);
|
||||
auto id_alloc = IdAllocator(0, 100);
|
||||
|
||||
const auto &src = symbol_table.CreateSymbol("n", true);
|
||||
node.symbol = symbol_table.CreateSymbol("u", true);
|
||||
|
||||
auto once_cur = plan::MakeUniqueCursorPtr<MockedCursor>(utils::NewDeleteResource());
|
||||
EXPECT_CALL(BaseToMock(once_cur.get()), PullMultiple(_, _)).Times(1);
|
||||
EXPECT_CALL(BaseToMock(*once_cur), PullMultiple(_, _)).Times(1);
|
||||
|
||||
std::shared_ptr<plan::LogicalOperator> once_op = std::make_shared<MockedLogicalOperator>();
|
||||
EXPECT_CALL(BaseToMock(once_op.get()), MakeCursor(_)).Times(1).WillOnce(Return(std::move(once_cur)));
|
||||
EXPECT_CALL(BaseToMock(*once_op), MakeCursor(_)).Times(1).WillOnce(Return(std::move(once_cur)));
|
||||
|
||||
auto create_expand = plan::CreateExpand(node, edge, once_op, src, true);
|
||||
auto cursor = create_expand.MakeCursor(utils::NewDeleteResource());
|
||||
|
||||
MockedRequestRouter router;
|
||||
EXPECT_CALL(router, CreateExpand(_)).Times(1).WillOnce(Return(std::vector<msgs::CreateExpandResponse>{}));
|
||||
EXPECT_CALL(router, CreateExpand(_))
|
||||
.Times(1)
|
||||
.WillOnce(Return(std::vector<msgs::CreateExpandResponse>{msgs::CreateExpandResponse{}}));
|
||||
auto context = MakeContext(ast, symbol_table, &router, &id_alloc);
|
||||
auto multi_frame = CreateMultiFrame(context.symbol_table.max_position(), src, node.symbol, &router);
|
||||
cursor->PullMultiple(multi_frame, context);
|
||||
|
||||
auto frames = multi_frame.GetValidFramesReader();
|
||||
for (auto &frame : frames) {
|
||||
EXPECT_EQ(frame[edge.symbol].IsEdge(), true);
|
||||
const auto &e = frame[edge.symbol].ValueEdge();
|
||||
EXPECT_EQ(e.EdgeType(), edge.edge_type);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace memgraph::query::v2
|
||||
|
Loading…
Reference in New Issue
Block a user