diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt index 7e6060d70..8ef782da7 100644 --- a/cpp/CMakeLists.txt +++ b/cpp/CMakeLists.txt @@ -37,16 +37,10 @@ project(graph-archive LANGUAGES C CXX VERSION ${GAR_VERSION}) # cmake options # ------------------------------------------------------------------------------ -option(NAMESPACE "User specific namespace, default is graphar" OFF) option(BUILD_TESTS "Build unit tests" OFF) option(BUILD_EXAMPLES "Build examples" OFF) option(BUILD_BENCHMARKS "Build benchmarks" OFF) -if (NAMESPACE) - add_definitions(-DGAR_NAMESPACE=${NAMESPACE}) -else() - add_definitions(-DGAR_NAMESPACE=graphar) -endif() # ------------------------------------------------------------------------------ # setting default cmake type to Release # ------------------------------------------------------------------------------ diff --git a/cpp/README.md b/cpp/README.md index b10759b55..6babe5516 100644 --- a/cpp/README.md +++ b/cpp/README.md @@ -56,19 +56,6 @@ Release build: $ make -j8 # if you have 8 CPU cores, otherwise adjust, use -j`nproc` for all cores ``` -Build with a custom namespace: - -The `namespace` is configurable. By default, -it is defined in `namespace graphar`; however this can be toggled by -setting `NAMESPACE` option with cmake: - -```bash - $ mkdir build - $ cd build - $ cmake -DNAMESPACE=MyNamespace .. - $ make -j8 # if you have 8 CPU cores, otherwise adjust, use -j`nproc` for all cores -``` - Build the Apache Arrow dependency from source: By default, GraphAr try to find Apache Arrow in the system. This can be configured to build Arrow dependency automatically from source: diff --git a/cpp/benchmarks/arrow_chunk_reader_benchmark.cc b/cpp/benchmarks/arrow_chunk_reader_benchmark.cc index 728518b42..78341639e 100644 --- a/cpp/benchmarks/arrow_chunk_reader_benchmark.cc +++ b/cpp/benchmarks/arrow_chunk_reader_benchmark.cc @@ -21,7 +21,7 @@ #include "gar/reader/arrow_chunk_reader.h" #include "gar/util/adj_list_type.h" -namespace GAR_NAMESPACE_INTERNAL { +namespace graphar { BENCHMARK_DEFINE_F(BenchmarkFixture, CreateVertexPropertyArrowChunkReader) (::benchmark::State& state) { // NOLINT @@ -149,4 +149,4 @@ BENCHMARK_REGISTER_F(BenchmarkFixture, VertexPropertyArrowChunkReaderReadChunk); BENCHMARK_REGISTER_F(BenchmarkFixture, AdjListArrowChunkReaderReadChunk); BENCHMARK_REGISTER_F(BenchmarkFixture, AdjListOffsetArrowChunkReaderReadChunk); BENCHMARK_REGISTER_F(BenchmarkFixture, AdjListOffsetArrowChunkReaderReadChunk); -} // namespace GAR_NAMESPACE_INTERNAL +} // namespace graphar diff --git a/cpp/benchmarks/benchmark_util.h b/cpp/benchmarks/benchmark_util.h index 9c026dcb6..bdeb8b07f 100644 --- a/cpp/benchmarks/benchmark_util.h +++ b/cpp/benchmarks/benchmark_util.h @@ -26,26 +26,26 @@ #ifndef CPP_BENCHMARKS_BENCHMARK_UTIL_H_ #define CPP_BENCHMARKS_BENCHMARK_UTIL_H_ -namespace GAR_NAMESPACE_INTERNAL { +namespace graphar { // Return the value of the GAR_TEST_DATA environment variable or return error // Status -GAR_NAMESPACE::Status GetTestResourceRoot(std::string* out) { +Status GetTestResourceRoot(std::string* out) { const char* c_root = std::getenv("GAR_TEST_DATA"); if (!c_root) { - return GAR_NAMESPACE::Status::IOError( + return Status::IOError( "Test resources not found, set GAR_TEST_DATA to /testing"); } // FIXME(@acezen): This is a hack to get around the fact that the testing *out = std::string(c_root); - return GAR_NAMESPACE::Status::OK(); + return Status::OK(); } class BenchmarkFixture : public ::benchmark::Fixture { public: void SetUp(const ::benchmark::State& state) override { std::string root; - GAR_NAMESPACE::Status status = GetTestResourceRoot(&root); + Status status = GetTestResourceRoot(&root); path_ = root + "/ldbc_sample/parquet/ldbc_sample.graph.yml"; auto maybe_graph_info = GraphInfo::Load(path_); graph_info_ = maybe_graph_info.value(); @@ -57,6 +57,6 @@ class BenchmarkFixture : public ::benchmark::Fixture { std::string path_; std::shared_ptr graph_info_; }; -} // namespace GAR_NAMESPACE_INTERNAL +} // namespace graphar #endif // CPP_BENCHMARKS_BENCHMARK_UTIL_H_ diff --git a/cpp/benchmarks/graph_info_benchmark.cc b/cpp/benchmarks/graph_info_benchmark.cc index 27bb11685..18022be68 100644 --- a/cpp/benchmarks/graph_info_benchmark.cc +++ b/cpp/benchmarks/graph_info_benchmark.cc @@ -19,7 +19,7 @@ #include "./benchmark_util.h" #include "gar/graph_info.h" -namespace GAR_NAMESPACE_INTERNAL { +namespace graphar { static void CreateGraphInfo(::benchmark::State& state, // NOLINT const std::string& path) { @@ -38,4 +38,4 @@ BENCHMARK_DEFINE_F(BenchmarkFixture, InitialGraphInfo) } BENCHMARK_REGISTER_F(BenchmarkFixture, InitialGraphInfo); -} // namespace GAR_NAMESPACE_INTERNAL +} // namespace graphar diff --git a/cpp/examples/bfs_father_example.cc b/cpp/examples/bfs_father_example.cc index ef3d63888..7d62c4475 100644 --- a/cpp/examples/bfs_father_example.cc +++ b/cpp/examples/bfs_father_example.cc @@ -29,13 +29,12 @@ int main(int argc, char* argv[]) { // read file and construct graph info std::string path = TEST_DATA_DIR + "/ldbc_sample/parquet/ldbc_sample.graph.yml"; - auto graph_info = GAR_NAMESPACE::GraphInfo::Load(path).value(); + auto graph_info = graphar::GraphInfo::Load(path).value(); // get the person vertices of graph std::string label = "person"; ASSERT(graph_info->GetVertexInfo(label) != nullptr); - auto maybe_vertices = - GAR_NAMESPACE::VerticesCollection::Make(graph_info, label); + auto maybe_vertices = graphar::VerticesCollection::Make(graph_info, label); ASSERT(maybe_vertices.status().ok()); auto vertices = maybe_vertices.value(); int num_vertices = vertices->size(); @@ -43,23 +42,23 @@ int main(int argc, char* argv[]) { // get the "person_knows_person" edges of graph std::string src_label = "person", edge_label = "knows", dst_label = "person"; - auto maybe_edges = GAR_NAMESPACE::EdgesCollection::Make( + auto maybe_edges = graphar::EdgesCollection::Make( graph_info, src_label, edge_label, dst_label, - GAR_NAMESPACE::AdjListType::unordered_by_source); + graphar::AdjListType::unordered_by_source); ASSERT(!maybe_edges.has_error()); auto& edges = maybe_edges.value(); // run bfs algorithm - GAR_NAMESPACE::IdType root = 0; + graphar::IdType root = 0; std::vector distance(num_vertices); - std::vector pre(num_vertices); - for (GAR_NAMESPACE::IdType i = 0; i < num_vertices; i++) { + std::vector pre(num_vertices); + for (graphar::IdType i = 0; i < num_vertices; i++) { distance[i] = (i == root ? 0 : -1); pre[i] = (i == root ? root : -1); } auto it_begin = edges->begin(), it_end = edges->end(); for (int iter = 0;; iter++) { - GAR_NAMESPACE::IdType count = 0; + graphar::IdType count = 0; for (auto it = it_begin; it != it_end; ++it) { auto src = it.source(), dst = it.destination(); if (distance[src] == iter && distance[dst] == -1) { @@ -80,11 +79,11 @@ int main(int argc, char* argv[]) { // Append the bfs result to the vertex info as a property group // and write to file // construct property group - GAR_NAMESPACE::Property bfs("bfs", GAR_NAMESPACE::int32(), false); - GAR_NAMESPACE::Property father("father", GAR_NAMESPACE::int64(), false); - std::vector property_vector = {bfs, father}; - auto group = GAR_NAMESPACE::CreatePropertyGroup(property_vector, - GAR_NAMESPACE::FileType::CSV); + graphar::Property bfs("bfs", graphar::int32(), false); + graphar::Property father("father", graphar::int64(), false); + std::vector property_vector = {bfs, father}; + auto group = + graphar::CreatePropertyGroup(property_vector, graphar::FileType::CSV); // extend the vertex_info auto vertex_info = graph_info->GetVertexInfo(label); @@ -97,15 +96,14 @@ int main(int argc, char* argv[]) { ASSERT(extend_info->Dump().status().ok()); ASSERT(extend_info->Save("/tmp/person-new-bfs-father.vertex.yml").ok()); // construct vertex property writer - GAR_NAMESPACE::VertexPropertyWriter writer(extend_info, "file:///tmp/"); + graphar::VertexPropertyWriter writer(extend_info, "file:///tmp/"); // convert results to arrow::Table std::vector> arrays; std::vector> schema_vector; schema_vector.push_back(arrow::field( - bfs.name, GAR_NAMESPACE::DataType::DataTypeToArrowDataType(bfs.type))); + bfs.name, graphar::DataType::DataTypeToArrowDataType(bfs.type))); schema_vector.push_back(arrow::field( - father.name, - GAR_NAMESPACE::DataType::DataTypeToArrowDataType(father.type))); + father.name, graphar::DataType::DataTypeToArrowDataType(father.type))); arrow::Int32Builder array_builder1; ASSERT(array_builder1.Reserve(num_vertices).ok()); ASSERT(array_builder1.AppendValues(distance).ok()); @@ -137,24 +135,23 @@ int main(int argc, char* argv[]) { dst_label = "person"; int edge_chunk_size = 1024, src_chunk_size = 100, dst_chunk_size = 100; bool directed = true; - auto version = GAR_NAMESPACE::InfoVersion::Parse("gar/v1").value(); - auto al = GAR_NAMESPACE::CreateAdjacentList( - GAR_NAMESPACE::AdjListType::ordered_by_source, - GAR_NAMESPACE::FileType::CSV); - auto new_edge_info = GAR_NAMESPACE::CreateEdgeInfo( + auto version = graphar::InfoVersion::Parse("gar/v1").value(); + auto al = graphar::CreateAdjacentList(graphar::AdjListType::ordered_by_source, + graphar::FileType::CSV); + auto new_edge_info = graphar::CreateEdgeInfo( src_label, edge_label, dst_label, edge_chunk_size, src_chunk_size, dst_chunk_size, directed, {al}, {}, "", version); ASSERT(new_edge_info->IsValidated()); // save & dump ASSERT(!new_edge_info->Dump().has_error()); ASSERT(new_edge_info->Save("/tmp/person_bfs_person.edge.yml").ok()); - GAR_NAMESPACE::builder::EdgesBuilder edges_builder( - new_edge_info, "file:///tmp/", - GAR_NAMESPACE::AdjListType::ordered_by_source, num_vertices); + graphar::builder::EdgesBuilder edges_builder( + new_edge_info, "file:///tmp/", graphar::AdjListType::ordered_by_source, + num_vertices); for (int i = 0; i < num_vertices; i++) { if (i == root || pre[i] == -1) continue; - GAR_NAMESPACE::builder::Edge e(pre[i], i); + graphar::builder::Edge e(pre[i], i); ASSERT(edges_builder.AddEdge(e).ok()); } ASSERT(edges_builder.Dump().ok()); diff --git a/cpp/examples/bfs_pull_example.cc b/cpp/examples/bfs_pull_example.cc index 9480bd9d6..b3ae66e1e 100644 --- a/cpp/examples/bfs_pull_example.cc +++ b/cpp/examples/bfs_pull_example.cc @@ -28,13 +28,12 @@ int main(int argc, char* argv[]) { // read file and construct graph info std::string path = TEST_DATA_DIR + "/ldbc_sample/parquet/ldbc_sample.graph.yml"; - auto graph_info = GAR_NAMESPACE::GraphInfo::Load(path).value(); + auto graph_info = graphar::GraphInfo::Load(path).value(); // construct vertices collection std::string label = "person"; ASSERT(graph_info->GetVertexInfo(label) != nullptr); - auto maybe_vertices = - GAR_NAMESPACE::VerticesCollection::Make(graph_info, label); + auto maybe_vertices = graphar::VerticesCollection::Make(graph_info, label); ASSERT(maybe_vertices.status().ok()); auto& vertices = maybe_vertices.value(); int num_vertices = vertices->size(); @@ -42,29 +41,29 @@ int main(int argc, char* argv[]) { // construct edges collection std::string src_label = "person", edge_label = "knows", dst_label = "person"; - auto maybe_edges = GAR_NAMESPACE::EdgesCollection::Make( + auto maybe_edges = graphar::EdgesCollection::Make( graph_info, src_label, edge_label, dst_label, - GAR_NAMESPACE::AdjListType::ordered_by_dest); + graphar::AdjListType::ordered_by_dest); ASSERT(!maybe_edges.has_error()); auto& edges = maybe_edges.value(); // run bfs algorithm - GAR_NAMESPACE::IdType root = 0; + graphar::IdType root = 0; std::vector distance(num_vertices); - for (GAR_NAMESPACE::IdType i = 0; i < num_vertices; i++) + for (graphar::IdType i = 0; i < num_vertices; i++) distance[i] = (i == root ? 0 : -1); auto it_begin = edges->begin(), it_end = edges->end(); auto it = it_begin; for (int iter = 0;; iter++) { - GAR_NAMESPACE::IdType count = 0; + graphar::IdType count = 0; it.to_begin(); - for (GAR_NAMESPACE::IdType vid = 0; vid < num_vertices; vid++) { + for (graphar::IdType vid = 0; vid < num_vertices; vid++) { if (distance[vid] == -1) { if (!it.first_dst(it, vid)) continue; // if (!it.first_dst(it_begin, vid)) continue; do { - GAR_NAMESPACE::IdType src = it.source(), dst = it.destination(); + graphar::IdType src = it.source(), dst = it.destination(); if (distance[src] == iter) { distance[dst] = distance[src] + 1; count++; @@ -83,10 +82,10 @@ int main(int argc, char* argv[]) { // extend the original vertex info and write results to gar using writer // construct property group - GAR_NAMESPACE::Property bfs("bfs-pull", GAR_NAMESPACE::int32(), false); - std::vector property_vector = {bfs}; - auto group = GAR_NAMESPACE::CreatePropertyGroup( - property_vector, GAR_NAMESPACE::FileType::PARQUET); + graphar::Property bfs("bfs-pull", graphar::int32(), false); + std::vector property_vector = {bfs}; + auto group = + graphar::CreatePropertyGroup(property_vector, graphar::FileType::PARQUET); // extend the vertex_info auto vertex_info = graph_info->GetVertexInfo(label); auto maybe_extend_info = vertex_info->AddPropertyGroup(group); @@ -97,12 +96,12 @@ int main(int argc, char* argv[]) { ASSERT(extend_info->Dump().status().ok()); ASSERT(extend_info->Save("/tmp/person-new-bfs-pull.vertex.yml").ok()); // construct vertex property writer - GAR_NAMESPACE::VertexPropertyWriter writer(extend_info, "/tmp/"); + graphar::VertexPropertyWriter writer(extend_info, "/tmp/"); // convert results to arrow::Table std::vector> arrays; std::vector> schema_vector; schema_vector.push_back(arrow::field( - bfs.name, GAR_NAMESPACE::DataType::DataTypeToArrowDataType(bfs.type))); + bfs.name, graphar::DataType::DataTypeToArrowDataType(bfs.type))); arrow::Int32Builder array_builder; ASSERT(array_builder.Reserve(num_vertices).ok()); ASSERT(array_builder.AppendValues(distance).ok()); diff --git a/cpp/examples/bfs_push_example.cc b/cpp/examples/bfs_push_example.cc index d3e803cec..c6190563e 100644 --- a/cpp/examples/bfs_push_example.cc +++ b/cpp/examples/bfs_push_example.cc @@ -28,13 +28,12 @@ int main(int argc, char* argv[]) { // read file and construct graph info std::string path = TEST_DATA_DIR + "/ldbc_sample/parquet/ldbc_sample.graph.yml"; - auto graph_info = GAR_NAMESPACE::GraphInfo::Load(path).value(); + auto graph_info = graphar::GraphInfo::Load(path).value(); // construct vertices collection std::string label = "person"; ASSERT(graph_info->GetVertexInfo(label) != nullptr); - auto maybe_vertices = - GAR_NAMESPACE::VerticesCollection::Make(graph_info, label); + auto maybe_vertices = graphar::VerticesCollection::Make(graph_info, label); ASSERT(maybe_vertices.status().ok()); auto& vertices = maybe_vertices.value(); int num_vertices = vertices->size(); @@ -42,29 +41,29 @@ int main(int argc, char* argv[]) { // construct edges collection std::string src_label = "person", edge_label = "knows", dst_label = "person"; - auto maybe_edges = GAR_NAMESPACE::EdgesCollection::Make( + auto maybe_edges = graphar::EdgesCollection::Make( graph_info, src_label, edge_label, dst_label, - GAR_NAMESPACE::AdjListType::ordered_by_source); + graphar::AdjListType::ordered_by_source); ASSERT(!maybe_edges.has_error()); auto& edges = maybe_edges.value(); // run bfs algorithm - GAR_NAMESPACE::IdType root = 0; + graphar::IdType root = 0; std::vector distance(num_vertices); - for (GAR_NAMESPACE::IdType i = 0; i < num_vertices; i++) + for (graphar::IdType i = 0; i < num_vertices; i++) distance[i] = (i == root ? 0 : -1); auto it_begin = edges->begin(), it_end = edges->end(); auto it = it_begin; for (int iter = 0;; iter++) { - GAR_NAMESPACE::IdType count = 0; + graphar::IdType count = 0; it.to_begin(); - for (GAR_NAMESPACE::IdType vid = 0; vid < num_vertices; vid++) { + for (graphar::IdType vid = 0; vid < num_vertices; vid++) { if (distance[vid] == iter) { if (!it.first_src(it, vid)) continue; // if (!it.first_src(it_begin, vid)) continue; do { - GAR_NAMESPACE::IdType src = it.source(), dst = it.destination(); + graphar::IdType src = it.source(), dst = it.destination(); if (distance[dst] == -1) { distance[dst] = distance[src] + 1; count++; @@ -82,10 +81,10 @@ int main(int argc, char* argv[]) { // extend the original vertex info and write results to gar using writer // construct property group - GAR_NAMESPACE::Property bfs("bfs-push", GAR_NAMESPACE::int32(), false); - std::vector property_vector = {bfs}; - auto group = GAR_NAMESPACE::CreatePropertyGroup( - property_vector, GAR_NAMESPACE::FileType::PARQUET); + graphar::Property bfs("bfs-push", graphar::int32(), false); + std::vector property_vector = {bfs}; + auto group = + graphar::CreatePropertyGroup(property_vector, graphar::FileType::PARQUET); // extend the vertex_info auto vertex_info = graph_info->GetVertexInfo(label); auto maybe_extend_info = vertex_info->AddPropertyGroup(group); @@ -96,12 +95,12 @@ int main(int argc, char* argv[]) { ASSERT(extend_info->Dump().status().ok()); ASSERT(extend_info->Save("/tmp/person-new-bfs-push.vertex.yml").ok()); // construct vertex property writer - GAR_NAMESPACE::VertexPropertyWriter writer(extend_info, "/tmp/"); + graphar::VertexPropertyWriter writer(extend_info, "/tmp/"); // convert results to arrow::Table std::vector> arrays; std::vector> schema_vector; schema_vector.push_back(arrow::field( - bfs.name, GAR_NAMESPACE::DataType::DataTypeToArrowDataType(bfs.type))); + bfs.name, graphar::DataType::DataTypeToArrowDataType(bfs.type))); arrow::Int32Builder array_builder; ASSERT(array_builder.Reserve(num_vertices).ok()); ASSERT(array_builder.AppendValues(distance).ok()); diff --git a/cpp/examples/bfs_stream_example.cc b/cpp/examples/bfs_stream_example.cc index 250145337..41e3fefb7 100644 --- a/cpp/examples/bfs_stream_example.cc +++ b/cpp/examples/bfs_stream_example.cc @@ -28,13 +28,12 @@ int main(int argc, char* argv[]) { // read file and construct graph info std::string path = TEST_DATA_DIR + "/ldbc_sample/parquet/ldbc_sample.graph.yml"; - auto graph_info = GAR_NAMESPACE::GraphInfo::Load(path).value(); + auto graph_info = graphar::GraphInfo::Load(path).value(); // construct vertices collection std::string label = "person"; ASSERT(graph_info->GetVertexInfo(label) != nullptr); - auto maybe_vertices = - GAR_NAMESPACE::VerticesCollection::Make(graph_info, label); + auto maybe_vertices = graphar::VerticesCollection::Make(graph_info, label); ASSERT(maybe_vertices.status().ok()); auto& vertices = maybe_vertices.value(); int num_vertices = vertices->size(); @@ -42,22 +41,22 @@ int main(int argc, char* argv[]) { // construct edges collection std::string src_label = "person", edge_label = "knows", dst_label = "person"; - auto maybe_edges = GAR_NAMESPACE::EdgesCollection::Make( + auto maybe_edges = graphar::EdgesCollection::Make( graph_info, src_label, edge_label, dst_label, - GAR_NAMESPACE::AdjListType::unordered_by_source); + graphar::AdjListType::unordered_by_source); ASSERT(!maybe_edges.has_error()); auto& edges = maybe_edges.value(); // run bfs algorithm - GAR_NAMESPACE::IdType root = 0; + graphar::IdType root = 0; std::vector distance(num_vertices); - for (GAR_NAMESPACE::IdType i = 0; i < num_vertices; i++) + for (graphar::IdType i = 0; i < num_vertices; i++) distance[i] = (i == root ? 0 : -1); auto it_begin = edges->begin(), it_end = edges->end(); for (int iter = 0;; iter++) { - GAR_NAMESPACE::IdType count = 0; + graphar::IdType count = 0; for (auto it = it_begin; it != it_end; ++it) { - GAR_NAMESPACE::IdType src = it.source(), dst = it.destination(); + graphar::IdType src = it.source(), dst = it.destination(); if (distance[src] == iter && distance[dst] == -1) { distance[dst] = distance[src] + 1; count++; @@ -73,10 +72,10 @@ int main(int argc, char* argv[]) { // extend the original vertex info and write results to gar using writer // construct property group - GAR_NAMESPACE::Property bfs("bfs-stream", GAR_NAMESPACE::int32(), false); - std::vector property_vector = {bfs}; - auto group = GAR_NAMESPACE::CreatePropertyGroup( - property_vector, GAR_NAMESPACE::FileType::PARQUET); + graphar::Property bfs("bfs-stream", graphar::int32(), false); + std::vector property_vector = {bfs}; + auto group = + graphar::CreatePropertyGroup(property_vector, graphar::FileType::PARQUET); // extend the vertex_info auto vertex_info = graph_info->GetVertexInfo(label); auto maybe_extend_info = vertex_info->AddPropertyGroup(group); @@ -87,12 +86,12 @@ int main(int argc, char* argv[]) { ASSERT(extend_info->Dump().status().ok()); ASSERT(extend_info->Save("/tmp/person-new-bfs-stream.vertex.yml").ok()); // construct vertex property writer - GAR_NAMESPACE::VertexPropertyWriter writer(extend_info, "/tmp/"); + graphar::VertexPropertyWriter writer(extend_info, "/tmp/"); // convert results to arrow::Table std::vector> arrays; std::vector> schema_vector; schema_vector.push_back(arrow::field( - bfs.name, GAR_NAMESPACE::DataType::DataTypeToArrowDataType(bfs.type))); + bfs.name, graphar::DataType::DataTypeToArrowDataType(bfs.type))); arrow::Int32Builder array_builder; ASSERT(array_builder.Reserve(num_vertices).ok()); ASSERT(array_builder.AppendValues(distance).ok()); diff --git a/cpp/examples/bgl_example.cc b/cpp/examples/bgl_example.cc index fbceb4742..78ca7df10 100644 --- a/cpp/examples/bgl_example.cc +++ b/cpp/examples/bgl_example.cc @@ -33,15 +33,14 @@ int main(int argc, char* argv[]) { // read file and construct graph info std::string path = TEST_DATA_DIR + "/ldbc_sample/parquet/ldbc_sample.graph.yml"; - auto graph_info = GAR_NAMESPACE::GraphInfo::Load(path).value(); + auto graph_info = graphar::GraphInfo::Load(path).value(); ASSERT(graph_info->GetVertexInfos().size() == 1); ASSERT(graph_info->GetEdgeInfos().size() == 1); // construct vertices collection std::string label = "person"; ASSERT(graph_info->GetVertexInfo(label) != nullptr); - auto maybe_vertices = - GAR_NAMESPACE::VerticesCollection::Make(graph_info, label); + auto maybe_vertices = graphar::VerticesCollection::Make(graph_info, label); ASSERT(maybe_vertices.status().ok()); auto& vertices = maybe_vertices.value(); int num_vertices = vertices->size(); @@ -49,9 +48,9 @@ int main(int argc, char* argv[]) { // construct edges collection std::string src_label = "person", edge_label = "knows", dst_label = "person"; - auto maybe_edges = GAR_NAMESPACE::EdgesCollection::Make( + auto maybe_edges = graphar::EdgesCollection::Make( graph_info, src_label, edge_label, dst_label, - GAR_NAMESPACE::AdjListType::ordered_by_source); + graphar::AdjListType::ordered_by_source); ASSERT(!maybe_edges.has_error()); auto& edges = maybe_edges.value(); @@ -67,8 +66,7 @@ int main(int argc, char* argv[]) { typedef typename boost::graph_traits::vertex_descriptor Vertex; // declare a graph object with (num_vertices) vertices and a edge iterator - std::vector> - edges_array; + std::vector> edges_array; auto it_end = edges->end(); for (auto it = edges->begin(); it != it_end; ++it) { edges_array.push_back(std::make_pair(it.source(), it.destination())); @@ -104,26 +102,26 @@ int main(int argc, char* argv[]) { // method 1 for writing results: construct new vertex type and write results // using vertex builder construct new property group - GAR_NAMESPACE::Property cc("cc", GAR_NAMESPACE::int32(), false); - std::vector property_vector = {cc}; - auto group = GAR_NAMESPACE::CreatePropertyGroup( - property_vector, GAR_NAMESPACE::FileType::PARQUET); + graphar::Property cc("cc", graphar::int32(), false); + std::vector property_vector = {cc}; + auto group = + graphar::CreatePropertyGroup(property_vector, graphar::FileType::PARQUET); // construct new vertex info std::string vertex_label = "cc_result", vertex_prefix = "result/"; int chunk_size = 100; - auto version = GAR_NAMESPACE::InfoVersion::Parse("gar/v1").value(); - auto new_info = GAR_NAMESPACE::CreateVertexInfo( - vertex_label, chunk_size, {group}, vertex_prefix, version); + auto version = graphar::InfoVersion::Parse("gar/v1").value(); + auto new_info = graphar::CreateVertexInfo(vertex_label, chunk_size, {group}, + vertex_prefix, version); // dump new vertex info ASSERT(new_info->IsValidated()); ASSERT(new_info->Dump().status().ok()); ASSERT(new_info->Save("/tmp/cc_result.vertex.yml").ok()); // construct vertices builder - GAR_NAMESPACE::builder::VerticesBuilder builder(new_info, "/tmp/"); + graphar::builder::VerticesBuilder builder(new_info, "/tmp/"); // add vertices to the builder for (vp = boost::vertices(g); vp.first != vp.second; ++vp.first) { Vertex v = *vp.first; - GAR_NAMESPACE::builder::Vertex vertex(index[v]); + graphar::builder::Vertex vertex(index[v]); vertex.AddProperty(cc.name, component[index[v]]); builder.AddVertex(vertex); } @@ -142,12 +140,12 @@ int main(int argc, char* argv[]) { ASSERT(extend_info->Dump().status().ok()); ASSERT(extend_info->Save("/tmp/person-new.vertex.yml").ok()); // construct vertex property writer - GAR_NAMESPACE::VertexPropertyWriter writer(extend_info, "/tmp/"); + graphar::VertexPropertyWriter writer(extend_info, "/tmp/"); // convert results to arrow::Table std::vector> arrays; std::vector> schema_vector; schema_vector.push_back(arrow::field( - cc.name, GAR_NAMESPACE::DataType::DataTypeToArrowDataType(cc.type))); + cc.name, graphar::DataType::DataTypeToArrowDataType(cc.type))); arrow::MemoryPool* pool = arrow::default_memory_pool(); typename arrow::TypeTraits::BuilderType array_builder(pool); ASSERT(array_builder.Reserve(num_vertices).ok()); diff --git a/cpp/examples/cc_push_example.cc b/cpp/examples/cc_push_example.cc index f88c46a28..7ad8577cc 100644 --- a/cpp/examples/cc_push_example.cc +++ b/cpp/examples/cc_push_example.cc @@ -29,13 +29,12 @@ int main(int argc, char* argv[]) { // read file and construct graph info std::string path = TEST_DATA_DIR + "/ldbc_sample/parquet/ldbc_sample.graph.yml"; - auto graph_info = GAR_NAMESPACE::GraphInfo::Load(path).value(); + auto graph_info = graphar::GraphInfo::Load(path).value(); // construct vertices collection std::string label = "person"; ASSERT(graph_info->GetVertexInfo(label) != nullptr); - auto maybe_vertices = - GAR_NAMESPACE::VerticesCollection::Make(graph_info, label); + auto maybe_vertices = graphar::VerticesCollection::Make(graph_info, label); ASSERT(maybe_vertices.status().ok()); auto& vertices = maybe_vertices.value(); int num_vertices = vertices->size(); @@ -43,21 +42,21 @@ int main(int argc, char* argv[]) { // construct edges collection std::string src_label = "person", edge_label = "knows", dst_label = "person"; - auto expect1 = GAR_NAMESPACE::EdgesCollection::Make( + auto expect1 = graphar::EdgesCollection::Make( graph_info, src_label, edge_label, dst_label, - GAR_NAMESPACE::AdjListType::ordered_by_source); + graphar::AdjListType::ordered_by_source); ASSERT(!expect1.has_error()); auto& edges1 = expect1.value(); - auto expect2 = GAR_NAMESPACE::EdgesCollection::Make( + auto expect2 = graphar::EdgesCollection::Make( graph_info, src_label, edge_label, dst_label, - GAR_NAMESPACE::AdjListType::ordered_by_dest); + graphar::AdjListType::ordered_by_dest); ASSERT(!expect2.has_error()); auto& edges2 = expect2.value(); // run cc algorithm - std::vector component(num_vertices); + std::vector component(num_vertices); std::vector active[2]; - for (GAR_NAMESPACE::IdType i = 0; i < num_vertices; i++) { + for (graphar::IdType i = 0; i < num_vertices; i++) { component[i] = i; active[0].push_back(true); active[1].push_back(false); @@ -71,12 +70,12 @@ int main(int argc, char* argv[]) { std::cout << "iter " << iter << ": " << count << std::endl; std::fill(active[1 - iter % 2].begin(), active[1 - iter % 2].end(), 0); count = 0; - for (GAR_NAMESPACE::IdType vid = 0; vid < num_vertices; vid++) { + for (graphar::IdType vid = 0; vid < num_vertices; vid++) { if (active[iter % 2][vid]) { // find outgoing edges and update neighbors if (it1.first_src(begin1, vid)) { do { - GAR_NAMESPACE::IdType src = it1.source(), dst = it1.destination(); + graphar::IdType src = it1.source(), dst = it1.destination(); if (component[src] < component[dst]) { component[dst] = component[src]; if (!active[1 - iter % 2][dst]) { @@ -89,7 +88,7 @@ int main(int argc, char* argv[]) { // find incoming edges and update neighbors if (it2.first_dst(begin2, vid)) { do { - GAR_NAMESPACE::IdType src = it2.source(), dst = it2.destination(); + graphar::IdType src = it2.source(), dst = it2.destination(); if (component[dst] < component[src]) { component[src] = component[dst]; if (!active[1 - iter % 2][src]) { @@ -103,8 +102,8 @@ int main(int argc, char* argv[]) { } } // count the number of connected components - std::unordered_set cc_count; - GAR_NAMESPACE::IdType cc_num = 0; + std::unordered_set cc_count; + graphar::IdType cc_num = 0; for (int i = 0; i < num_vertices; i++) { std::cout << i << ", component id: " << component[i] << std::endl; if (cc_count.find(component[i]) == cc_count.end()) { @@ -116,10 +115,10 @@ int main(int argc, char* argv[]) { // extend the original vertex info and write results to gar using writer // construct property group - GAR_NAMESPACE::Property cc("cc-push", GAR_NAMESPACE::int64(), false); - std::vector property_vector = {cc}; - auto group = GAR_NAMESPACE::CreatePropertyGroup( - property_vector, GAR_NAMESPACE::FileType::PARQUET); + graphar::Property cc("cc-push", graphar::int64(), false); + std::vector property_vector = {cc}; + auto group = + graphar::CreatePropertyGroup(property_vector, graphar::FileType::PARQUET); // extend the vertex_info auto vertex_info = graph_info->GetVertexInfo(label); auto maybe_extend_info = vertex_info->AddPropertyGroup(group); @@ -130,12 +129,12 @@ int main(int argc, char* argv[]) { ASSERT(extend_info->Dump().status().ok()); ASSERT(extend_info->Save("/tmp/person-new-cc-push.vertex.yml").ok()); // construct vertex property writer - GAR_NAMESPACE::VertexPropertyWriter writer(extend_info, "/tmp/"); + graphar::VertexPropertyWriter writer(extend_info, "/tmp/"); // convert results to arrow::Table std::vector> arrays; std::vector> schema_vector; schema_vector.push_back(arrow::field( - cc.name, GAR_NAMESPACE::DataType::DataTypeToArrowDataType(cc.type))); + cc.name, graphar::DataType::DataTypeToArrowDataType(cc.type))); arrow::Int64Builder array_builder; ASSERT(array_builder.Reserve(num_vertices).ok()); ASSERT(array_builder.AppendValues(component).ok()); diff --git a/cpp/examples/cc_stream_example.cc b/cpp/examples/cc_stream_example.cc index 36893b71a..a29ebeda0 100644 --- a/cpp/examples/cc_stream_example.cc +++ b/cpp/examples/cc_stream_example.cc @@ -29,13 +29,12 @@ int main(int argc, char* argv[]) { // read file and construct graph info std::string path = TEST_DATA_DIR + "/ldbc_sample/parquet/ldbc_sample.graph.yml"; - auto graph_info = GAR_NAMESPACE::GraphInfo::Load(path).value(); + auto graph_info = graphar::GraphInfo::Load(path).value(); // construct vertices collection std::string label = "person"; ASSERT(graph_info->GetVertexInfo(label) != nullptr); - auto maybe_vertices = - GAR_NAMESPACE::VerticesCollection::Make(graph_info, label); + auto maybe_vertices = graphar::VerticesCollection::Make(graph_info, label); ASSERT(maybe_vertices.status().ok()); auto& vertices = maybe_vertices.value(); int num_vertices = vertices->size(); @@ -43,22 +42,22 @@ int main(int argc, char* argv[]) { // construct edges collection std::string src_label = "person", edge_label = "knows", dst_label = "person"; - auto maybe_edges = GAR_NAMESPACE::EdgesCollection::Make( + auto maybe_edges = graphar::EdgesCollection::Make( graph_info, src_label, edge_label, dst_label, - GAR_NAMESPACE::AdjListType::ordered_by_source); + graphar::AdjListType::ordered_by_source); ASSERT(!maybe_edges.has_error()); auto& edges = maybe_edges.value(); // run cc algorithm - std::vector component(num_vertices); - for (GAR_NAMESPACE::IdType i = 0; i < num_vertices; i++) + std::vector component(num_vertices); + for (graphar::IdType i = 0; i < num_vertices; i++) component[i] = i; auto it_begin = edges->begin(), it_end = edges->end(); for (int iter = 0;; iter++) { std::cout << "iter " << iter << std::endl; bool flag = false; for (auto it = it_begin; it != it_end; ++it) { - GAR_NAMESPACE::IdType src = it.source(), dst = it.destination(); + graphar::IdType src = it.source(), dst = it.destination(); if (component[src] < component[dst]) { component[dst] = component[src]; flag = true; @@ -71,8 +70,8 @@ int main(int argc, char* argv[]) { break; } // count the number of connected components - std::unordered_set cc_count; - GAR_NAMESPACE::IdType cc_num = 0; + std::unordered_set cc_count; + graphar::IdType cc_num = 0; for (int i = 0; i < num_vertices; i++) { std::cout << i << ", component id: " << component[i] << std::endl; if (cc_count.find(component[i]) == cc_count.end()) { @@ -84,10 +83,10 @@ int main(int argc, char* argv[]) { // extend the original vertex info and write results to gar using writer // construct property group - GAR_NAMESPACE::Property cc("cc", GAR_NAMESPACE::int64(), false); - std::vector property_vector = {cc}; - auto group = GAR_NAMESPACE::CreatePropertyGroup( - property_vector, GAR_NAMESPACE::FileType::PARQUET); + graphar::Property cc("cc", graphar::int64(), false); + std::vector property_vector = {cc}; + auto group = + graphar::CreatePropertyGroup(property_vector, graphar::FileType::PARQUET); // extend the vertex_info auto vertex_info = graph_info->GetVertexInfo(label); auto maybe_extend_info = vertex_info->AddPropertyGroup(group); @@ -98,12 +97,12 @@ int main(int argc, char* argv[]) { ASSERT(extend_info->Dump().status().ok()); ASSERT(extend_info->Save("/tmp/person-new.vertex.yml").ok()); // construct vertex property writer - GAR_NAMESPACE::VertexPropertyWriter writer(extend_info, "/tmp/"); + graphar::VertexPropertyWriter writer(extend_info, "/tmp/"); // convert results to arrow::Table std::vector> arrays; std::vector> schema_vector; schema_vector.push_back(arrow::field( - cc.name, GAR_NAMESPACE::DataType::DataTypeToArrowDataType(cc.type))); + cc.name, graphar::DataType::DataTypeToArrowDataType(cc.type))); arrow::Int64Builder array_builder; ASSERT(array_builder.Reserve(num_vertices).ok()); ASSERT(array_builder.AppendValues(component).ok()); diff --git a/cpp/examples/construct_info_example.cc b/cpp/examples/construct_info_example.cc index 6c60df594..998259d6f 100644 --- a/cpp/examples/construct_info_example.cc +++ b/cpp/examples/construct_info_example.cc @@ -21,27 +21,26 @@ int main(int argc, char* argv[]) { /*------------------construct vertex info------------------*/ - auto version = GAR_NAMESPACE::InfoVersion::Parse("gar/v1").value(); + auto version = graphar::InfoVersion::Parse("gar/v1").value(); // meta info std::string vertex_label = "person", vertex_prefix = "vertex/person/"; int chunk_size = 100; // construct properties and property groups - auto property_vector_1 = { - GAR_NAMESPACE::Property("id", GAR_NAMESPACE::int32(), true)}; + auto property_vector_1 = {graphar::Property("id", graphar::int32(), true)}; auto property_vector_2 = { - GAR_NAMESPACE::Property("firstName", GAR_NAMESPACE::string(), false), - GAR_NAMESPACE::Property("lastName", GAR_NAMESPACE::string(), false), - GAR_NAMESPACE::Property("gender", GAR_NAMESPACE::string(), false)}; + graphar::Property("firstName", graphar::string(), false), + graphar::Property("lastName", graphar::string(), false), + graphar::Property("gender", graphar::string(), false)}; - auto group1 = GAR_NAMESPACE::CreatePropertyGroup( - property_vector_1, GAR_NAMESPACE::FileType::CSV); - auto group2 = GAR_NAMESPACE::CreatePropertyGroup( - property_vector_2, GAR_NAMESPACE::FileType::ORC); + auto group1 = + graphar::CreatePropertyGroup(property_vector_1, graphar::FileType::CSV); + auto group2 = + graphar::CreatePropertyGroup(property_vector_2, graphar::FileType::ORC); // create vertex info - auto vertex_info = GAR_NAMESPACE::CreateVertexInfo( + auto vertex_info = graphar::CreateVertexInfo( vertex_label, chunk_size, {group1}, vertex_prefix, version); ASSERT(vertex_info != nullptr); @@ -54,8 +53,7 @@ int main(int argc, char* argv[]) { ASSERT(!vertex_info->HasPropertyGroup(group2)); ASSERT(vertex_info->IsPrimaryKey("id")); ASSERT(!vertex_info->IsPrimaryKey("gender")); - ASSERT(vertex_info->GetPropertyType("id").value()->Equals( - GAR_NAMESPACE::int32())); + ASSERT(vertex_info->GetPropertyType("id").value()->Equals(graphar::int32())); ASSERT(vertex_info->GetFilePath(group1, 0).value() == "vertex/person/id/chunk0"); @@ -80,20 +78,19 @@ int main(int argc, char* argv[]) { bool directed = false; // construct adjacent lists - auto adjacent_lists = {GAR_NAMESPACE::CreateAdjacentList( - GAR_NAMESPACE::AdjListType::unordered_by_source, - GAR_NAMESPACE::FileType::CSV), - GAR_NAMESPACE::CreateAdjacentList( - GAR_NAMESPACE::AdjListType::ordered_by_dest, - GAR_NAMESPACE::FileType::CSV)}; + auto adjacent_lists = { + graphar::CreateAdjacentList(graphar::AdjListType::unordered_by_source, + graphar::FileType::CSV), + graphar::CreateAdjacentList(graphar::AdjListType::ordered_by_dest, + graphar::FileType::CSV)}; // construct properties and property groups auto property_vector_3 = { - GAR_NAMESPACE::Property("creationDate", GAR_NAMESPACE::string(), false)}; - auto group3 = GAR_NAMESPACE::CreatePropertyGroup( - property_vector_3, GAR_NAMESPACE::FileType::PARQUET); + graphar::Property("creationDate", graphar::string(), false)}; + auto group3 = graphar::CreatePropertyGroup(property_vector_3, + graphar::FileType::PARQUET); // create edge info - auto edge_info = GAR_NAMESPACE::CreateEdgeInfo( + auto edge_info = graphar::CreateEdgeInfo( src_label, edge_label, dst_label, edge_chunk_size, src_chunk_size, dst_chunk_size, directed, adjacent_lists, {group3}, edge_prefix, version); @@ -107,40 +104,37 @@ int main(int argc, char* argv[]) { ASSERT(edge_info->IsDirected() == directed); ASSERT(edge_info->HasAdjacentListType( - GAR_NAMESPACE::AdjListType::unordered_by_source)); - ASSERT(edge_info - ->GetAdjListFilePath(0, 0, - GAR_NAMESPACE::AdjListType::ordered_by_dest) - .value() == - "edge/person_knows_person/ordered_by_dest/adj_list/part0/chunk0"); - ASSERT(edge_info - ->GetAdjListOffsetFilePath( - 0, GAR_NAMESPACE::AdjListType::ordered_by_dest) - .value() == - "edge/person_knows_person/ordered_by_dest/offset/chunk0"); + graphar::AdjListType::unordered_by_source)); + ASSERT( + edge_info->GetAdjListFilePath(0, 0, graphar::AdjListType::ordered_by_dest) + .value() == + "edge/person_knows_person/ordered_by_dest/adj_list/part0/chunk0"); + ASSERT( + edge_info + ->GetAdjListOffsetFilePath(0, graphar::AdjListType::ordered_by_dest) + .value() == "edge/person_knows_person/ordered_by_dest/offset/chunk0"); ASSERT(edge_info->HasPropertyGroup(group3)); ASSERT(edge_info->HasProperty("creationDate")); ASSERT( edge_info - ->GetPropertyFilePath( - group3, GAR_NAMESPACE::AdjListType::unordered_by_source, 0, 0) + ->GetPropertyFilePath(group3, + graphar::AdjListType::unordered_by_source, 0, 0) .value() == "edge/person_knows_person/unordered_by_source/creationDate/part0/chunk0"); ASSERT(edge_info->GetPropertyType("creationDate") .value() - ->Equals(GAR_NAMESPACE::string())); + ->Equals(graphar::string())); ASSERT(!edge_info->IsPrimaryKey("creationDate")); // extend & validate - auto new_adjacent_list = GAR_NAMESPACE::CreateAdjacentList( - GAR_NAMESPACE::AdjListType::ordered_by_source, - GAR_NAMESPACE::FileType::PARQUET); + auto new_adjacent_list = graphar::CreateAdjacentList( + graphar::AdjListType::ordered_by_source, graphar::FileType::PARQUET); auto res1 = edge_info->AddAdjacentList(new_adjacent_list); ASSERT(res1.status().ok()); edge_info = res1.value(); - ASSERT(edge_info->HasAdjacentListType( - GAR_NAMESPACE::AdjListType::ordered_by_source)); + ASSERT( + edge_info->HasAdjacentListType(graphar::AdjListType::ordered_by_source)); ASSERT(edge_info->IsValidated()); // save & dump ASSERT(!edge_info->Dump().has_error()); @@ -152,8 +146,8 @@ int main(int argc, char* argv[]) { std::string name = "graph", prefix = "file:///tmp/"; // create graph info - auto graph_info = GAR_NAMESPACE::CreateGraphInfo( - name, {vertex_info}, {edge_info}, prefix, version); + auto graph_info = graphar::CreateGraphInfo(name, {vertex_info}, {edge_info}, + prefix, version); ASSERT(graph_info->GetName() == name); ASSERT(graph_info->GetPrefix() == prefix); ASSERT(graph_info->GetVertexInfos().size() == 1); diff --git a/cpp/examples/high_level_reader_example.cc b/cpp/examples/high_level_reader_example.cc index dfcd6e630..4af6a22ca 100644 --- a/cpp/examples/high_level_reader_example.cc +++ b/cpp/examples/high_level_reader_example.cc @@ -23,11 +23,11 @@ #include "gar/graph.h" void vertices_collection( - const std::shared_ptr& graph_info) { + const std::shared_ptr& graph_info) { // construct vertices collection std::string label = "person", property = "firstName"; auto maybe_vertices_collection = - GAR_NAMESPACE::VerticesCollection::Make(graph_info, label); + graphar::VerticesCollection::Make(graph_info, label); ASSERT(!maybe_vertices_collection.has_error()); auto vertices = maybe_vertices_collection.value(); @@ -70,13 +70,12 @@ void vertices_collection( std::cout << "vertex_count=" << count << std::endl; } -void edges_collection( - const std::shared_ptr& graph_info) { +void edges_collection(const std::shared_ptr& graph_info) { // construct edges collection std::string src_label = "person", edge_label = "knows", dst_label = "person"; - auto expect = GAR_NAMESPACE::EdgesCollection::Make( + auto expect = graphar::EdgesCollection::Make( graph_info, src_label, edge_label, dst_label, - GAR_NAMESPACE::AdjListType::ordered_by_source); + graphar::AdjListType::ordered_by_source); ASSERT(!expect.has_error()); auto edges = expect.value(); @@ -119,7 +118,7 @@ int main(int argc, char* argv[]) { // read file and construct graph info std::string path = TEST_DATA_DIR + "/ldbc_sample/parquet/ldbc_sample.graph.yml"; - auto graph_info = GAR_NAMESPACE::GraphInfo::Load(path).value(); + auto graph_info = graphar::GraphInfo::Load(path).value(); // vertices collection std::cout << "Vertices collection" << std::endl; diff --git a/cpp/examples/high_level_writer_example.cc b/cpp/examples/high_level_writer_example.cc index 6bf2aa673..56b76e83f 100644 --- a/cpp/examples/high_level_writer_example.cc +++ b/cpp/examples/high_level_writer_example.cc @@ -28,14 +28,13 @@ void vertices_builder() { // construct vertices builder std::string vertex_meta_file = TEST_DATA_DIR + "/ldbc_sample/parquet/" + "person.vertex.yml"; - auto vertex_meta = GAR_NAMESPACE::Yaml::LoadFile(vertex_meta_file).value(); - auto vertex_info = GAR_NAMESPACE::VertexInfo::Load(vertex_meta).value(); - GAR_NAMESPACE::IdType start_index = 0; - GAR_NAMESPACE::builder::VerticesBuilder builder(vertex_info, "/tmp/", - start_index); + auto vertex_meta = graphar::Yaml::LoadFile(vertex_meta_file).value(); + auto vertex_info = graphar::VertexInfo::Load(vertex_meta).value(); + graphar::IdType start_index = 0; + graphar::builder::VerticesBuilder builder(vertex_info, "/tmp/", start_index); // set validate level - builder.SetValidateLevel(GAR_NAMESPACE::ValidateLevel::strong_validate); + builder.SetValidateLevel(graphar::ValidateLevel::strong_validate); // prepare vertex data int vertex_count = 3; @@ -48,7 +47,7 @@ void vertices_builder() { // add vertices for (int i = 0; i < vertex_count; i++) { - GAR_NAMESPACE::builder::Vertex v; + graphar::builder::Vertex v; v.AddProperty(property_names[0], id[i]); v.AddProperty(property_names[1], firstName[i]); v.AddProperty(property_names[2], lastName[i]); @@ -71,15 +70,14 @@ void edges_builder() { // construct edges builder std::string edge_meta_file = TEST_DATA_DIR + "/ldbc_sample/parquet/" + "person_knows_person.edge.yml"; - auto edge_meta = GAR_NAMESPACE::Yaml::LoadFile(edge_meta_file).value(); - auto edge_info = GAR_NAMESPACE::EdgeInfo::Load(edge_meta).value(); + auto edge_meta = graphar::Yaml::LoadFile(edge_meta_file).value(); + auto edge_info = graphar::EdgeInfo::Load(edge_meta).value(); auto vertex_count = 3; - GAR_NAMESPACE::builder::EdgesBuilder builder( - edge_info, "/tmp/", GAR_NAMESPACE::AdjListType::ordered_by_dest, - vertex_count); + graphar::builder::EdgesBuilder builder( + edge_info, "/tmp/", graphar::AdjListType::ordered_by_dest, vertex_count); // set validate level - builder.SetValidateLevel(GAR_NAMESPACE::ValidateLevel::strong_validate); + builder.SetValidateLevel(graphar::ValidateLevel::strong_validate); // prepare edge data int edge_count = 4; @@ -91,7 +89,7 @@ void edges_builder() { // add edges for (int i = 0; i < edge_count; i++) { - GAR_NAMESPACE::builder::Edge e(src[i], dst[i]); + graphar::builder::Edge e(src[i], dst[i]); e.AddProperty("creationDate", creationDate[i]); ASSERT(builder.AddEdge(e).ok()); } diff --git a/cpp/examples/low_level_reader_example.cc b/cpp/examples/low_level_reader_example.cc index c0ac89c03..e42b77756 100644 --- a/cpp/examples/low_level_reader_example.cc +++ b/cpp/examples/low_level_reader_example.cc @@ -24,10 +24,10 @@ #include "gar/reader/chunk_info_reader.h" void vertex_property_chunk_info_reader( - const std::shared_ptr& graph_info) { + const std::shared_ptr& graph_info) { // constuct reader std::string label = "person", property_name = "id"; - auto maybe_reader = GAR_NAMESPACE::VertexPropertyChunkInfoReader::Make( + auto maybe_reader = graphar::VertexPropertyChunkInfoReader::Make( graph_info, label, property_name); ASSERT(!maybe_reader.has_error()); auto reader = maybe_reader.value(); @@ -57,12 +57,12 @@ void vertex_property_chunk_info_reader( } void adj_list_chunk_info_reader( - const std::shared_ptr& graph_info) { + const std::shared_ptr& graph_info) { // construct reader std::string src_label = "person", edge_label = "knows", dst_label = "person"; - auto maybe_reader = GAR_NAMESPACE::AdjListChunkInfoReader::Make( + auto maybe_reader = graphar::AdjListChunkInfoReader::Make( graph_info, src_label, edge_label, dst_label, - GAR_NAMESPACE::AdjListType::ordered_by_source); + graphar::AdjListType::ordered_by_source); ASSERT(maybe_reader.status().ok()); auto reader = maybe_reader.value(); @@ -88,15 +88,14 @@ void adj_list_chunk_info_reader( } void adj_list_property_chunk_info_reader( - const std::shared_ptr& graph_info) { + const std::shared_ptr& graph_info) { // construct reader std::string src_label = "person", edge_label = "knows", dst_label = "person", property_name = "creationDate"; - auto maybe_property_reader = - GAR_NAMESPACE::AdjListPropertyChunkInfoReader::Make( - graph_info, src_label, edge_label, dst_label, property_name, - GAR_NAMESPACE::AdjListType::ordered_by_source); + auto maybe_property_reader = graphar::AdjListPropertyChunkInfoReader::Make( + graph_info, src_label, edge_label, dst_label, property_name, + graphar::AdjListType::ordered_by_source); ASSERT(maybe_property_reader.status().ok()); auto reader = maybe_property_reader.value(); @@ -127,7 +126,7 @@ int main(int argc, char* argv[]) { // read file and construct graph info std::string path = TEST_DATA_DIR + "/ldbc_sample/parquet/ldbc_sample.graph.yml"; - auto graph_info = GAR_NAMESPACE::GraphInfo::Load(path).value(); + auto graph_info = graphar::GraphInfo::Load(path).value(); // vertex property chunk info reader std::cout << "Vertex property chunk info reader" << std::endl; diff --git a/cpp/examples/mid_level_reader_example.cc b/cpp/examples/mid_level_reader_example.cc index 0a6b2ae72..1643a68aa 100644 --- a/cpp/examples/mid_level_reader_example.cc +++ b/cpp/examples/mid_level_reader_example.cc @@ -25,10 +25,10 @@ #include "gar/util/expression.h" void vertex_property_chunk_reader( - const std::shared_ptr& graph_info) { + const std::shared_ptr& graph_info) { // create reader std::string label = "person", property_name = "gender"; - auto maybe_reader = GAR_NAMESPACE::VertexPropertyArrowChunkReader::Make( + auto maybe_reader = graphar::VertexPropertyArrowChunkReader::Make( graph_info, label, property_name); ASSERT(maybe_reader.status().ok()); auto reader = maybe_reader.value(); @@ -43,7 +43,7 @@ void vertex_property_chunk_reader( std::cout << "schema of first vertex property chunk: " << std::endl << table->schema()->ToString() << std::endl; auto index_col = - table->GetColumnByName(GAR_NAMESPACE::GeneralParams::kVertexIndexCol); + table->GetColumnByName(graphar::GeneralParams::kVertexIndexCol); ASSERT(index_col != nullptr); std::cout << "Internal id column: " << index_col->ToString() << " " << std::endl; @@ -52,8 +52,7 @@ void vertex_property_chunk_reader( result = reader->GetChunk(); ASSERT(!result.has_error()); table = result.value(); - index_col = - table->GetColumnByName(GAR_NAMESPACE::GeneralParams::kVertexIndexCol); + index_col = table->GetColumnByName(graphar::GeneralParams::kVertexIndexCol); ASSERT(index_col != nullptr); std::cout << "Internal id column of vertex property chunk for vertex id 100: " << index_col->ToString() << " " << std::endl; @@ -62,19 +61,17 @@ void vertex_property_chunk_reader( result = reader->GetChunk(); ASSERT(!result.has_error()); table = result.value(); - index_col = - table->GetColumnByName(GAR_NAMESPACE::GeneralParams::kVertexIndexCol); + index_col = table->GetColumnByName(graphar::GeneralParams::kVertexIndexCol); ASSERT(index_col != nullptr); std::cout << "Internal id column of next chunk: " << index_col->ToString() << " " << std::endl; // reader with filter pushdown - auto filter = GAR_NAMESPACE::_Equal(GAR_NAMESPACE::_Property("gender"), - GAR_NAMESPACE::_Literal("female")); + auto filter = graphar::_Equal(graphar::_Property("gender"), + graphar::_Literal("female")); std::vector expected_cols{"firstName", "lastName"}; - auto maybe_filter_reader = - GAR_NAMESPACE::VertexPropertyArrowChunkReader::Make(graph_info, label, - property_name); + auto maybe_filter_reader = graphar::VertexPropertyArrowChunkReader::Make( + graph_info, label, property_name); ASSERT(maybe_filter_reader.status().ok()); auto filter_reader = maybe_filter_reader.value(); filter_reader->Filter(filter); @@ -89,12 +86,12 @@ void vertex_property_chunk_reader( } void adj_list_chunk_reader( - const std::shared_ptr& graph_info) { + const std::shared_ptr& graph_info) { // create reader std::string src_label = "person", edge_label = "knows", dst_label = "person"; - auto maybe_reader = GAR_NAMESPACE::AdjListArrowChunkReader::Make( + auto maybe_reader = graphar::AdjListArrowChunkReader::Make( graph_info, src_label, edge_label, dst_label, - GAR_NAMESPACE::AdjListType::ordered_by_source); + graphar::AdjListType::ordered_by_source); ASSERT(maybe_reader.status().ok()); // use reader @@ -124,13 +121,13 @@ void adj_list_chunk_reader( } void adj_list_property_chunk_reader( - const std::shared_ptr& graph_info) { + const std::shared_ptr& graph_info) { // create reader std::string src_label = "person", edge_label = "knows", dst_label = "person", property_name = "creationDate"; - auto maybe_reader = GAR_NAMESPACE::AdjListPropertyArrowChunkReader::Make( + auto maybe_reader = graphar::AdjListPropertyArrowChunkReader::Make( graph_info, src_label, edge_label, dst_label, property_name, - GAR_NAMESPACE::AdjListType::ordered_by_source); + graphar::AdjListType::ordered_by_source); ASSERT(maybe_reader.status().ok()); auto reader = maybe_reader.value(); @@ -159,17 +156,16 @@ void adj_list_property_chunk_reader( << table->num_rows() << std::endl; // reader with filter pushdown - auto expr1 = GAR_NAMESPACE::_LessThan( - GAR_NAMESPACE::_Literal("2012-06-02T04:30:44.526+0000"), - GAR_NAMESPACE::_Property(property_name)); - auto expr2 = GAR_NAMESPACE::_Equal(GAR_NAMESPACE::_Property(property_name), - GAR_NAMESPACE::_Property(property_name)); - auto filter = GAR_NAMESPACE::_And(expr1, expr2); + auto expr1 = + graphar::_LessThan(graphar::_Literal("2012-06-02T04:30:44.526+0000"), + graphar::_Property(property_name)); + auto expr2 = graphar::_Equal(graphar::_Property(property_name), + graphar::_Property(property_name)); + auto filter = graphar::_And(expr1, expr2); std::vector expected_cols{"creationDate"}; - auto maybe_filter_reader = - GAR_NAMESPACE::AdjListPropertyArrowChunkReader::Make( - graph_info, src_label, edge_label, dst_label, property_name, - GAR_NAMESPACE::AdjListType::ordered_by_source); + auto maybe_filter_reader = graphar::AdjListPropertyArrowChunkReader::Make( + graph_info, src_label, edge_label, dst_label, property_name, + graphar::AdjListType::ordered_by_source); ASSERT(maybe_filter_reader.status().ok()); auto filter_reader = maybe_filter_reader.value(); filter_reader->Filter(filter); @@ -182,12 +178,12 @@ void adj_list_property_chunk_reader( } void adj_list_offset_chunk_reader( - const std::shared_ptr& graph_info) { + const std::shared_ptr& graph_info) { // create reader std::string src_label = "person", edge_label = "knows", dst_label = "person"; - auto maybe_reader = GAR_NAMESPACE::AdjListOffsetArrowChunkReader::Make( + auto maybe_reader = graphar::AdjListOffsetArrowChunkReader::Make( graph_info, src_label, edge_label, dst_label, - GAR_NAMESPACE::AdjListType::ordered_by_source); + graphar::AdjListType::ordered_by_source); ASSERT(maybe_reader.status().ok()); auto reader = maybe_reader.value(); @@ -217,7 +213,7 @@ int main(int argc, char* argv[]) { // read file and construct graph info std::string path = TEST_DATA_DIR + "/ldbc_sample/parquet/ldbc_sample.graph.yml"; - auto graph_info = GAR_NAMESPACE::GraphInfo::Load(path).value(); + auto graph_info = graphar::GraphInfo::Load(path).value(); // vertex property chunk reader std::cout << "Vertex property chunk reader" << std::endl; diff --git a/cpp/examples/mid_level_writer_example.cc b/cpp/examples/mid_level_writer_example.cc index 67713635b..2e864e204 100644 --- a/cpp/examples/mid_level_writer_example.cc +++ b/cpp/examples/mid_level_writer_example.cc @@ -78,9 +78,8 @@ arrow::Result> generate_adj_list_table() { // schema auto schema = arrow::schema( - {arrow::field(GAR_NAMESPACE::GeneralParams::kSrcIndexCol, arrow::int64()), - arrow::field(GAR_NAMESPACE::GeneralParams::kDstIndexCol, - arrow::int64())}); + {arrow::field(graphar::GeneralParams::kSrcIndexCol, arrow::int64()), + arrow::field(graphar::GeneralParams::kDstIndexCol, arrow::int64())}); return arrow::Table::Make(schema, {i64array, i64array2}); } @@ -100,16 +99,15 @@ arrow::Result> generate_edge_property_table() { } void vertex_property_writer( - const std::shared_ptr& graph_info) { + const std::shared_ptr& graph_info) { // create writer std::string vertex_meta_file = TEST_DATA_DIR + "/ldbc_sample/parquet/" + "person.vertex.yml"; - auto vertex_meta = GAR_NAMESPACE::Yaml::LoadFile(vertex_meta_file).value(); - auto vertex_info = GAR_NAMESPACE::VertexInfo::Load(vertex_meta).value(); + auto vertex_meta = graphar::Yaml::LoadFile(vertex_meta_file).value(); + auto vertex_info = graphar::VertexInfo::Load(vertex_meta).value(); ASSERT(vertex_info->GetLabel() == "person"); - auto maybe_writer = - GAR_NAMESPACE::VertexPropertyWriter::Make(vertex_info, "/tmp/"); + auto maybe_writer = graphar::VertexPropertyWriter::Make(vertex_info, "/tmp/"); ASSERT(maybe_writer.status().ok()); auto writer = maybe_writer.value(); @@ -123,7 +121,7 @@ void vertex_property_writer( // use writer // set validate level - writer->SetValidateLevel(GAR_NAMESPACE::ValidateLevel::strong_validate); + writer->SetValidateLevel(graphar::ValidateLevel::strong_validate); // write the table ASSERT(writer->WriteTable(table, 0).ok()); // write the number of vertices @@ -133,21 +131,20 @@ void vertex_property_writer( auto path = "/tmp/vertex/person/vertex_count"; auto fs = arrow::fs::FileSystemFromUriOrPath(path).ValueOrDie(); auto input = fs->OpenInputStream(path).ValueOrDie(); - auto num = input->Read(sizeof(GAR_NAMESPACE::IdType)).ValueOrDie(); - GAR_NAMESPACE::IdType* ptr = (GAR_NAMESPACE::IdType*) num->data(); + auto num = input->Read(sizeof(graphar::IdType)).ValueOrDie(); + graphar::IdType* ptr = (graphar::IdType*) num->data(); std::cout << "vertex count from reading written file: " << *ptr << std::endl; } -void edge_chunk_writer( - const std::shared_ptr& graph_info) { +void edge_chunk_writer(const std::shared_ptr& graph_info) { // construct writer std::string edge_meta_file = TEST_DATA_DIR + "/ldbc_sample/csv/" + "person_knows_person.edge.yml"; - auto edge_meta = GAR_NAMESPACE::Yaml::LoadFile(edge_meta_file).value(); - auto edge_info = GAR_NAMESPACE::EdgeInfo::Load(edge_meta).value(); - auto adj_list_type = GAR_NAMESPACE::AdjListType::ordered_by_source; + auto edge_meta = graphar::Yaml::LoadFile(edge_meta_file).value(); + auto edge_info = graphar::EdgeInfo::Load(edge_meta).value(); + auto adj_list_type = graphar::AdjListType::ordered_by_source; auto maybe_writer = - GAR_NAMESPACE::EdgeChunkWriter::Make(edge_info, "/tmp/", adj_list_type); + graphar::EdgeChunkWriter::Make(edge_info, "/tmp/", adj_list_type); ASSERT(maybe_writer.status().ok()); auto writer = maybe_writer.value(); @@ -168,7 +165,7 @@ void edge_chunk_writer( // use writer // set validate level - writer->SetValidateLevel(GAR_NAMESPACE::ValidateLevel::strong_validate); + writer->SetValidateLevel(graphar::ValidateLevel::strong_validate); // write a property chunk auto pg = edge_info->GetPropertyGroup("creationDate"); ASSERT(pg != nullptr); @@ -185,9 +182,8 @@ void edge_chunk_writer( auto fs = arrow::fs::FileSystemFromUriOrPath(path).ValueOrDie(); std::shared_ptr input = fs->OpenInputStream(path).ValueOrDie(); - auto edge_num = input->Read(sizeof(GAR_NAMESPACE::IdType)).ValueOrDie(); - GAR_NAMESPACE::IdType* edge_num_ptr = - (GAR_NAMESPACE::IdType*) edge_num->data(); + auto edge_num = input->Read(sizeof(graphar::IdType)).ValueOrDie(); + graphar::IdType* edge_num_ptr = (graphar::IdType*) edge_num->data(); std::cout << "edge number from reading written file: " << *edge_num_ptr << std::endl; } @@ -196,7 +192,7 @@ int main(int argc, char* argv[]) { // read file and construct graph info std::string path = TEST_DATA_DIR + "/ldbc_sample/parquet/ldbc_sample.graph.yml"; - auto graph_info = GAR_NAMESPACE::GraphInfo::Load(path).value(); + auto graph_info = graphar::GraphInfo::Load(path).value(); // vertex property writer std::cout << "Vertex property writer" << std::endl; diff --git a/cpp/examples/pagerank_example.cc b/cpp/examples/pagerank_example.cc index ab30a8a7e..0c1909eb5 100644 --- a/cpp/examples/pagerank_example.cc +++ b/cpp/examples/pagerank_example.cc @@ -29,13 +29,12 @@ int main(int argc, char* argv[]) { // read file and construct graph info std::string path = TEST_DATA_DIR + "/ldbc_sample/parquet/ldbc_sample.graph.yml"; - auto graph_info = GAR_NAMESPACE::GraphInfo::Load(path).value(); + auto graph_info = graphar::GraphInfo::Load(path).value(); // construct vertices collection std::string label = "person"; ASSERT(graph_info->GetVertexInfo(label) != nullptr); - auto maybe_vertices = - GAR_NAMESPACE::VerticesCollection::Make(graph_info, label); + auto maybe_vertices = graphar::VerticesCollection::Make(graph_info, label); ASSERT(maybe_vertices.status().ok()); auto& vertices = maybe_vertices.value(); int num_vertices = vertices->size(); @@ -43,9 +42,9 @@ int main(int argc, char* argv[]) { // construct edges collection std::string src_label = "person", edge_label = "knows", dst_label = "person"; - auto maybe_edges = GAR_NAMESPACE::EdgesCollection::Make( + auto maybe_edges = graphar::EdgesCollection::Make( graph_info, src_label, edge_label, dst_label, - GAR_NAMESPACE::AdjListType::ordered_by_source); + graphar::AdjListType::ordered_by_source); ASSERT(!maybe_edges.has_error()); auto& edges = maybe_edges.value(); @@ -54,24 +53,24 @@ int main(int argc, char* argv[]) { const int max_iters = 10; std::vector pr_curr(num_vertices); std::vector pr_next(num_vertices); - std::vector out_degree(num_vertices); - for (GAR_NAMESPACE::IdType i = 0; i < num_vertices; i++) { + std::vector out_degree(num_vertices); + for (graphar::IdType i = 0; i < num_vertices; i++) { pr_curr[i] = 1 / static_cast(num_vertices); pr_next[i] = 0; out_degree[i] = 0; } auto it_begin = edges->begin(), it_end = edges->end(); for (auto it = it_begin; it != it_end; ++it) { - GAR_NAMESPACE::IdType src = it.source(); + graphar::IdType src = it.source(); out_degree[src]++; } for (int iter = 0; iter < max_iters; iter++) { std::cout << "iter " << iter << std::endl; for (auto it = it_begin; it != it_end; ++it) { - GAR_NAMESPACE::IdType src = it.source(), dst = it.destination(); + graphar::IdType src = it.source(), dst = it.destination(); pr_next[dst] += pr_curr[src] / out_degree[src]; } - for (GAR_NAMESPACE::IdType i = 0; i < num_vertices; i++) { + for (graphar::IdType i = 0; i < num_vertices; i++) { pr_next[i] = damping * pr_next[i] + (1 - damping) * (1 / static_cast(num_vertices)); if (out_degree[i] == 0) @@ -83,10 +82,10 @@ int main(int argc, char* argv[]) { // extend the original vertex info and write results to gar using writer // construct property group - GAR_NAMESPACE::Property pagerank("pagerank", GAR_NAMESPACE::float64(), false); - std::vector property_vector = {pagerank}; - auto group = GAR_NAMESPACE::CreatePropertyGroup( - property_vector, GAR_NAMESPACE::FileType::PARQUET); + graphar::Property pagerank("pagerank", graphar::float64(), false); + std::vector property_vector = {pagerank}; + auto group = + graphar::CreatePropertyGroup(property_vector, graphar::FileType::PARQUET); // extend the vertex_info auto vertex_info = graph_info->GetVertexInfo(label); auto maybe_extend_info = vertex_info->AddPropertyGroup(group); @@ -97,13 +96,13 @@ int main(int argc, char* argv[]) { ASSERT(extend_info->Dump().status().ok()); ASSERT(extend_info->Save("/tmp/person-new-pagerank.vertex.yml").ok()); // construct vertex property writer - GAR_NAMESPACE::VertexPropertyWriter writer(extend_info, "/tmp/"); + graphar::VertexPropertyWriter writer(extend_info, "/tmp/"); // convert results to arrow::Table std::vector> arrays; std::vector> schema_vector; - schema_vector.push_back(arrow::field( - pagerank.name, - GAR_NAMESPACE::DataType::DataTypeToArrowDataType(pagerank.type))); + schema_vector.push_back( + arrow::field(pagerank.name, + graphar::DataType::DataTypeToArrowDataType(pagerank.type))); arrow::DoubleBuilder array_builder; ASSERT(array_builder.Reserve(num_vertices).ok()); ASSERT(array_builder.AppendValues(pr_curr).ok()); diff --git a/cpp/examples/snap_dataset_to_graphar.cc b/cpp/examples/snap_dataset_to_graphar.cc index 16be656b8..c44ccdb4a 100644 --- a/cpp/examples/snap_dataset_to_graphar.cc +++ b/cpp/examples/snap_dataset_to_graphar.cc @@ -32,8 +32,8 @@ #define IS_DIRECTED false /*-----------------------GraphAr status---------------------*/ #define SAVE_PATH "/tmp/snap/" + graph_name + "/" -#define ADJLIST_TYPE GAR_NAMESPACE::AdjListType::ordered_by_source -#define PAYLOAD_TYPE GAR_NAMESPACE::FileType::CSV +#define ADJLIST_TYPE graphar::AdjListType::ordered_by_source +#define PAYLOAD_TYPE graphar::FileType::CSV #define VERTEX_CHUNK_SIZE 1024 #define EDGE_CHUNK_SIZE 1024 * 1024 @@ -42,14 +42,14 @@ int main(int argc, char* argv[]) { std::string save_path = SAVE_PATH; /*------------------construct vertex info------------------*/ - auto version = GAR_NAMESPACE::InfoVersion::Parse("gar/v1").value(); + auto version = graphar::InfoVersion::Parse("gar/v1").value(); // meta info std::string vertex_label = "node", vertex_prefix = "vertex/node/"; // create vertex info - auto vertex_info = GAR_NAMESPACE::CreateVertexInfo( - vertex_label, VERTEX_CHUNK_SIZE, {}, vertex_prefix, version); + auto vertex_info = graphar::CreateVertexInfo(vertex_label, VERTEX_CHUNK_SIZE, + {}, vertex_prefix, version); // save & dump ASSERT(!vertex_info->Dump().has_error()); @@ -62,9 +62,9 @@ int main(int argc, char* argv[]) { // construct adjacent lists auto adjacent_lists = { - GAR_NAMESPACE::CreateAdjacentList(ADJLIST_TYPE, PAYLOAD_TYPE)}; + graphar::CreateAdjacentList(ADJLIST_TYPE, PAYLOAD_TYPE)}; // create edge info - auto edge_info = GAR_NAMESPACE::CreateEdgeInfo( + auto edge_info = graphar::CreateEdgeInfo( src_label, edge_label, dst_label, EDGE_CHUNK_SIZE, VERTEX_CHUNK_SIZE, VERTEX_CHUNK_SIZE, directed, adjacent_lists, {}, edge_prefix, version); @@ -74,22 +74,22 @@ int main(int argc, char* argv[]) { /*------------------construct graph info------------------*/ // create graph info - auto graph_info = GAR_NAMESPACE::CreateGraphInfo( - graph_name, {vertex_info}, {edge_info}, save_path, version); + auto graph_info = graphar::CreateGraphInfo(graph_name, {vertex_info}, + {edge_info}, save_path, version); // save & dump ASSERT(!graph_info->Dump().has_error()); ASSERT(graph_info->Save(save_path + graph_name + ".graph.yml").ok()); /*------------------construct vertices------------------*/ // construct vertices builder - GAR_NAMESPACE::IdType start_index = 0; - auto v_builder = GAR_NAMESPACE::builder::VerticesBuilder::Make( + graphar::IdType start_index = 0; + auto v_builder = graphar::builder::VerticesBuilder::Make( vertex_info, save_path, start_index) .value(); // prepare vertex data for (int i = 0; i < VERTEX_COUNT; i++) { - GAR_NAMESPACE::builder::Vertex v; + graphar::builder::Vertex v; ASSERT(v_builder->AddVertex(v).ok()); } @@ -104,7 +104,7 @@ int main(int argc, char* argv[]) { /*------------------construct edges------------------*/ // construct edges builder - auto e_builder = GAR_NAMESPACE::builder::EdgesBuilder::Make( + auto e_builder = graphar::builder::EdgesBuilder::Make( edge_info, save_path, ADJLIST_TYPE, VERTEX_COUNT) .value(); // prepare edge data @@ -120,7 +120,7 @@ int main(int argc, char* argv[]) { if (!(iss >> src >> dst)) { break; } - GAR_NAMESPACE::builder::Edge e(src, dst); + graphar::builder::Edge e(src, dst); ASSERT(e_builder->AddEdge(e).ok()); } diff --git a/cpp/include/gar/fwd.h b/cpp/include/gar/fwd.h index 58247bfb6..b78192ef6 100644 --- a/cpp/include/gar/fwd.h +++ b/cpp/include/gar/fwd.h @@ -28,7 +28,7 @@ #include "gar/util/macros.h" #include "gar/util/status.h" -namespace GAR_NAMESPACE_INTERNAL { +namespace graphar { class Status; @@ -207,6 +207,6 @@ using ColumnNames = std::optional>>; } // namespace util -} // namespace GAR_NAMESPACE_INTERNAL +} // namespace graphar #endif // GAR_FWD_H_ diff --git a/cpp/include/gar/graph.h b/cpp/include/gar/graph.h index c18cc592a..2bfacb050 100644 --- a/cpp/include/gar/graph.h +++ b/cpp/include/gar/graph.h @@ -39,7 +39,7 @@ class ChunkedArray; class Array; } // namespace arrow -namespace GAR_NAMESPACE_INTERNAL { +namespace graphar { /** * @brief Vertex contains information of certain vertex. @@ -1056,6 +1056,6 @@ class UBDEdgesCollection : public EdgesCollection { return iter; } }; -} // namespace GAR_NAMESPACE_INTERNAL +} // namespace graphar #endif // GAR_GRAPH_H_ diff --git a/cpp/include/gar/graph_info.h b/cpp/include/gar/graph_info.h index ff0ab0ff0..3ab63d507 100644 --- a/cpp/include/gar/graph_info.h +++ b/cpp/include/gar/graph_info.h @@ -24,7 +24,7 @@ #include "gar/fwd.h" -namespace GAR_NAMESPACE_INTERNAL { +namespace graphar { /** * Property is a struct to store the property information. @@ -871,5 +871,5 @@ class GraphInfo { std::unique_ptr impl_; }; -} // namespace GAR_NAMESPACE_INTERNAL +} // namespace graphar #endif // GAR_GRAPH_INFO_H_ diff --git a/cpp/include/gar/reader/arrow_chunk_reader.h b/cpp/include/gar/reader/arrow_chunk_reader.h index 730cf2228..6200a2c5b 100644 --- a/cpp/include/gar/reader/arrow_chunk_reader.h +++ b/cpp/include/gar/reader/arrow_chunk_reader.h @@ -31,7 +31,7 @@ class Array; class Table; } // namespace arrow -namespace GAR_NAMESPACE_INTERNAL { +namespace graphar { /** * @brief The arrow chunk reader for vertex property group. @@ -504,5 +504,5 @@ class AdjListPropertyArrowChunkReader { std::string base_dir_; std::shared_ptr fs_; }; -} // namespace GAR_NAMESPACE_INTERNAL +} // namespace graphar #endif // GAR_READER_ARROW_CHUNK_READER_H_ diff --git a/cpp/include/gar/reader/chunk_info_reader.h b/cpp/include/gar/reader/chunk_info_reader.h index 576f26cee..5528ba0f9 100644 --- a/cpp/include/gar/reader/chunk_info_reader.h +++ b/cpp/include/gar/reader/chunk_info_reader.h @@ -23,7 +23,7 @@ #include "gar/fwd.h" -namespace GAR_NAMESPACE_INTERNAL { +namespace graphar { /** The chunk info reader for vertex property group. */ class VertexPropertyChunkInfoReader { @@ -383,5 +383,5 @@ class AdjListPropertyChunkInfoReader { std::string base_dir_; // the chunk files base dir std::shared_ptr fs_; }; -} // namespace GAR_NAMESPACE_INTERNAL +} // namespace graphar #endif // GAR_READER_CHUNK_INFO_READER_H_ diff --git a/cpp/include/gar/util/adj_list_type.h b/cpp/include/gar/util/adj_list_type.h index dd08206e4..5db9c4d3b 100644 --- a/cpp/include/gar/util/adj_list_type.h +++ b/cpp/include/gar/util/adj_list_type.h @@ -23,7 +23,7 @@ #ifndef GAR_UTIL_ADJ_LIST_TYPE_H_ #define GAR_UTIL_ADJ_LIST_TYPE_H_ -namespace GAR_NAMESPACE_INTERNAL { +namespace graphar { /** Adj list type enumeration for adjacency list of graph. */ enum class AdjListType : std::uint8_t { @@ -86,5 +86,5 @@ static inline std::pair AdjListTypeToOrderedAligned( } } -} // namespace GAR_NAMESPACE_INTERNAL +} // namespace graphar #endif // GAR_UTIL_ADJ_LIST_TYPE_H_ diff --git a/cpp/include/gar/util/convert_to_arrow_type.h b/cpp/include/gar/util/convert_to_arrow_type.h index 3d80f967e..9bb4b73bd 100644 --- a/cpp/include/gar/util/convert_to_arrow_type.h +++ b/cpp/include/gar/util/convert_to_arrow_type.h @@ -25,7 +25,7 @@ #include "gar/util/data_type.h" -namespace GAR_NAMESPACE_INTERNAL { +namespace graphar { /** Struct to convert DataType to arrow::DataType. */ template @@ -75,6 +75,6 @@ CONVERT_TO_ARROW_TYPE(Type::TIMESTAMP, Timestamp, arrow::TimestampType, CONVERT_TO_ARROW_TYPE(Type::DATE, Date, arrow::Date32Type, arrow::Date32Array, arrow::Date32Builder, arrow::date32(), "date") -} // namespace GAR_NAMESPACE_INTERNAL +} // namespace graphar #endif // GAR_UTIL_CONVERT_TO_ARROW_TYPE_H_ diff --git a/cpp/include/gar/util/data_type.h b/cpp/include/gar/util/data_type.h index c3be0cc21..221c4fc2e 100644 --- a/cpp/include/gar/util/data_type.h +++ b/cpp/include/gar/util/data_type.h @@ -29,7 +29,7 @@ namespace arrow { class DataType; } -namespace GAR_NAMESPACE_INTERNAL { +namespace graphar { /** @brief Main data type enumeration. */ enum class Type { @@ -156,6 +156,6 @@ class Date { c_type value_; }; -} // namespace GAR_NAMESPACE_INTERNAL +} // namespace graphar #endif // GAR_UTIL_DATA_TYPE_H_ diff --git a/cpp/include/gar/util/expression.h b/cpp/include/gar/util/expression.h index a0ebf49de..4f6e669ee 100644 --- a/cpp/include/gar/util/expression.h +++ b/cpp/include/gar/util/expression.h @@ -39,7 +39,7 @@ limitations under the License. #ifndef GAR_UTIL_EXPRESSION_H_ #define GAR_UTIL_EXPRESSION_H_ -namespace GAR_NAMESPACE_INTERNAL { +namespace graphar { using ArrowExpression = arrow::compute::Expression; @@ -368,5 +368,5 @@ template lhs, std::shared_ptr rhs) { return std::make_shared(lhs, rhs); } -} // namespace GAR_NAMESPACE_INTERNAL +} // namespace graphar #endif // GAR_UTIL_EXPRESSION_H_ diff --git a/cpp/include/gar/util/file_type.h b/cpp/include/gar/util/file_type.h index 799c9224a..f3bb7e18a 100644 --- a/cpp/include/gar/util/file_type.h +++ b/cpp/include/gar/util/file_type.h @@ -24,7 +24,7 @@ #ifndef GAR_UTIL_FILE_TYPE_H_ #define GAR_UTIL_FILE_TYPE_H_ -namespace GAR_NAMESPACE_INTERNAL { +namespace graphar { static inline FileType StringToFileType(const std::string& str) { static const std::map str2file_type{ @@ -46,5 +46,5 @@ static inline const char* FileTypeToString(FileType file_type) { return file_type2string.at(file_type); } -} // namespace GAR_NAMESPACE_INTERNAL +} // namespace graphar #endif // GAR_UTIL_FILE_TYPE_H_ diff --git a/cpp/include/gar/util/filesystem.h b/cpp/include/gar/util/filesystem.h index 604f83795..f6ec0494e 100644 --- a/cpp/include/gar/util/filesystem.h +++ b/cpp/include/gar/util/filesystem.h @@ -44,7 +44,7 @@ class FileFormat; } } // namespace arrow -namespace GAR_NAMESPACE_INTERNAL { +namespace graphar { /** * This class wraps an arrow::fs::FileSystem and provides methods for @@ -148,5 +148,5 @@ class FileSystem { Result> FileSystemFromUriOrPath( const std::string& uri, std::string* out_path = nullptr); -} // namespace GAR_NAMESPACE_INTERNAL +} // namespace graphar #endif // GAR_UTIL_FILESYSTEM_H_ diff --git a/cpp/include/gar/util/general_params.h b/cpp/include/gar/util/general_params.h index 5c299c044..78e7d86ff 100644 --- a/cpp/include/gar/util/general_params.h +++ b/cpp/include/gar/util/general_params.h @@ -17,7 +17,7 @@ #ifndef GAR_UTIL_GENERAL_PARAMS_H_ #define GAR_UTIL_GENERAL_PARAMS_H_ -namespace GAR_NAMESPACE_INTERNAL { +namespace graphar { struct GeneralParams { static constexpr const char* kVertexIndexCol = "_graphArVertexIndex"; @@ -27,6 +27,6 @@ struct GeneralParams { static constexpr const char* kPrimaryCol = "_graphArPrimary"; }; -} // namespace GAR_NAMESPACE_INTERNAL +} // namespace graphar #endif // GAR_UTIL_GENERAL_PARAMS_H_ diff --git a/cpp/include/gar/util/macros.h b/cpp/include/gar/util/macros.h index 4094cd1d7..47b98d7f8 100644 --- a/cpp/include/gar/util/macros.h +++ b/cpp/include/gar/util/macros.h @@ -35,11 +35,6 @@ #include // namespace config -#if defined(GAR_NAMESPACE) -#define GAR_NAMESPACE_INTERNAL GAR_NAMESPACE -#else -#define GAR_NAMESPACE_INTERNAL graphar -#endif #define GAR_EXPAND(x) x #define GAR_STRINGIFY(x) #x diff --git a/cpp/include/gar/util/reader_util.h b/cpp/include/gar/util/reader_util.h index 75e075b9c..5a0b1ebef 100644 --- a/cpp/include/gar/util/reader_util.h +++ b/cpp/include/gar/util/reader_util.h @@ -24,7 +24,7 @@ #include "gar/fwd.h" -namespace GAR_NAMESPACE_INTERNAL { +namespace graphar { namespace util { struct FilterOptions { @@ -73,5 +73,5 @@ Result GetEdgeNum(const std::string& prefix, IdType vertex_chunk_index) noexcept; } // namespace util -} // namespace GAR_NAMESPACE_INTERNAL +} // namespace graphar #endif // GAR_UTIL_READER_UTIL_H_ diff --git a/cpp/include/gar/util/result.h b/cpp/include/gar/util/result.h index e41ed6cc4..f42f30a2b 100644 --- a/cpp/include/gar/util/result.h +++ b/cpp/include/gar/util/result.h @@ -81,8 +81,7 @@ #define GAR_RETURN_ON_ARROW_ERROR_AND_ASSIGN_IMPL(result_name, lhs, rexpr) \ auto&& result_name = (rexpr); \ if (!result_name.status().ok()) { \ - return ::GAR_NAMESPACE_INTERNAL::Status::ArrowError( \ - result_name.status().ToString()); \ + return ::graphar::Status::ArrowError(result_name.status().ToString()); \ } \ lhs = std::move(result_name).ValueOrDie(); @@ -101,7 +100,7 @@ GAR_RETURN_ON_ARROW_ERROR_AND_ASSIGN_IMPL( \ GAR_ASSIGN_OR_RAISE_NAME(_error_or_value, __COUNTER__), lhs, rexpr); -namespace GAR_NAMESPACE_INTERNAL { +namespace graphar { namespace internal { @@ -118,5 +117,5 @@ inline Status GenericToStatus(Result&& res) { } // namespace internal -} // namespace GAR_NAMESPACE_INTERNAL +} // namespace graphar #endif // GAR_UTIL_RESULT_H_ diff --git a/cpp/include/gar/util/status.h b/cpp/include/gar/util/status.h index 888ceb48b..70d904d8d 100644 --- a/cpp/include/gar/util/status.h +++ b/cpp/include/gar/util/status.h @@ -31,19 +31,18 @@ } while (0) /** @brief Propagate any non-successful Status to the caller. */ -#define GAR_RETURN_NOT_OK(status) \ - do { \ - ::GAR_NAMESPACE_INTERNAL::Status __s = \ - ::GAR_NAMESPACE_INTERNAL::internal::GenericToStatus(status); \ - GAR_RETURN_IF_(!__s.ok(), __s, GAR_STRINGIFY(status)); \ +#define GAR_RETURN_NOT_OK(status) \ + do { \ + ::graphar::Status __s = ::graphar::internal::GenericToStatus(status); \ + GAR_RETURN_IF_(!__s.ok(), __s, GAR_STRINGIFY(status)); \ } while (false) /** @brief Propagate any non-successful Arrow Status to the caller. */ -#define RETURN_NOT_ARROW_OK(status) \ - do { \ - if (GAR_PREDICT_FALSE(!status.ok())) { \ - return ::GAR_NAMESPACE_INTERNAL::Status::ArrowError(status.ToString()); \ - } \ +#define RETURN_NOT_ARROW_OK(status) \ + do { \ + if (GAR_PREDICT_FALSE(!status.ok())) { \ + return ::graphar::Status::ArrowError(status.ToString()); \ + } \ } while (false) #define GAR_RAISE_ERROR_IF_(condition, status, _) \ @@ -54,14 +53,13 @@ } while (0) /** @brief Throw runtime error if Status not OK. */ -#define GAR_RAISE_ERROR_NOT_OK(status) \ - do { \ - ::GAR_NAMESPACE_INTERNAL::Status __s = \ - ::GAR_NAMESPACE_INTERNAL::internal::GenericToStatus(status); \ - GAR_RAISE_ERROR_IF_(!__s.ok(), __s, GAR_STRINGIFY(status)); \ +#define GAR_RAISE_ERROR_NOT_OK(status) \ + do { \ + ::graphar::Status __s = ::graphar::internal::GenericToStatus(status); \ + GAR_RAISE_ERROR_IF_(!__s.ok(), __s, GAR_STRINGIFY(status)); \ } while (false) -namespace GAR_NAMESPACE_INTERNAL { +namespace graphar { namespace util { template @@ -278,6 +276,6 @@ inline Status GenericToStatus(Status&& st) { return std::move(st); } } // namespace internal -} // namespace GAR_NAMESPACE_INTERNAL +} // namespace graphar #endif // GAR_UTIL_STATUS_H_ diff --git a/cpp/include/gar/util/util.h b/cpp/include/gar/util/util.h index ad9772f1d..552982796 100644 --- a/cpp/include/gar/util/util.h +++ b/cpp/include/gar/util/util.h @@ -34,7 +34,7 @@ class ChunkedArray; class Array; } // namespace arrow -namespace GAR_NAMESPACE_INTERNAL { +namespace graphar { namespace util { @@ -248,5 +248,5 @@ using FloatArray = Array; using DoubleArray = Array; using StringArray = Array; -} // namespace GAR_NAMESPACE_INTERNAL +} // namespace graphar #endif // GAR_UTIL_UTIL_H_ diff --git a/cpp/include/gar/util/version_parser.h b/cpp/include/gar/util/version_parser.h index ddb520f6a..6e6b71f39 100644 --- a/cpp/include/gar/util/version_parser.h +++ b/cpp/include/gar/util/version_parser.h @@ -25,7 +25,7 @@ #include "gar/util/result.h" -namespace GAR_NAMESPACE_INTERNAL { +namespace graphar { /** InfoVersion is a class provide version information of info. */ class InfoVersion { @@ -107,5 +107,5 @@ class InfoVersion { std::vector user_define_types_; }; -} // namespace GAR_NAMESPACE_INTERNAL +} // namespace graphar #endif // GAR_UTIL_VERSION_PARSER_H_ diff --git a/cpp/include/gar/util/writer_util.h b/cpp/include/gar/util/writer_util.h index 05ae333b3..00cd3731f 100644 --- a/cpp/include/gar/util/writer_util.h +++ b/cpp/include/gar/util/writer_util.h @@ -19,7 +19,7 @@ #include "gar/util/macros.h" -namespace GAR_NAMESPACE_INTERNAL { +namespace graphar { /** * @brief The level for validating writing operations. @@ -38,5 +38,5 @@ enum class ValidateLevel : char { strong_validate = 3 }; -} // namespace GAR_NAMESPACE_INTERNAL +} // namespace graphar #endif // GAR_UTIL_WRITER_UTIL_H_ diff --git a/cpp/include/gar/util/yaml.h b/cpp/include/gar/util/yaml.h index 00e7cce0b..63021ebf1 100644 --- a/cpp/include/gar/util/yaml.h +++ b/cpp/include/gar/util/yaml.h @@ -28,7 +28,7 @@ namespace Yaml { class Node; } -namespace GAR_NAMESPACE_INTERNAL { +namespace graphar { /** A wrapper of ::Yaml::Node to provide functions to parse yaml. */ class Yaml { @@ -65,5 +65,5 @@ class Yaml { std::shared_ptr<::Yaml::Node> root_node_; }; -} // namespace GAR_NAMESPACE_INTERNAL +} // namespace graphar #endif // GAR_UTIL_YAML_H_ diff --git a/cpp/include/gar/writer/arrow_chunk_writer.h b/cpp/include/gar/writer/arrow_chunk_writer.h index 74ae4e1b6..8808afc80 100644 --- a/cpp/include/gar/writer/arrow_chunk_writer.h +++ b/cpp/include/gar/writer/arrow_chunk_writer.h @@ -29,7 +29,7 @@ namespace arrow { class Table; } -namespace GAR_NAMESPACE_INTERNAL { +namespace graphar { /** * @brief The writer for vertex property group chunks. @@ -729,5 +729,5 @@ class EdgeChunkWriter { ValidateLevel validate_level_; }; -} // namespace GAR_NAMESPACE_INTERNAL +} // namespace graphar #endif // GAR_WRITER_ARROW_CHUNK_WRITER_H_ diff --git a/cpp/include/gar/writer/edges_builder.h b/cpp/include/gar/writer/edges_builder.h index 7d251f380..36403c87f 100644 --- a/cpp/include/gar/writer/edges_builder.h +++ b/cpp/include/gar/writer/edges_builder.h @@ -34,7 +34,7 @@ namespace arrow { class Array; } -namespace GAR_NAMESPACE_INTERNAL { +namespace graphar { namespace builder { /** @@ -425,5 +425,5 @@ class EdgesBuilder { }; } // namespace builder -} // namespace GAR_NAMESPACE_INTERNAL +} // namespace graphar #endif // GAR_WRITER_EDGES_BUILDER_H_ diff --git a/cpp/include/gar/writer/vertices_builder.h b/cpp/include/gar/writer/vertices_builder.h index e5f4cb21a..8fc60df15 100644 --- a/cpp/include/gar/writer/vertices_builder.h +++ b/cpp/include/gar/writer/vertices_builder.h @@ -34,7 +34,7 @@ class Array; class Table; } // namespace arrow -namespace GAR_NAMESPACE_INTERNAL { +namespace graphar { namespace builder { /** @@ -346,5 +346,5 @@ class VerticesBuilder { }; } // namespace builder -} // namespace GAR_NAMESPACE_INTERNAL +} // namespace graphar #endif // GAR_WRITER_VERTICES_BUILDER_H_ diff --git a/cpp/src/arrow_chunk_reader.cc b/cpp/src/arrow_chunk_reader.cc index 9183d57f4..85cf4c77d 100644 --- a/cpp/src/arrow_chunk_reader.cc +++ b/cpp/src/arrow_chunk_reader.cc @@ -26,7 +26,7 @@ #include "gar/util/status.h" #include "gar/util/util.h" -namespace GAR_NAMESPACE_INTERNAL { +namespace graphar { VertexPropertyArrowChunkReader::VertexPropertyArrowChunkReader( const std::shared_ptr& vertex_info, @@ -700,4 +700,4 @@ Status AdjListPropertyArrowChunkReader::initOrUpdateEdgeChunkNum() { return Status::OK(); } -} // namespace GAR_NAMESPACE_INTERNAL +} // namespace graphar diff --git a/cpp/src/arrow_chunk_writer.cc b/cpp/src/arrow_chunk_writer.cc index ed5e61162..f74c2d894 100644 --- a/cpp/src/arrow_chunk_writer.cc +++ b/cpp/src/arrow_chunk_writer.cc @@ -39,7 +39,7 @@ #include "gar/util/util.h" #include "gar/writer/arrow_chunk_writer.h" -namespace GAR_NAMESPACE_INTERNAL { +namespace graphar { // common methods #if defined(ARROW_VERSION) && ARROW_VERSION >= 12000000 @@ -962,4 +962,4 @@ std::string EdgeChunkWriter::getSortColumnName(AdjListType adj_list_type) { } return GeneralParams::kSrcIndexCol; } -} // namespace GAR_NAMESPACE_INTERNAL +} // namespace graphar diff --git a/cpp/src/chunk_info_reader.cc b/cpp/src/chunk_info_reader.cc index 44c4cb8a4..e2cf0bb20 100644 --- a/cpp/src/chunk_info_reader.cc +++ b/cpp/src/chunk_info_reader.cc @@ -24,7 +24,7 @@ #include "gar/util/result.h" #include "gar/util/util.h" -namespace GAR_NAMESPACE_INTERNAL { +namespace graphar { VertexPropertyChunkInfoReader::VertexPropertyChunkInfoReader( const std::shared_ptr& vertex_info, @@ -506,4 +506,4 @@ AdjListPropertyChunkInfoReader::Make( graph_info->GetPrefix()); } -} // namespace GAR_NAMESPACE_INTERNAL +} // namespace graphar diff --git a/cpp/src/data_type.cc b/cpp/src/data_type.cc index dc59b8e7f..9465c6038 100644 --- a/cpp/src/data_type.cc +++ b/cpp/src/data_type.cc @@ -22,7 +22,7 @@ #include "gar/fwd.h" #include "gar/util/data_type.h" -namespace GAR_NAMESPACE_INTERNAL { +namespace graphar { std::shared_ptr DataType::DataTypeToArrowDataType( const std::shared_ptr& type) { @@ -163,4 +163,4 @@ TYPE_FACTORY(timestamp, Type::TIMESTAMP) std::shared_ptr list(const std::shared_ptr& value_type) { return std::make_shared(Type::LIST, value_type); } -} // namespace GAR_NAMESPACE_INTERNAL +} // namespace graphar diff --git a/cpp/src/edges_builder.cc b/cpp/src/edges_builder.cc index 44946af7e..b7e8ff3ed 100644 --- a/cpp/src/edges_builder.cc +++ b/cpp/src/edges_builder.cc @@ -21,7 +21,7 @@ #include "gar/util/result.h" #include "gar/writer/edges_builder.h" -namespace GAR_NAMESPACE_INTERNAL { +namespace graphar { namespace builder { Status EdgesBuilder::Dump() { @@ -347,4 +347,4 @@ Result> EdgesBuilder::getOffsetTable( } } // namespace builder -} // namespace GAR_NAMESPACE_INTERNAL +} // namespace graphar diff --git a/cpp/src/expression.cc b/cpp/src/expression.cc index 2dfc432c0..4f558f48a 100644 --- a/cpp/src/expression.cc +++ b/cpp/src/expression.cc @@ -32,7 +32,7 @@ limitations under the License. #include "gar/util/expression.h" #include "gar/util/result.h" -namespace GAR_NAMESPACE_INTERNAL { +namespace graphar { Result ExpressionProperty::Evaluate() { return arrow::compute::field_ref(property_.name); @@ -98,4 +98,4 @@ Result ExpressionOr::Evaluate() { return arrow::compute::or_(lexpr, rexpr); } -} // namespace GAR_NAMESPACE_INTERNAL +} // namespace graphar diff --git a/cpp/src/filesystem.cc b/cpp/src/filesystem.cc index b5528f1a4..cd55a6e19 100644 --- a/cpp/src/filesystem.cc +++ b/cpp/src/filesystem.cc @@ -27,7 +27,7 @@ #include "gar/util/expression.h" #include "gar/util/filesystem.h" -namespace GAR_NAMESPACE_INTERNAL { +namespace graphar { namespace ds = arrow::dataset; namespace detail { template @@ -310,4 +310,4 @@ template Result FileSystem::ReadFileToValue( template Status FileSystem::WriteValueToFile(const IdType&, const std::string&) const noexcept; -} // namespace GAR_NAMESPACE_INTERNAL +} // namespace graphar diff --git a/cpp/src/graph.cc b/cpp/src/graph.cc index 7cec1819c..23ff696ff 100644 --- a/cpp/src/graph.cc +++ b/cpp/src/graph.cc @@ -18,7 +18,7 @@ #include "gar/util/adj_list_type.h" #include "gar/util/convert_to_arrow_type.h" -namespace GAR_NAMESPACE_INTERNAL { +namespace graphar { template Status CastToAny(std::shared_ptr array, @@ -562,4 +562,4 @@ Result> EdgesCollection::Make( return Status::OK(); } -} // namespace GAR_NAMESPACE_INTERNAL +} // namespace graphar diff --git a/cpp/src/graph_info.cc b/cpp/src/graph_info.cc index 10f75dace..dffbbcb3e 100644 --- a/cpp/src/graph_info.cc +++ b/cpp/src/graph_info.cc @@ -26,7 +26,7 @@ #include "gar/util/version_parser.h" #include "gar/util/yaml.h" -namespace GAR_NAMESPACE_INTERNAL { +namespace graphar { #define CHECK_HAS_ADJ_LIST_TYPE(adj_list_type) \ do { \ @@ -1301,4 +1301,4 @@ Status GraphInfo::Save(const std::string& path) const { return fs->WriteValueToFile(yaml_content, no_url_path); } -} // namespace GAR_NAMESPACE_INTERNAL +} // namespace graphar diff --git a/cpp/src/reader_util.cc b/cpp/src/reader_util.cc index 6042960cc..423547d6d 100644 --- a/cpp/src/reader_util.cc +++ b/cpp/src/reader_util.cc @@ -27,7 +27,7 @@ #include "gar/util/filesystem.h" #include "gar/util/reader_util.h" -namespace GAR_NAMESPACE_INTERNAL { +namespace graphar { namespace util { @@ -205,4 +205,4 @@ Result GetEdgeNum(const std::string& prefix, } // namespace util -} // namespace GAR_NAMESPACE_INTERNAL +} // namespace graphar diff --git a/cpp/src/util.cc b/cpp/src/util.cc index 0e97c371e..dd6c3a856 100644 --- a/cpp/src/util.cc +++ b/cpp/src/util.cc @@ -21,7 +21,7 @@ #include "gar/util/util.h" -namespace GAR_NAMESPACE_INTERNAL { +namespace graphar { namespace util { @@ -97,4 +97,4 @@ std::string ValueGetter::Value(const void* data, int64_t offset) { } } // namespace util -} // namespace GAR_NAMESPACE_INTERNAL +} // namespace graphar diff --git a/cpp/src/version_parser.cc b/cpp/src/version_parser.cc index 6161e7675..b6047373d 100644 --- a/cpp/src/version_parser.cc +++ b/cpp/src/version_parser.cc @@ -20,7 +20,7 @@ #include "gar/util/version_parser.h" -namespace GAR_NAMESPACE_INTERNAL { +namespace graphar { // Helper function for parsing version string bool is_whitespace(char ch) { @@ -111,4 +111,4 @@ Result> InfoVersion::Parse( } return version; } -} // namespace GAR_NAMESPACE_INTERNAL +} // namespace graphar diff --git a/cpp/src/vertices_builder.cc b/cpp/src/vertices_builder.cc index a84561340..24c7ab642 100644 --- a/cpp/src/vertices_builder.cc +++ b/cpp/src/vertices_builder.cc @@ -18,7 +18,7 @@ #include "gar/graph_info.h" #include "gar/util/convert_to_arrow_type.h" -namespace GAR_NAMESPACE_INTERNAL { +namespace graphar { namespace builder { Status VerticesBuilder::validate(const Vertex& v, IdType index, @@ -230,4 +230,4 @@ Result> VerticesBuilder::convertToTable() { } } // namespace builder -} // namespace GAR_NAMESPACE_INTERNAL +} // namespace graphar diff --git a/cpp/src/yaml.cc b/cpp/src/yaml.cc index dfbf441a0..04e19dadf 100644 --- a/cpp/src/yaml.cc +++ b/cpp/src/yaml.cc @@ -22,7 +22,7 @@ #include "gar/util/result.h" #include "gar/util/yaml.h" -namespace GAR_NAMESPACE_INTERNAL { +namespace graphar { const ::Yaml::Node Yaml::operator[](const std::string& key) const { return root_node_->operator[](key); @@ -52,4 +52,4 @@ Result> Yaml::LoadFile(const std::string& file_name) { return std::make_shared(root_node); } -} // namespace GAR_NAMESPACE_INTERNAL +} // namespace graphar diff --git a/cpp/test/test_arrow_chunk_reader.cc b/cpp/test/test_arrow_chunk_reader.cc index 3dc030e2d..064b15782 100644 --- a/cpp/test/test_arrow_chunk_reader.cc +++ b/cpp/test/test_arrow_chunk_reader.cc @@ -27,14 +27,7 @@ #define CATCH_CONFIG_MAIN #include -using GAR_NAMESPACE::_And; -using GAR_NAMESPACE::_Equal; -using GAR_NAMESPACE::_LessThan; -using GAR_NAMESPACE::_Literal; -using GAR_NAMESPACE::_Property; -using GAR_NAMESPACE::util::FilterOptions; - -namespace GAR_NAMESPACE { +namespace graphar { TEST_CASE("ArrowChunkReader") { std::string root; @@ -137,7 +130,7 @@ TEST_CASE("ArrowChunkReader") { SECTION("pushdown by helper function") { std::cout << "Vertex property pushdown by helper function:\n"; // construct push down options - FilterOptions options; + util::FilterOptions options; options.filter = filter; options.columns = expected_cols; auto maybe_reader = VertexPropertyArrowChunkReader::Make( @@ -160,7 +153,7 @@ TEST_CASE("ArrowChunkReader") { SECTION("pushdown property that don't exist") { std::cout << "Vertex property pushdown property that don't exist:\n"; auto filter = _Equal(_Property("id"), _Literal(933)); - FilterOptions options; + util::FilterOptions options; options.filter = filter; options.columns = expected_cols; auto maybe_reader = VertexPropertyArrowChunkReader::Make( @@ -176,7 +169,7 @@ TEST_CASE("ArrowChunkReader") { std::cout << "Vertex property pushdown column that don't exist:\n"; auto filter = _Literal(true); std::vector expected_cols{"id"}; - FilterOptions options; + util::FilterOptions options; options.filter = filter; options.columns = expected_cols; auto maybe_reader = VertexPropertyArrowChunkReader::Make( @@ -277,7 +270,7 @@ TEST_CASE("ArrowChunkReader") { SECTION("AdjListPropertyArrowChunkReader") { auto maybe_reader = AdjListPropertyArrowChunkReader::Make( graph_info, src_label, edge_label, dst_label, edge_property_name, - GAR_NAMESPACE::AdjListType::ordered_by_source); + AdjListType::ordered_by_source); REQUIRE(maybe_reader.status().ok()); auto reader = maybe_reader.value(); @@ -327,7 +320,7 @@ TEST_CASE("ArrowChunkReader") { std::vector expected_cols{"creationDate"}; - FilterOptions options; + util::FilterOptions options; options.filter = filter; options.columns = expected_cols; @@ -363,7 +356,7 @@ TEST_CASE("ArrowChunkReader") { std::cout << "Adj list property pushdown by helper function: \n"; auto maybe_reader = AdjListPropertyArrowChunkReader::Make( graph_info, src_label, edge_label, dst_label, edge_property_name, - GAR_NAMESPACE::AdjListType::ordered_by_source, options); + AdjListType::ordered_by_source, options); REQUIRE(maybe_reader.status().ok()); auto reader = maybe_reader.value(); walkReader(reader); @@ -374,7 +367,7 @@ TEST_CASE("ArrowChunkReader") { << std::endl; auto maybe_reader = AdjListPropertyArrowChunkReader::Make( graph_info, src_label, edge_label, dst_label, edge_property_name, - GAR_NAMESPACE::AdjListType::ordered_by_source); + AdjListType::ordered_by_source); REQUIRE(maybe_reader.status().ok()); auto reader = maybe_reader.value(); reader->Filter(filter); @@ -386,7 +379,7 @@ TEST_CASE("ArrowChunkReader") { SECTION("set start vertex chunk index by seek_chunk_index") { auto maybe_reader = AdjListPropertyArrowChunkReader::Make( graph_info, src_label, edge_label, dst_label, edge_property_name, - GAR_NAMESPACE::AdjListType::ordered_by_source); + AdjListType::ordered_by_source); REQUIRE(maybe_reader.status().ok()); auto reader = maybe_reader.value(); // check reader start from vertex chunk 0 @@ -406,7 +399,7 @@ TEST_CASE("ArrowChunkReader") { SECTION("AdjListOffsetArrowChunkReader") { auto maybe_reader = AdjListOffsetArrowChunkReader::Make( graph_info, src_label, edge_label, dst_label, - GAR_NAMESPACE::AdjListType::ordered_by_source); + AdjListType::ordered_by_source); REQUIRE(maybe_reader.status().ok()); auto reader = maybe_reader.value(); auto result = reader->GetChunk(); @@ -429,4 +422,4 @@ TEST_CASE("ArrowChunkReader") { REQUIRE(reader->seek(1024).IsIndexError()); } } -} // namespace GAR_NAMESPACE +} // namespace graphar diff --git a/cpp/test/test_arrow_chunk_writer.cc b/cpp/test/test_arrow_chunk_writer.cc index a69ef6fbb..51b4cf4f7 100644 --- a/cpp/test/test_arrow_chunk_writer.cc +++ b/cpp/test/test_arrow_chunk_writer.cc @@ -39,7 +39,7 @@ #define CATCH_CONFIG_MAIN #include -namespace GAR_NAMESPACE { +namespace graphar { TEST_CASE("test_vertex_property_writer_from_file") { std::string root; @@ -182,8 +182,8 @@ TEST_CASE("test_edge_chunk_writer") { std::shared_ptr table = maybe_table - ->RenameColumns({GAR_NAMESPACE::GeneralParams::kSrcIndexCol, - GAR_NAMESPACE::GeneralParams::kDstIndexCol}) + ->RenameColumns( + {GeneralParams::kSrcIndexCol, GeneralParams::kDstIndexCol}) .ValueOrDie(); std::cout << table->schema()->ToString() << std::endl; std::cout << table->num_rows() << ' ' << table->num_columns() << std::endl; @@ -260,4 +260,4 @@ TEST_CASE("test_edge_chunk_writer") { // Invalid data type REQUIRE(writer->WritePropertyChunk(tmp_table, pg2, 0, 0).IsTypeError()); } -} // namespace GAR_NAMESPACE +} // namespace graphar diff --git a/cpp/test/test_builder.cc b/cpp/test/test_builder.cc index 3d9029f89..377d99154 100644 --- a/cpp/test/test_builder.cc +++ b/cpp/test/test_builder.cc @@ -39,7 +39,7 @@ #define CATCH_CONFIG_MAIN #include -namespace GAR_NAMESPACE { +namespace graphar { TEST_CASE("test_vertices_builder") { std::cout << "Test vertex builder" << std::endl; std::string root; @@ -214,4 +214,4 @@ TEST_CASE("test_edges_builder") { const IdType* ptr = reinterpret_cast(num->data()); REQUIRE((*ptr) == vertices_num); } -} // namespace GAR_NAMESPACE +} // namespace graphar diff --git a/cpp/test/test_chunk_info_reader.cc b/cpp/test/test_chunk_info_reader.cc index 90677e763..6e4232580 100644 --- a/cpp/test/test_chunk_info_reader.cc +++ b/cpp/test/test_chunk_info_reader.cc @@ -24,7 +24,7 @@ #define CATCH_CONFIG_MAIN #include -namespace GAR_NAMESPACE { +namespace graphar { TEST_CASE("ChunkInfoReader") { std::string root; @@ -302,4 +302,4 @@ TEST_CASE("ChunkInfoReader") { } } } -} // namespace GAR_NAMESPACE +} // namespace graphar diff --git a/cpp/test/test_graph.cc b/cpp/test/test_graph.cc index e179bf6ed..7fc0bf9ab 100644 --- a/cpp/test/test_graph.cc +++ b/cpp/test/test_graph.cc @@ -23,7 +23,7 @@ #define CATCH_CONFIG_MAIN #include -namespace GAR_NAMESPACE { +namespace graphar { TEST_CASE("Graph") { std::string root; REQUIRE(GetTestResourceRoot(&root).ok()); @@ -195,4 +195,4 @@ TEST_CASE("Graph") { REQUIRE(expect4.status().IsInvalid()); } } -} // namespace GAR_NAMESPACE +} // namespace graphar diff --git a/cpp/test/test_info.cc b/cpp/test/test_info.cc index 56291d898..3801ebe61 100644 --- a/cpp/test/test_info.cc +++ b/cpp/test/test_info.cc @@ -31,7 +31,7 @@ #define CATCH_CONFIG_MAIN #include -namespace GAR_NAMESPACE { +namespace graphar { TEST_CASE("InfoVersion") { InfoVersion info_version(1); @@ -791,4 +791,4 @@ TEST_CASE("LoadFromS3", "[!hide]") { REQUIRE(vertex_infos.size() == 8); REQUIRE(edge_infos.size() == 23); } -} // namespace GAR_NAMESPACE +} // namespace graphar diff --git a/cpp/test/util.h b/cpp/test/util.h index c5603bb3b..c03fc1ed9 100644 --- a/cpp/test/util.h +++ b/cpp/test/util.h @@ -22,16 +22,20 @@ #ifndef CPP_TEST_UTIL_H_ #define CPP_TEST_UTIL_H_ +namespace graphar { + // Return the value of the GAR_TEST_DATA environment variable or return error // Status -GAR_NAMESPACE::Status GetTestResourceRoot(std::string* out) { +Status GetTestResourceRoot(std::string* out) { const char* c_root = std::getenv("GAR_TEST_DATA"); if (!c_root) { - return GAR_NAMESPACE::Status::IOError( + return Status::IOError( "Test resources not found, set GAR_TEST_DATA to /testing"); } *out = std::string(c_root); - return GAR_NAMESPACE::Status::OK(); + return Status::OK(); } +} // namespace graphar + #endif // CPP_TEST_UTIL_H_ diff --git a/docs/cpp/examples/snap-to-graphar.rst b/docs/cpp/examples/snap-to-graphar.rst index f34cd73d0..3e569189b 100644 --- a/docs/cpp/examples/snap-to-graphar.rst +++ b/docs/cpp/examples/snap-to-graphar.rst @@ -24,13 +24,13 @@ For instance, the code snippet below illustrates the creation and storage of the .. code:: C++ - auto version = GAR_NAMESPACE::InfoVersion::Parse("gar/v1").value(); + auto version = graphar::InfoVersion::Parse("gar/v1").value(); // meta info std::string vertex_label = "node", vertex_prefix = "vertex/node/"; // create vertex info - auto vertex_info = GAR_NAMESPACE::CreateVertexInfo( + auto vertex_info = graphar::CreateVertexInfo( vertex_label, VERTEX_CHUNK_SIZE, {}, vertex_prefix, version); // save & dump vertex info @@ -54,7 +54,7 @@ The code snippet that follows demonstrates the generation and preservation of th .. code:: C++ // construct edges builder - auto e_builder = GAR_NAMESPACE::builder::EdgesBuilder::Make( + auto e_builder = graphar::builder::EdgesBuilder::Make( edge_info, save_path, ADJLIST_TYPE, VERTEX_COUNT) .value(); // read edge data from file @@ -70,7 +70,7 @@ The code snippet that follows demonstrates the generation and preservation of th if (!(iss >> src >> dst)) { break; } - GAR_NAMESPACE::builder::Edge e(src, dst); + graphar::builder::Edge e(src, dst); ASSERT(e_builder->AddEdge(e).ok()); }