Make ExpandOne work in the query engine (#589)
This commit is contained in:
committed by
GitHub
parent
85b8ce9101
commit
f89a2bbf42
@@ -86,6 +86,7 @@ ShardMap TestShardMap() {
|
||||
const auto label_id = sm.InitializeNewLabel(kLabelName, schema, replication_factor, sm.shard_map_version);
|
||||
EXPECT_TRUE(label_id.has_value());
|
||||
|
||||
sm.AllocateEdgeTypeIds(std::vector<std::string>{"edge_type"});
|
||||
// split the shard at N split points
|
||||
// NB: this is the logic that should be provided by the "split file"
|
||||
// TODO(tyler) split points should account for signedness
|
||||
@@ -116,12 +117,11 @@ void TestScanAll(ShardRequestManager &shard_request_manager) {
|
||||
EXPECT_EQ(result.size(), 2);
|
||||
}
|
||||
|
||||
template <typename ShardRequestManager>
|
||||
void TestCreateVertices(ShardRequestManager &shard_request_manager) {
|
||||
void TestCreateVertices(msgs::ShardRequestManagerInterface &shard_request_manager) {
|
||||
using PropVal = msgs::Value;
|
||||
msgs::ExecutionState<msgs::CreateVerticesRequest> state;
|
||||
std::vector<msgs::NewVertex> new_vertices;
|
||||
auto label_id = shard_request_manager.LabelNameToLabelId(kLabelName);
|
||||
auto label_id = shard_request_manager.NameToLabel(kLabelName);
|
||||
msgs::NewVertex a1{.primary_key = {PropVal(int64_t(0)), PropVal(int64_t(0))}};
|
||||
a1.label_ids.push_back({label_id});
|
||||
msgs::NewVertex a2{.primary_key = {PropVal(int64_t(13)), PropVal(int64_t(13))}};
|
||||
@@ -133,8 +133,40 @@ void TestCreateVertices(ShardRequestManager &shard_request_manager) {
|
||||
EXPECT_EQ(result.size(), 1);
|
||||
}
|
||||
|
||||
template <typename ShardRequestManager>
|
||||
void TestExpand(ShardRequestManager &shard_request_manager) {}
|
||||
void TestCreateExpand(msgs::ShardRequestManagerInterface &shard_request_manager) {
|
||||
using PropVal = msgs::Value;
|
||||
msgs::ExecutionState<msgs::CreateExpandRequest> state;
|
||||
std::vector<msgs::NewExpand> new_expands;
|
||||
|
||||
const auto edge_type_id = shard_request_manager.NameToEdgeType("edge_type");
|
||||
const auto label = msgs::Label{shard_request_manager.NameToLabel("test_label")};
|
||||
const msgs::VertexId vertex_id_1{label, {PropVal(int64_t(0)), PropVal(int64_t(0))}};
|
||||
const msgs::VertexId vertex_id_2{label, {PropVal(int64_t(13)), PropVal(int64_t(13))}};
|
||||
msgs::NewExpand expand_1{
|
||||
.id = {.gid = 0}, .type = {edge_type_id}, .src_vertex = vertex_id_1, .dest_vertex = vertex_id_2};
|
||||
msgs::NewExpand expand_2{
|
||||
.id = {.gid = 1}, .type = {edge_type_id}, .src_vertex = vertex_id_2, .dest_vertex = vertex_id_1};
|
||||
new_expands.push_back(std::move(expand_1));
|
||||
new_expands.push_back(std::move(expand_2));
|
||||
|
||||
auto responses = shard_request_manager.Request(state, std::move(new_expands));
|
||||
MG_ASSERT(responses.size() == 1);
|
||||
MG_ASSERT(responses[0].success);
|
||||
}
|
||||
|
||||
void TestExpandOne(msgs::ShardRequestManagerInterface &shard_request_manager) {
|
||||
msgs::ExecutionState<msgs::ExpandOneRequest> state{};
|
||||
msgs::ExpandOneRequest request;
|
||||
const auto edge_type_id = shard_request_manager.NameToEdgeType("edge_type");
|
||||
const auto label = msgs::Label{shard_request_manager.NameToLabel("test_label")};
|
||||
request.src_vertices.push_back(msgs::VertexId{label, {msgs::Value(int64_t(0)), msgs::Value(int64_t(0))}});
|
||||
request.edge_types.push_back(msgs::EdgeType{edge_type_id});
|
||||
request.direction = msgs::EdgeDirection::BOTH;
|
||||
auto result_rows = shard_request_manager.Request(state, std::move(request));
|
||||
MG_ASSERT(result_rows.size() == 1);
|
||||
MG_ASSERT(result_rows[0].in_edges_with_all_properties.size() == 1);
|
||||
MG_ASSERT(result_rows[0].out_edges_with_all_properties.size() == 1);
|
||||
}
|
||||
|
||||
template <typename ShardRequestManager>
|
||||
void TestAggregate(ShardRequestManager &shard_request_manager) {}
|
||||
@@ -198,6 +230,8 @@ TEST(MachineManager, BasicFunctionality) {
|
||||
shard_request_manager.StartTransaction();
|
||||
TestCreateVertices(shard_request_manager);
|
||||
TestScanAll(shard_request_manager);
|
||||
TestCreateExpand(shard_request_manager);
|
||||
TestExpandOne(shard_request_manager);
|
||||
local_system.ShutDown();
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user