Skip to content

Commit

Permalink
refactor: stop creating PropertyGraphs with no storage prefix
Browse files Browse the repository at this point in the history
Some instances of this behavior can be replaced with MakeEphemeral() and
some can be replaced with a call that provides a storage prefix.
  • Loading branch information
simon committed Mar 11, 2022
1 parent 4c1f8a3 commit 9163154
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,9 @@ struct ClusteringImplementationBase {
// Thus any property index indirection of the original topology has to be dropped.
katana::GraphTopology topo_copy =
GraphTopology::CopyWithoutPropertyIndexes(pfg_from.topology());
return katana::PropertyGraph::Make(std::move(topo_copy));
// PR question: is this okay? My guess is that this will be written to
// rarely if ever?
return katana::PropertyGraph::MakeEphemeral(std::move(topo_copy));
}

/**
Expand Down Expand Up @@ -681,7 +683,8 @@ struct ClusteringImplementationBase {

GraphTopology topo_next{
std::move(prefix_edges_count), std::move(out_dests_next)};
auto pfg_next_res = katana::PropertyGraph::Make(std::move(topo_next));
auto pfg_next_res =
katana::PropertyGraph::MakeEphemeral(std::move(topo_next));

if (!pfg_next_res) {
return pfg_next_res.error();
Expand Down
3 changes: 2 additions & 1 deletion libgraph/src/BuildGraph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1834,7 +1834,8 @@ ImportData::ValueFromArrowScalar(std::shared_ptr<arrow::Scalar> scalar) {
katana::Result<std::unique_ptr<katana::PropertyGraph>>
katana::ConvertToPropertyGraph(
katana::GraphComponents&& graph_comps, katana::TxnContext* txn_ctx) {
auto pg_result = katana::PropertyGraph::Make(std::move(graph_comps.topology));
auto pg_result =
katana::PropertyGraph::MakeEphemeral(std::move(graph_comps.topology));
if (!pg_result) {
return pg_result.error().WithContext("adding topology");
}
Expand Down
2 changes: 1 addition & 1 deletion libgraph/src/TopologyGeneration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ MakeTopologyImpl(F builder_fun) {
builder_fun(builder);

katana::GraphTopology topo = builder.ConvertToCSR();
auto res = katana::PropertyGraph::Make(std::move(topo));
auto res = katana::PropertyGraph::MakeEphemeral(std::move(topo));
KATANA_LOG_ASSERT(res);
return std::move(res.value());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ SubGraphNodeSet(

katana::GraphTopology sub_g_topo{
std::move(out_indices), std::move(out_dests)};
auto sub_g_res = katana::PropertyGraph::Make(std::move(sub_g_topo));
auto sub_g_res = katana::PropertyGraph::MakeEphemeral(std::move(sub_g_topo));

return sub_g_res;
}
Expand Down
2 changes: 1 addition & 1 deletion libgraph/test/TestTypedPropertyGraph.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ MakeFileGraph(
katana::GraphTopology topo{
indices.data(), indices.size(), dests.data(), dests.size()};

auto g_res = katana::PropertyGraph::Make(std::move(topo));
auto g_res = katana::PropertyGraph::MakeEphemeral(std::move(topo));
KATANA_LOG_ASSERT(g_res);

std::unique_ptr<katana::PropertyGraph> g = std::move(g_res.value());
Expand Down
6 changes: 4 additions & 2 deletions libgraph/test/property-graph-transposed-view.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,12 @@ TestTransposedView() {
builder_tr.AddEdge(n2, n1);
}

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

auto pg_tr = KATANA_CHECKED(PropertyGraph::Make(builder_tr.ConvertToCSR()));
auto pg_tr =
KATANA_CHECKED(PropertyGraph::MakeEphemeral(builder_tr.ConvertToCSR()));

for (Edge e : pg_tr_view.OutEdges()) {
KATANA_LOG_VASSERT(
Expand Down
4 changes: 2 additions & 2 deletions libkatana_python_native/src/ImportData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ katana::python::InitImportData(py::module& m) {
[](py::array_t<PropertyGraph::Edge> edge_indices,
py::array_t<PropertyGraph::Node> edge_destinations)
-> Result<std::shared_ptr<PropertyGraph>> {
return KATANA_CHECKED(katana::PropertyGraph::Make(
return KATANA_CHECKED(katana::PropertyGraph::MakeEphemeral(
TopologyFromCSR(edge_indices, edge_destinations)));
},
R"""(
Expand Down Expand Up @@ -75,7 +75,7 @@ katana::python::InitImportData(py::module& m) {
edge_types_owned.begin());
EntityTypeManager node_type_manager_owned = node_type_manager;
EntityTypeManager edge_type_manager_owned = edge_type_manager;
return KATANA_CHECKED(katana::PropertyGraph::Make(
return KATANA_CHECKED(katana::PropertyGraph::MakeEphemeral(
TopologyFromCSR(edge_indices, edge_destinations),
std::move(node_types_owned), std::move(edge_types_owned),
std::move(node_type_manager_owned),
Expand Down
9 changes: 7 additions & 2 deletions tools/graph-convert/graph-convert.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3011,7 +3011,12 @@ struct Gr2Kg : public Conversion {
}

katana::GraphTopology topo{std::move(out_indices), std::move(out_dests)};
auto pg_res = katana::PropertyGraph::Make(std::move(topo));
auto rdg_dir_res = katana::URI::Make(out_file_name);
if (!rdg_dir_res) {
KATANA_LOG_FATAL("Failed to create PropertyGraph storage URI");
}
auto pg_res =
katana::PropertyGraph::Make(rdg_dir_res.value(), std::move(topo));
if (!pg_res) {
KATANA_LOG_FATAL("Failed to create PropertyGraph");
}
Expand All @@ -3030,7 +3035,7 @@ struct Gr2Kg : public Conversion {
katana::gPrint(
"Node Schema : ", pg->loaded_node_schema()->ToString(), "\n");

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

0 comments on commit 9163154

Please sign in to comment.