Skip to content

Commit b61678a

Browse files
authored
[BugFix][C++]: Fix VertexInfo/EdgeInfo can not be saved to a URI path (#395)
1 parent da86711 commit b61678a

2 files changed

Lines changed: 23 additions & 2 deletions

File tree

cpp/src/graph_info.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -478,7 +478,7 @@ Status VertexInfo::Save(const std::string& path) const {
478478
std::string no_url_path;
479479
GAR_ASSIGN_OR_RAISE(auto fs, FileSystemFromUriOrPath(path, &no_url_path));
480480
GAR_ASSIGN_OR_RAISE(auto yaml_content, this->Dump());
481-
return fs->WriteValueToFile(yaml_content, path);
481+
return fs->WriteValueToFile(yaml_content, no_url_path);
482482
}
483483

484484
class EdgeInfo::Impl {
@@ -964,7 +964,7 @@ Status EdgeInfo::Save(const std::string& path) const {
964964
std::string no_url_path;
965965
GAR_ASSIGN_OR_RAISE(auto fs, FileSystemFromUriOrPath(path, &no_url_path));
966966
GAR_ASSIGN_OR_RAISE(auto yaml_content, this->Dump());
967-
return fs->WriteValueToFile(yaml_content, path);
967+
return fs->WriteValueToFile(yaml_content, no_url_path);
968968
}
969969

970970
namespace {

cpp/test/test_info.cc

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,13 @@ version: gar/v1
274274
REQUIRE(vertex_info_empty_version->Dump().status().ok());
275275
}
276276

277+
SECTION("Save") {
278+
// save to a simple output path
279+
REQUIRE(vertex_info->Save("/tmp/" + label + ".vertex.yml").ok());
280+
// save to a URI path
281+
REQUIRE(vertex_info->Save("file:///tmp/" + label + ".vertex.yml").ok());
282+
}
283+
277284
SECTION("AddPropertyGroup") {
278285
auto pg2 = CreatePropertyGroup({Property("p2", int32(), false)},
279286
FileType::CSV, "p2/");
@@ -467,6 +474,13 @@ version: gar/v1
467474
REQUIRE(edge_info_empty_version->Dump().status().ok());
468475
}
469476

477+
SECTION("Save") {
478+
// save to a simple output path
479+
REQUIRE(edge_info->Save("/tmp/" + edge_label + ".edge.yml").ok());
480+
// save to a URI path
481+
REQUIRE(edge_info->Save("file:///tmp/" + edge_label + ".edge.yml").ok());
482+
}
483+
470484
SECTION("AddAdjacentList") {
471485
auto adj_list2 = CreateAdjacentList(AdjListType::ordered_by_dest,
472486
FileType::CSV, "ordered_by_dest/");
@@ -619,6 +633,13 @@ version: gar/v1
619633
REQUIRE(graph_info_empty_version->Dump().status().ok());
620634
}
621635

636+
SECTION("Save") {
637+
// save to a simple output path
638+
REQUIRE(graph_info->Save("/tmp/" + name + ".graph.yml").ok());
639+
// save to a URI path
640+
REQUIRE(graph_info->Save("file:///tmp/" + name + ".graph.yml").ok());
641+
}
642+
622643
SECTION("AddVertex") {
623644
auto vertex_info2 =
624645
CreateVertexInfo("test_vertex2", 100, {pg}, "test_vertex2/", version);

0 commit comments

Comments
 (0)