Skip to content

Commit 9163154

Browse files
author
simon
committed
refactor: stop creating PropertyGraphs with no storage prefix
Some instances of this behavior can be replaced with MakeEphemeral() and some can be replaced with a call that provides a storage prefix.
1 parent 4c1f8a3 commit 9163154

File tree

8 files changed

+23
-12
lines changed

8 files changed

+23
-12
lines changed

libgraph/include/katana/analytics/ClusteringImplementationBase.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -493,7 +493,9 @@ struct ClusteringImplementationBase {
493493
// Thus any property index indirection of the original topology has to be dropped.
494494
katana::GraphTopology topo_copy =
495495
GraphTopology::CopyWithoutPropertyIndexes(pfg_from.topology());
496-
return katana::PropertyGraph::Make(std::move(topo_copy));
496+
// PR question: is this okay? My guess is that this will be written to
497+
// rarely if ever?
498+
return katana::PropertyGraph::MakeEphemeral(std::move(topo_copy));
497499
}
498500

499501
/**
@@ -681,7 +683,8 @@ struct ClusteringImplementationBase {
681683

682684
GraphTopology topo_next{
683685
std::move(prefix_edges_count), std::move(out_dests_next)};
684-
auto pfg_next_res = katana::PropertyGraph::Make(std::move(topo_next));
686+
auto pfg_next_res =
687+
katana::PropertyGraph::MakeEphemeral(std::move(topo_next));
685688

686689
if (!pfg_next_res) {
687690
return pfg_next_res.error();

libgraph/src/BuildGraph.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1834,7 +1834,8 @@ ImportData::ValueFromArrowScalar(std::shared_ptr<arrow::Scalar> scalar) {
18341834
katana::Result<std::unique_ptr<katana::PropertyGraph>>
18351835
katana::ConvertToPropertyGraph(
18361836
katana::GraphComponents&& graph_comps, katana::TxnContext* txn_ctx) {
1837-
auto pg_result = katana::PropertyGraph::Make(std::move(graph_comps.topology));
1837+
auto pg_result =
1838+
katana::PropertyGraph::MakeEphemeral(std::move(graph_comps.topology));
18381839
if (!pg_result) {
18391840
return pg_result.error().WithContext("adding topology");
18401841
}

libgraph/src/TopologyGeneration.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ MakeTopologyImpl(F builder_fun) {
88
builder_fun(builder);
99

1010
katana::GraphTopology topo = builder.ConvertToCSR();
11-
auto res = katana::PropertyGraph::Make(std::move(topo));
11+
auto res = katana::PropertyGraph::MakeEphemeral(std::move(topo));
1212
KATANA_LOG_ASSERT(res);
1313
return std::move(res.value());
1414
}

libgraph/src/analytics/subgraph_extraction/subgraph_extraction.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ SubGraphNodeSet(
8686

8787
katana::GraphTopology sub_g_topo{
8888
std::move(out_indices), std::move(out_dests)};
89-
auto sub_g_res = katana::PropertyGraph::Make(std::move(sub_g_topo));
89+
auto sub_g_res = katana::PropertyGraph::MakeEphemeral(std::move(sub_g_topo));
9090

9191
return sub_g_res;
9292
}

libgraph/test/TestTypedPropertyGraph.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ MakeFileGraph(
8080
katana::GraphTopology topo{
8181
indices.data(), indices.size(), dests.data(), dests.size()};
8282

83-
auto g_res = katana::PropertyGraph::Make(std::move(topo));
83+
auto g_res = katana::PropertyGraph::MakeEphemeral(std::move(topo));
8484
KATANA_LOG_ASSERT(g_res);
8585

8686
std::unique_ptr<katana::PropertyGraph> g = std::move(g_res.value());

libgraph/test/property-graph-transposed-view.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,12 @@ TestTransposedView() {
2222
builder_tr.AddEdge(n2, n1);
2323
}
2424

25-
auto pg = KATANA_CHECKED(PropertyGraph::Make(builder.ConvertToCSR()));
25+
auto pg =
26+
KATANA_CHECKED(PropertyGraph::MakeEphemeral(builder.ConvertToCSR()));
2627
TransposedGraphView pg_tr_view = pg->BuildView<TransposedGraphView>();
2728

28-
auto pg_tr = KATANA_CHECKED(PropertyGraph::Make(builder_tr.ConvertToCSR()));
29+
auto pg_tr =
30+
KATANA_CHECKED(PropertyGraph::MakeEphemeral(builder_tr.ConvertToCSR()));
2931

3032
for (Edge e : pg_tr_view.OutEdges()) {
3133
KATANA_LOG_VASSERT(

libkatana_python_native/src/ImportData.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ katana::python::InitImportData(py::module& m) {
3939
[](py::array_t<PropertyGraph::Edge> edge_indices,
4040
py::array_t<PropertyGraph::Node> edge_destinations)
4141
-> Result<std::shared_ptr<PropertyGraph>> {
42-
return KATANA_CHECKED(katana::PropertyGraph::Make(
42+
return KATANA_CHECKED(katana::PropertyGraph::MakeEphemeral(
4343
TopologyFromCSR(edge_indices, edge_destinations)));
4444
},
4545
R"""(
@@ -75,7 +75,7 @@ katana::python::InitImportData(py::module& m) {
7575
edge_types_owned.begin());
7676
EntityTypeManager node_type_manager_owned = node_type_manager;
7777
EntityTypeManager edge_type_manager_owned = edge_type_manager;
78-
return KATANA_CHECKED(katana::PropertyGraph::Make(
78+
return KATANA_CHECKED(katana::PropertyGraph::MakeEphemeral(
7979
TopologyFromCSR(edge_indices, edge_destinations),
8080
std::move(node_types_owned), std::move(edge_types_owned),
8181
std::move(node_type_manager_owned),

tools/graph-convert/graph-convert.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3011,7 +3011,12 @@ struct Gr2Kg : public Conversion {
30113011
}
30123012

30133013
katana::GraphTopology topo{std::move(out_indices), std::move(out_dests)};
3014-
auto pg_res = katana::PropertyGraph::Make(std::move(topo));
3014+
auto rdg_dir_res = katana::URI::Make(out_file_name);
3015+
if (!rdg_dir_res) {
3016+
KATANA_LOG_FATAL("Failed to create PropertyGraph storage URI");
3017+
}
3018+
auto pg_res =
3019+
katana::PropertyGraph::Make(rdg_dir_res.value(), std::move(topo));
30153020
if (!pg_res) {
30163021
KATANA_LOG_FATAL("Failed to create PropertyGraph");
30173022
}
@@ -3030,7 +3035,7 @@ struct Gr2Kg : public Conversion {
30303035
katana::gPrint(
30313036
"Node Schema : ", pg->loaded_node_schema()->ToString(), "\n");
30323037

3033-
if (auto r = pg->Write(out_file_name, "cmd", &txn_ctx); !r) {
3038+
if (auto r = pg->Commit("cmd", &txn_ctx); !r) {
30343039
KATANA_LOG_FATAL("Failed to write property file graph: {}", r.error());
30353040
}
30363041
printStatus(graph.size(), graph.sizeEdges());

0 commit comments

Comments
 (0)