From a9161d89ffb49461a82fb28090b240064141a7df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=89=E7=90=86?= Date: Thu, 25 May 2023 11:13:49 +0800 Subject: [PATCH 1/5] Define a new macro ASSERT works for NDEBUG mode --- cpp/examples/bfs_father_example.cc | 40 ++++---- cpp/examples/bfs_pull_example.cc | 22 ++-- cpp/examples/bfs_push_example.cc | 22 ++-- cpp/examples/bfs_stream_example.cc | 22 ++-- cpp/examples/bgl_example.cc | 38 +++---- cpp/examples/cc_push_example.cc | 24 ++--- cpp/examples/cc_stream_example.cc | 22 ++-- cpp/examples/config.h | 33 ++++++ cpp/examples/construct_info_example.cc | 133 +++++++++++++------------ cpp/examples/pagerank_example.cc | 22 ++-- 10 files changed, 206 insertions(+), 172 deletions(-) diff --git a/cpp/examples/bfs_father_example.cc b/cpp/examples/bfs_father_example.cc index e73babd18..76a4c6be4 100644 --- a/cpp/examples/bfs_father_example.cc +++ b/cpp/examples/bfs_father_example.cc @@ -32,10 +32,10 @@ int main(int argc, char* argv[]) { // get the person vertices of graph std::string label = "person"; - assert(graph_info.GetVertexInfo(label).status().ok()); + ASSERT(graph_info.GetVertexInfo(label).status().ok()); auto maybe_vertices = GAR_NAMESPACE::ConstructVerticesCollection(graph_info, label); - assert(maybe_vertices.status().ok()); + ASSERT(maybe_vertices.status().ok()); auto& vertices = maybe_vertices.value(); int num_vertices = vertices.size(); std::cout << "num_vertices: " << num_vertices << std::endl; @@ -45,7 +45,7 @@ int main(int argc, char* argv[]) { auto maybe_edges = GAR_NAMESPACE::ConstructEdgesCollection( graph_info, src_label, edge_label, dst_label, GAR_NAMESPACE::AdjListType::unordered_by_source); - assert(!maybe_edges.has_error()); + ASSERT(!maybe_edges.has_error()); auto& edges = std::get>(maybe_edges.value()); @@ -90,16 +90,16 @@ int main(int argc, char* argv[]) { // extend the vertex_info auto maybe_vertex_info = graph_info.GetVertexInfo(label); - assert(maybe_vertex_info.status().ok()); + ASSERT(maybe_vertex_info.status().ok()); auto vertex_info = maybe_vertex_info.value(); auto maybe_extend_info = vertex_info.Extend(group); - assert(maybe_extend_info.status().ok()); + ASSERT(maybe_extend_info.status().ok()); auto extend_info = maybe_extend_info.value(); // dump the extened vertex info - assert(extend_info.IsValidated()); - assert(extend_info.Dump().status().ok()); - assert(extend_info.Save("/tmp/person-new-bfs-father.vertex.yml").ok()); + ASSERT(extend_info.IsValidated()); + 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/"); // convert results to arrow::Table @@ -111,20 +111,20 @@ int main(int argc, char* argv[]) { father.name, GAR_NAMESPACE::DataType::DataTypeToArrowDataType(father.type))); arrow::Int32Builder array_builder1; - assert(array_builder1.Reserve(num_vertices).ok()); - assert(array_builder1.AppendValues(distance).ok()); + ASSERT(array_builder1.Reserve(num_vertices).ok()); + ASSERT(array_builder1.AppendValues(distance).ok()); std::shared_ptr array1 = array_builder1.Finish().ValueOrDie(); arrays.push_back(array1); arrow::Int64Builder array_builder2; - assert(array_builder2.Reserve(num_vertices).ok()); + ASSERT(array_builder2.Reserve(num_vertices).ok()); for (int i = 0; i < num_vertices; i++) { if (pre[i] == -1) { - assert(array_builder2.AppendNull().ok()); + ASSERT(array_builder2.AppendNull().ok()); } else { auto it = vertices.find(pre[i]); auto father_id = it.property("id").value(); - assert(array_builder2.Append(father_id).ok()); + ASSERT(array_builder2.Append(father_id).ok()); } } std::shared_ptr array2 = array_builder2.Finish().ValueOrDie(); @@ -133,7 +133,7 @@ int main(int argc, char* argv[]) { auto schema = std::make_shared(schema_vector); std::shared_ptr table = arrow::Table::Make(schema, arrays); // dump the results through writer - assert(writer.WriteTable(table, group, 0).ok()); + ASSERT(writer.WriteTable(table, group, 0).ok()); // construct a new graph src_label = "person"; @@ -145,14 +145,14 @@ int main(int argc, char* argv[]) { GAR_NAMESPACE::EdgeInfo new_edge_info(src_label, edge_label, dst_label, edge_chunk_size, src_chunk_size, dst_chunk_size, directed, version); - assert(new_edge_info + ASSERT(new_edge_info .AddAdjList(GAR_NAMESPACE::AdjListType::ordered_by_source, GAR_NAMESPACE::FileType::CSV) .ok()); - assert(new_edge_info.IsValidated()); + 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()); + 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); @@ -160,7 +160,7 @@ int main(int argc, char* argv[]) { if (i == root || pre[i] == -1) continue; GAR_NAMESPACE::builder::Edge e(pre[i], i); - assert(edges_builder.AddEdge(e).ok()); + ASSERT(edges_builder.AddEdge(e).ok()); } - assert(edges_builder.Dump().ok()); + ASSERT(edges_builder.Dump().ok()); } diff --git a/cpp/examples/bfs_pull_example.cc b/cpp/examples/bfs_pull_example.cc index c949ce460..89eb1fd94 100644 --- a/cpp/examples/bfs_pull_example.cc +++ b/cpp/examples/bfs_pull_example.cc @@ -30,10 +30,10 @@ int main(int argc, char* argv[]) { // construct vertices collection std::string label = "person"; - assert(graph_info.GetVertexInfo(label).status().ok()); + ASSERT(graph_info.GetVertexInfo(label).status().ok()); auto maybe_vertices = GAR_NAMESPACE::ConstructVerticesCollection(graph_info, label); - assert(maybe_vertices.status().ok()); + ASSERT(maybe_vertices.status().ok()); auto& vertices = maybe_vertices.value(); int num_vertices = vertices.size(); std::cout << "num_vertices: " << num_vertices << std::endl; @@ -43,7 +43,7 @@ int main(int argc, char* argv[]) { auto maybe_edges = GAR_NAMESPACE::ConstructEdgesCollection( graph_info, src_label, edge_label, dst_label, GAR_NAMESPACE::AdjListType::ordered_by_dest); - assert(!maybe_edges.has_error()); + ASSERT(!maybe_edges.has_error()); auto& edges = std::get>(maybe_edges.value()); @@ -89,15 +89,15 @@ int main(int argc, char* argv[]) { GAR_NAMESPACE::FileType::PARQUET); // extend the vertex_info auto maybe_vertex_info = graph_info.GetVertexInfo(label); - assert(maybe_vertex_info.status().ok()); + ASSERT(maybe_vertex_info.status().ok()); auto vertex_info = maybe_vertex_info.value(); auto maybe_extend_info = vertex_info.Extend(group); - assert(maybe_extend_info.status().ok()); + ASSERT(maybe_extend_info.status().ok()); auto extend_info = maybe_extend_info.value(); // dump the extened vertex info - assert(extend_info.IsValidated()); - assert(extend_info.Dump().status().ok()); - assert(extend_info.Save("/tmp/person-new-bfs-pull.vertex.yml").ok()); + ASSERT(extend_info.IsValidated()); + 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/"); // convert results to arrow::Table @@ -106,12 +106,12 @@ int main(int argc, char* argv[]) { schema_vector.push_back(arrow::field( bfs.name, GAR_NAMESPACE::DataType::DataTypeToArrowDataType(bfs.type))); arrow::Int32Builder array_builder; - assert(array_builder.Reserve(num_vertices).ok()); - assert(array_builder.AppendValues(distance).ok()); + ASSERT(array_builder.Reserve(num_vertices).ok()); + ASSERT(array_builder.AppendValues(distance).ok()); std::shared_ptr array = array_builder.Finish().ValueOrDie(); arrays.push_back(array); auto schema = std::make_shared(schema_vector); std::shared_ptr table = arrow::Table::Make(schema, arrays); // dump the results through writer - assert(writer.WriteTable(table, group, 0).ok()); + ASSERT(writer.WriteTable(table, group, 0).ok()); } diff --git a/cpp/examples/bfs_push_example.cc b/cpp/examples/bfs_push_example.cc index 6e0dfaf56..515a4aaba 100644 --- a/cpp/examples/bfs_push_example.cc +++ b/cpp/examples/bfs_push_example.cc @@ -30,10 +30,10 @@ int main(int argc, char* argv[]) { // construct vertices collection std::string label = "person"; - assert(graph_info.GetVertexInfo(label).status().ok()); + ASSERT(graph_info.GetVertexInfo(label).status().ok()); auto maybe_vertices = GAR_NAMESPACE::ConstructVerticesCollection(graph_info, label); - assert(maybe_vertices.status().ok()); + ASSERT(maybe_vertices.status().ok()); auto& vertices = maybe_vertices.value(); int num_vertices = vertices.size(); std::cout << "num_vertices: " << num_vertices << std::endl; @@ -43,7 +43,7 @@ int main(int argc, char* argv[]) { auto maybe_edges = GAR_NAMESPACE::ConstructEdgesCollection( graph_info, src_label, edge_label, dst_label, GAR_NAMESPACE::AdjListType::ordered_by_source); - assert(!maybe_edges.has_error()); + ASSERT(!maybe_edges.has_error()); auto& edges = std::get>(maybe_edges.value()); @@ -88,15 +88,15 @@ int main(int argc, char* argv[]) { GAR_NAMESPACE::FileType::PARQUET); // extend the vertex_info auto maybe_vertex_info = graph_info.GetVertexInfo(label); - assert(maybe_vertex_info.status().ok()); + ASSERT(maybe_vertex_info.status().ok()); auto vertex_info = maybe_vertex_info.value(); auto maybe_extend_info = vertex_info.Extend(group); - assert(maybe_extend_info.status().ok()); + ASSERT(maybe_extend_info.status().ok()); auto extend_info = maybe_extend_info.value(); // dump the extened vertex info - assert(extend_info.IsValidated()); - assert(extend_info.Dump().status().ok()); - assert(extend_info.Save("/tmp/person-new-bfs-push.vertex.yml").ok()); + ASSERT(extend_info.IsValidated()); + 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/"); // convert results to arrow::Table @@ -105,12 +105,12 @@ int main(int argc, char* argv[]) { schema_vector.push_back(arrow::field( bfs.name, GAR_NAMESPACE::DataType::DataTypeToArrowDataType(bfs.type))); arrow::Int32Builder array_builder; - assert(array_builder.Reserve(num_vertices).ok()); - assert(array_builder.AppendValues(distance).ok()); + ASSERT(array_builder.Reserve(num_vertices).ok()); + ASSERT(array_builder.AppendValues(distance).ok()); std::shared_ptr array = array_builder.Finish().ValueOrDie(); arrays.push_back(array); auto schema = std::make_shared(schema_vector); std::shared_ptr table = arrow::Table::Make(schema, arrays); // dump the results through writer - assert(writer.WriteTable(table, group, 0).ok()); + ASSERT(writer.WriteTable(table, group, 0).ok()); } diff --git a/cpp/examples/bfs_stream_example.cc b/cpp/examples/bfs_stream_example.cc index 51d295445..853d2bd5c 100644 --- a/cpp/examples/bfs_stream_example.cc +++ b/cpp/examples/bfs_stream_example.cc @@ -30,10 +30,10 @@ int main(int argc, char* argv[]) { // construct vertices collection std::string label = "person"; - assert(graph_info.GetVertexInfo(label).status().ok()); + ASSERT(graph_info.GetVertexInfo(label).status().ok()); auto maybe_vertices = GAR_NAMESPACE::ConstructVerticesCollection(graph_info, label); - assert(maybe_vertices.status().ok()); + ASSERT(maybe_vertices.status().ok()); auto& vertices = maybe_vertices.value(); int num_vertices = vertices.size(); std::cout << "num_vertices: " << num_vertices << std::endl; @@ -43,7 +43,7 @@ int main(int argc, char* argv[]) { auto maybe_edges = GAR_NAMESPACE::ConstructEdgesCollection( graph_info, src_label, edge_label, dst_label, GAR_NAMESPACE::AdjListType::unordered_by_source); - assert(!maybe_edges.has_error()); + ASSERT(!maybe_edges.has_error()); auto& edges = std::get>(maybe_edges.value()); @@ -79,15 +79,15 @@ int main(int argc, char* argv[]) { GAR_NAMESPACE::FileType::PARQUET); // extend the vertex_info auto maybe_vertex_info = graph_info.GetVertexInfo(label); - assert(maybe_vertex_info.status().ok()); + ASSERT(maybe_vertex_info.status().ok()); auto vertex_info = maybe_vertex_info.value(); auto maybe_extend_info = vertex_info.Extend(group); - assert(maybe_extend_info.status().ok()); + ASSERT(maybe_extend_info.status().ok()); auto extend_info = maybe_extend_info.value(); // dump the extened vertex info - assert(extend_info.IsValidated()); - assert(extend_info.Dump().status().ok()); - assert(extend_info.Save("/tmp/person-new-bfs-stream.vertex.yml").ok()); + ASSERT(extend_info.IsValidated()); + 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/"); // convert results to arrow::Table @@ -96,12 +96,12 @@ int main(int argc, char* argv[]) { schema_vector.push_back(arrow::field( bfs.name, GAR_NAMESPACE::DataType::DataTypeToArrowDataType(bfs.type))); arrow::Int32Builder array_builder; - assert(array_builder.Reserve(num_vertices).ok()); - assert(array_builder.AppendValues(distance).ok()); + ASSERT(array_builder.Reserve(num_vertices).ok()); + ASSERT(array_builder.AppendValues(distance).ok()); std::shared_ptr array = array_builder.Finish().ValueOrDie(); arrays.push_back(array); auto schema = std::make_shared(schema_vector); std::shared_ptr table = arrow::Table::Make(schema, arrays); // dump the results through writer - assert(writer.WriteTable(table, group, 0).ok()); + ASSERT(writer.WriteTable(table, group, 0).ok()); } diff --git a/cpp/examples/bgl_example.cc b/cpp/examples/bgl_example.cc index 5fe2bc95b..593175275 100644 --- a/cpp/examples/bgl_example.cc +++ b/cpp/examples/bgl_example.cc @@ -32,15 +32,15 @@ int main(int argc, char* argv[]) { std::string path = TEST_DATA_DIR + "/ldbc_sample/parquet/ldbc_sample.graph.yml"; auto graph_info = GAR_NAMESPACE::GraphInfo::Load(path).value(); - assert(graph_info.GetVertexInfos().size() == 1); - assert(graph_info.GetEdgeInfos().size() == 1); + ASSERT(graph_info.GetVertexInfos().size() == 1); + ASSERT(graph_info.GetEdgeInfos().size() == 1); // construct vertices collection std::string label = "person"; - assert(graph_info.GetVertexInfo(label).status().ok()); + ASSERT(graph_info.GetVertexInfo(label).status().ok()); auto maybe_vertices = GAR_NAMESPACE::ConstructVerticesCollection(graph_info, label); - assert(maybe_vertices.status().ok()); + ASSERT(maybe_vertices.status().ok()); auto& vertices = maybe_vertices.value(); int num_vertices = vertices.size(); std::cout << "num_vertices: " << num_vertices << std::endl; @@ -50,7 +50,7 @@ int main(int argc, char* argv[]) { auto maybe_edges = GAR_NAMESPACE::ConstructEdgesCollection( graph_info, src_label, edge_label, dst_label, GAR_NAMESPACE::AdjListType::ordered_by_source); - assert(!maybe_edges.has_error()); + ASSERT(!maybe_edges.has_error()); auto& edges = std::get>(maybe_edges.value()); @@ -114,11 +114,11 @@ int main(int argc, char* argv[]) { GAR_NAMESPACE::InfoVersion version(1); GAR_NAMESPACE::VertexInfo new_info(vertex_label, chunk_size, version, vertex_prefix); - assert(new_info.AddPropertyGroup(group).ok()); + ASSERT(new_info.AddPropertyGroup(group).ok()); // dump new vertex info - assert(new_info.IsValidated()); - assert(new_info.Dump().status().ok()); - assert(new_info.Save("/tmp/cc_result.vertex.yml").ok()); + 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/"); // add vertices to the builder @@ -128,22 +128,22 @@ int main(int argc, char* argv[]) { vertex.AddProperty(cc.name, component[index[v]]); builder.AddVertex(vertex); } - assert(builder.GetNum() == num_vertices); + ASSERT(builder.GetNum() == num_vertices); // dump the results through builder - assert(builder.Dump().ok()); + ASSERT(builder.Dump().ok()); // method 2 for writing results: extend the original vertex info and write // results using writer extend the vertex_info auto maybe_vertex_info = graph_info.GetVertexInfo(label); - assert(maybe_vertex_info.status().ok()); + ASSERT(maybe_vertex_info.status().ok()); auto vertex_info = maybe_vertex_info.value(); auto maybe_extend_info = vertex_info.Extend(group); - assert(maybe_extend_info.status().ok()); + ASSERT(maybe_extend_info.status().ok()); auto extend_info = maybe_extend_info.value(); // dump the extened vertex info - assert(extend_info.IsValidated()); - assert(extend_info.Dump().status().ok()); - assert(extend_info.Save("/tmp/person-new.vertex.yml").ok()); + ASSERT(extend_info.IsValidated()); + 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/"); // convert results to arrow::Table @@ -153,12 +153,12 @@ int main(int argc, char* argv[]) { cc.name, GAR_NAMESPACE::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()); - assert(array_builder.AppendValues(component).ok()); + ASSERT(array_builder.Reserve(num_vertices).ok()); + ASSERT(array_builder.AppendValues(component).ok()); std::shared_ptr array = array_builder.Finish().ValueOrDie(); arrays.push_back(array); auto schema = std::make_shared(schema_vector); std::shared_ptr table = arrow::Table::Make(schema, arrays); // dump the results through writer - assert(writer.WriteTable(table, group, 0).ok()); + ASSERT(writer.WriteTable(table, group, 0).ok()); } diff --git a/cpp/examples/cc_push_example.cc b/cpp/examples/cc_push_example.cc index 19a72b3b9..babe273bd 100644 --- a/cpp/examples/cc_push_example.cc +++ b/cpp/examples/cc_push_example.cc @@ -31,10 +31,10 @@ int main(int argc, char* argv[]) { // construct vertices collection std::string label = "person"; - assert(graph_info.GetVertexInfo(label).status().ok()); + ASSERT(graph_info.GetVertexInfo(label).status().ok()); auto maybe_vertices = GAR_NAMESPACE::ConstructVerticesCollection(graph_info, label); - assert(maybe_vertices.status().ok()); + ASSERT(maybe_vertices.status().ok()); auto& vertices = maybe_vertices.value(); int num_vertices = vertices.size(); std::cout << "num_vertices: " << num_vertices << std::endl; @@ -44,13 +44,13 @@ int main(int argc, char* argv[]) { auto expect1 = GAR_NAMESPACE::ConstructEdgesCollection( graph_info, src_label, edge_label, dst_label, GAR_NAMESPACE::AdjListType::ordered_by_source); - assert(!expect1.has_error()); + ASSERT(!expect1.has_error()); auto& edges1 = std::get>(expect1.value()); auto expect2 = GAR_NAMESPACE::ConstructEdgesCollection( graph_info, src_label, edge_label, dst_label, GAR_NAMESPACE::AdjListType::ordered_by_dest); - assert(!expect2.has_error()); + ASSERT(!expect2.has_error()); auto& edges2 = std::get>(expect2.value()); @@ -123,15 +123,15 @@ int main(int argc, char* argv[]) { GAR_NAMESPACE::FileType::PARQUET); // extend the vertex_info auto maybe_vertex_info = graph_info.GetVertexInfo(label); - assert(maybe_vertex_info.status().ok()); + ASSERT(maybe_vertex_info.status().ok()); auto vertex_info = maybe_vertex_info.value(); auto maybe_extend_info = vertex_info.Extend(group); - assert(maybe_extend_info.status().ok()); + ASSERT(maybe_extend_info.status().ok()); auto extend_info = maybe_extend_info.value(); // dump the extened vertex info - assert(extend_info.IsValidated()); - assert(extend_info.Dump().status().ok()); - assert(extend_info.Save("/tmp/person-new-cc-push.vertex.yml").ok()); + ASSERT(extend_info.IsValidated()); + 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/"); // convert results to arrow::Table @@ -140,12 +140,12 @@ int main(int argc, char* argv[]) { schema_vector.push_back(arrow::field( cc.name, GAR_NAMESPACE::DataType::DataTypeToArrowDataType(cc.type))); arrow::Int64Builder array_builder; - assert(array_builder.Reserve(num_vertices).ok()); - assert(array_builder.AppendValues(component).ok()); + ASSERT(array_builder.Reserve(num_vertices).ok()); + ASSERT(array_builder.AppendValues(component).ok()); std::shared_ptr array = array_builder.Finish().ValueOrDie(); arrays.push_back(array); auto schema = std::make_shared(schema_vector); std::shared_ptr table = arrow::Table::Make(schema, arrays); // dump the results through writer - assert(writer.WriteTable(table, group, 0).ok()); + ASSERT(writer.WriteTable(table, group, 0).ok()); } diff --git a/cpp/examples/cc_stream_example.cc b/cpp/examples/cc_stream_example.cc index 292758e36..41cb27c4d 100644 --- a/cpp/examples/cc_stream_example.cc +++ b/cpp/examples/cc_stream_example.cc @@ -31,10 +31,10 @@ int main(int argc, char* argv[]) { // construct vertices collection std::string label = "person"; - assert(graph_info.GetVertexInfo(label).status().ok()); + ASSERT(graph_info.GetVertexInfo(label).status().ok()); auto maybe_vertices = GAR_NAMESPACE::ConstructVerticesCollection(graph_info, label); - assert(maybe_vertices.status().ok()); + ASSERT(maybe_vertices.status().ok()); auto& vertices = maybe_vertices.value(); int num_vertices = vertices.size(); std::cout << "num_vertices: " << num_vertices << std::endl; @@ -44,7 +44,7 @@ int main(int argc, char* argv[]) { auto maybe_edges = GAR_NAMESPACE::ConstructEdgesCollection( graph_info, src_label, edge_label, dst_label, GAR_NAMESPACE::AdjListType::ordered_by_source); - assert(!maybe_edges.has_error()); + ASSERT(!maybe_edges.has_error()); auto& edges = std::get>(maybe_edges.value()); @@ -90,15 +90,15 @@ int main(int argc, char* argv[]) { GAR_NAMESPACE::FileType::PARQUET); // extend the vertex_info auto maybe_vertex_info = graph_info.GetVertexInfo(label); - assert(maybe_vertex_info.status().ok()); + ASSERT(maybe_vertex_info.status().ok()); auto vertex_info = maybe_vertex_info.value(); auto maybe_extend_info = vertex_info.Extend(group); - assert(maybe_extend_info.status().ok()); + ASSERT(maybe_extend_info.status().ok()); auto extend_info = maybe_extend_info.value(); // dump the extened vertex info - assert(extend_info.IsValidated()); - assert(extend_info.Dump().status().ok()); - assert(extend_info.Save("/tmp/person-new.vertex.yml").ok()); + ASSERT(extend_info.IsValidated()); + 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/"); // convert results to arrow::Table @@ -107,12 +107,12 @@ int main(int argc, char* argv[]) { schema_vector.push_back(arrow::field( cc.name, GAR_NAMESPACE::DataType::DataTypeToArrowDataType(cc.type))); arrow::Int64Builder array_builder; - assert(array_builder.Reserve(num_vertices).ok()); - assert(array_builder.AppendValues(component).ok()); + ASSERT(array_builder.Reserve(num_vertices).ok()); + ASSERT(array_builder.AppendValues(component).ok()); std::shared_ptr array = array_builder.Finish().ValueOrDie(); arrays.push_back(array); auto schema = std::make_shared(schema_vector); std::shared_ptr table = arrow::Table::Make(schema, arrays); // dump the results through writer - assert(writer.WriteTable(table, group, 0).ok()); + ASSERT(writer.WriteTable(table, group, 0).ok()); } diff --git a/cpp/examples/config.h b/cpp/examples/config.h index 80b1c46f2..9f3d9a642 100644 --- a/cpp/examples/config.h +++ b/cpp/examples/config.h @@ -19,6 +19,39 @@ limitations under the License. #ifndef TEST_CONFIG_H_ #define TEST_CONFIG_H_ +// Define a new macro that is just like the standard C assert macro, +// except that it works even in optimized builds (where NDEBUG is +// defined) and it prints the failed assertion to stderr. +#ifndef ASSERT +#define ASSERT(x) \ + if (!(x)) { \ + char buf[2048]; \ + snprintf (buf, 2048, "Assertion failed in \"%s\", line %d\n" \ + "\tProbable bug in software.\n", \ + __FILE__, __LINE__); \ + ABORT (buf); \ + } \ + else // This 'else' exists to catch the user's following semicolon +#endif + +// Define a new macro that is just like the standard C abort macro, +// except that it prints the failed assertion to stderr. +#ifndef ABORT +#define ABORT(msg) \ + do { \ + fprintf (stderr, "%s", msg); \ + fflush (stderr); \ + abort (); \ + } while (0) +#endif + +// DASSERT is like ASSERT, but it only works in debug builds. +#ifdef DEBUG +# define DASSERT(x) ASSERT(x) +#else +# define DASSERT(x) +#endif + static const std::string TEST_DATA_DIR = // NOLINT std::filesystem::path(__FILE__) .parent_path() diff --git a/cpp/examples/construct_info_example.cc b/cpp/examples/construct_info_example.cc index a5cd1d265..34a1d7de6 100644 --- a/cpp/examples/construct_info_example.cc +++ b/cpp/examples/construct_info_example.cc @@ -15,6 +15,7 @@ limitations under the License. #include +#include "config.h" #include "gar/graph_info.h" int main(int argc, char* argv[]) { @@ -23,10 +24,10 @@ int main(int argc, char* argv[]) { GAR_NAMESPACE::InfoVersion version(1); GAR_NAMESPACE::GraphInfo graph_info(name, version, prefix); // validate - assert(graph_info.GetName() == name); - assert(graph_info.GetPrefix() == prefix); - assert(graph_info.GetVertexInfos().size() == 0); - assert(graph_info.GetEdgeInfos().size() == 0); + ASSERT(graph_info.GetName() == name); + ASSERT(graph_info.GetPrefix() == prefix); + ASSERT(graph_info.GetVertexInfos().size() == 0); + ASSERT(graph_info.GetEdgeInfos().size() == 0); /*------------------construct vertex info------------------*/ std::string vertex_label = "person", vertex_prefix = "vertex/person/"; @@ -34,9 +35,9 @@ int main(int argc, char* argv[]) { GAR_NAMESPACE::VertexInfo vertex_info(vertex_label, chunk_size, version, vertex_prefix); // validate - assert(vertex_info.GetLabel() == vertex_label); - assert(vertex_info.GetChunkSize() == chunk_size); - assert(vertex_info.GetPropertyGroups().size() == 0); + ASSERT(vertex_info.GetLabel() == vertex_label); + ASSERT(vertex_info.GetChunkSize() == chunk_size); + ASSERT(vertex_info.GetPropertyGroups().size() == 0); // construct properties and property groups GAR_NAMESPACE::Property id = { @@ -56,39 +57,39 @@ int main(int argc, char* argv[]) { GAR_NAMESPACE::FileType::ORC); // add property groups to vertex info & validate - assert(vertex_info.AddPropertyGroup(group1).ok()); - assert(vertex_info.GetPropertyGroups()[0] == group1); - assert(vertex_info.ContainProperty(id.name)); - assert(!vertex_info.ContainProperty(firstName.name)); - assert(vertex_info.ContainPropertyGroup(group1)); - assert(!vertex_info.ContainPropertyGroup(group2)); - assert(vertex_info.IsPrimaryKey(id.name).value()); - assert(!vertex_info.IsPrimaryKey(gender.name).status().ok()); - assert(vertex_info.GetPropertyType(id.name).value() == id.type); - assert(vertex_info.GetFilePath(group1, 0).value() == + ASSERT(vertex_info.AddPropertyGroup(group1).ok()); + ASSERT(vertex_info.GetPropertyGroups()[0] == group1); + ASSERT(vertex_info.ContainProperty(id.name)); + ASSERT(!vertex_info.ContainProperty(firstName.name)); + ASSERT(vertex_info.ContainPropertyGroup(group1)); + ASSERT(!vertex_info.ContainPropertyGroup(group2)); + ASSERT(vertex_info.IsPrimaryKey(id.name).value()); + ASSERT(!vertex_info.IsPrimaryKey(gender.name).status().ok()); + ASSERT(vertex_info.GetPropertyType(id.name).value() == id.type); + ASSERT(vertex_info.GetFilePath(group1, 0).value() == "vertex/person/id/chunk0"); // extend property groups & validate auto result = vertex_info.Extend(group2); - assert(result.status().ok()); + ASSERT(result.status().ok()); vertex_info = result.value(); - assert(vertex_info.ContainProperty(firstName.name)); - assert(vertex_info.ContainPropertyGroup(group2)); - assert(vertex_info.GetPropertyGroup(firstName.name) == group2); - assert(!vertex_info.IsPrimaryKey(gender.name).value()); - assert(vertex_info.IsValidated()); + ASSERT(vertex_info.ContainProperty(firstName.name)); + ASSERT(vertex_info.ContainPropertyGroup(group2)); + ASSERT(vertex_info.GetPropertyGroup(firstName.name) == group2); + ASSERT(!vertex_info.IsPrimaryKey(gender.name).value()); + ASSERT(vertex_info.IsValidated()); // save & dump - assert(!vertex_info.Dump().has_error()); - assert(vertex_info.Save("/tmp/person.vertex.yml").ok()); + ASSERT(!vertex_info.Dump().has_error()); + ASSERT(vertex_info.Save("/tmp/person.vertex.yml").ok()); /*------------------add vertex info to graph------------------*/ graph_info.AddVertex(vertex_info); - assert(graph_info.GetVertexInfos().size() == 1); - assert(graph_info.GetVertexInfo(vertex_label).status().ok()); - assert(graph_info.GetVertexPropertyGroup(vertex_label, id.name).value() == + ASSERT(graph_info.GetVertexInfos().size() == 1); + ASSERT(graph_info.GetVertexInfo(vertex_label).status().ok()); + ASSERT(graph_info.GetVertexPropertyGroup(vertex_label, id.name).value() == group1); - assert( + ASSERT( graph_info.GetVertexPropertyGroup(vertex_label, firstName.name).value() == group2); graph_info.AddVertexInfoPath("person.vertex.yml"); @@ -101,35 +102,35 @@ int main(int argc, char* argv[]) { GAR_NAMESPACE::EdgeInfo edge_info( src_label, edge_label, dst_label, edge_chunk_size, src_chunk_size, dst_chunk_size, directed, version, edge_prefix); - assert(edge_info.GetSrcLabel() == src_label); - assert(edge_info.GetEdgeLabel() == edge_label); - assert(edge_info.GetDstLabel() == dst_label); - assert(edge_info.GetChunkSize() == edge_chunk_size); - assert(edge_info.GetSrcChunkSize() == src_chunk_size); - assert(edge_info.GetDstChunkSize() == dst_chunk_size); - assert(edge_info.IsDirected() == directed); + ASSERT(edge_info.GetSrcLabel() == src_label); + ASSERT(edge_info.GetEdgeLabel() == edge_label); + ASSERT(edge_info.GetDstLabel() == dst_label); + ASSERT(edge_info.GetChunkSize() == edge_chunk_size); + ASSERT(edge_info.GetSrcChunkSize() == src_chunk_size); + ASSERT(edge_info.GetDstChunkSize() == dst_chunk_size); + ASSERT(edge_info.IsDirected() == directed); // add adj list & validate - assert(!edge_info.ContainAdjList( + ASSERT(!edge_info.ContainAdjList( GAR_NAMESPACE::AdjListType::unordered_by_source)); - assert(edge_info + ASSERT(edge_info .AddAdjList(GAR_NAMESPACE::AdjListType::unordered_by_source, GAR_NAMESPACE::FileType::PARQUET) .ok()); - assert(edge_info.ContainAdjList( + ASSERT(edge_info.ContainAdjList( GAR_NAMESPACE::AdjListType::unordered_by_source)); - assert(edge_info + ASSERT(edge_info .AddAdjList(GAR_NAMESPACE::AdjListType::ordered_by_dest, GAR_NAMESPACE::FileType::PARQUET) .ok()); - assert(edge_info.GetFileType(GAR_NAMESPACE::AdjListType::ordered_by_dest) + ASSERT(edge_info.GetFileType(GAR_NAMESPACE::AdjListType::ordered_by_dest) .value() == GAR_NAMESPACE::FileType::PARQUET); - assert( + 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 + ASSERT(edge_info .GetAdjListOffsetFilePath( 0, GAR_NAMESPACE::AdjListType::ordered_by_dest) .value() == @@ -142,69 +143,69 @@ int main(int argc, char* argv[]) { std::vector property_vector_3 = {creationDate}; GAR_NAMESPACE::PropertyGroup group3(property_vector_3, GAR_NAMESPACE::FileType::PARQUET); - assert(!edge_info.ContainPropertyGroup( + ASSERT(!edge_info.ContainPropertyGroup( group3, GAR_NAMESPACE::AdjListType::unordered_by_source)); - assert(!edge_info.ContainProperty(creationDate.name)); - assert(edge_info + ASSERT(!edge_info.ContainProperty(creationDate.name)); + ASSERT(edge_info .AddPropertyGroup(group3, GAR_NAMESPACE::AdjListType::unordered_by_source) .ok()); - assert(edge_info.ContainPropertyGroup( + ASSERT(edge_info.ContainPropertyGroup( group3, GAR_NAMESPACE::AdjListType::unordered_by_source)); - assert(edge_info.ContainProperty(creationDate.name)); - assert(edge_info + ASSERT(edge_info.ContainProperty(creationDate.name)); + ASSERT(edge_info .GetPropertyGroups(GAR_NAMESPACE::AdjListType::unordered_by_source) .value()[0] == group3); - assert(edge_info + ASSERT(edge_info .GetPropertyGroup(creationDate.name, GAR_NAMESPACE::AdjListType::unordered_by_source) .value() == group3); - assert(!edge_info + ASSERT(!edge_info .GetPropertyGroup(creationDate.name, GAR_NAMESPACE::AdjListType::ordered_by_source) .status() .ok()); - assert( + ASSERT( edge_info .GetPropertyFilePath( group3, GAR_NAMESPACE::AdjListType::unordered_by_source, 0, 0) .value() == "edge/person_knows_person/unordered_by_source/creationDate/part0/chunk0"); - assert(edge_info.GetPropertyType(creationDate.name).value() == + ASSERT(edge_info.GetPropertyType(creationDate.name).value() == creationDate.type); - assert(edge_info.IsPrimaryKey(creationDate.name).value() == + ASSERT(edge_info.IsPrimaryKey(creationDate.name).value() == creationDate.is_primary); // extend & validate auto res1 = edge_info.ExtendAdjList(GAR_NAMESPACE::AdjListType::ordered_by_source, GAR_NAMESPACE::FileType::PARQUET); - assert(res1.status().ok()); + ASSERT(res1.status().ok()); edge_info = res1.value(); - assert(edge_info.GetFileType(GAR_NAMESPACE::AdjListType::ordered_by_source) + ASSERT(edge_info.GetFileType(GAR_NAMESPACE::AdjListType::ordered_by_source) .value() == GAR_NAMESPACE::FileType::PARQUET); auto res2 = edge_info.ExtendPropertyGroup( group3, GAR_NAMESPACE::AdjListType::ordered_by_source); - assert(res2.status().ok()); - assert(edge_info.IsValidated()); + ASSERT(res2.status().ok()); + ASSERT(edge_info.IsValidated()); // save & dump - assert(!edge_info.Dump().has_error()); - assert(edge_info.Save("/tmp/person_knows_person.edge.yml").ok()); + ASSERT(!edge_info.Dump().has_error()); + ASSERT(edge_info.Save("/tmp/person_knows_person.edge.yml").ok()); /*------------------add edge info to graph------------------*/ graph_info.AddEdge(edge_info); graph_info.AddEdgeInfoPath("person_knows_person.edge.yml"); - assert(graph_info.GetEdgeInfos().size() == 1); - assert( + ASSERT(graph_info.GetEdgeInfos().size() == 1); + ASSERT( graph_info.GetEdgeInfo(src_label, edge_label, dst_label).status().ok()); - assert(graph_info + ASSERT(graph_info .GetEdgePropertyGroup( src_label, edge_label, dst_label, creationDate.name, GAR_NAMESPACE::AdjListType::unordered_by_source) .value() == group3); - assert(graph_info.IsValidated()); + ASSERT(graph_info.IsValidated()); // save & dump - assert(!graph_info.Dump().has_error()); - assert(graph_info.Save("/tmp/ldbc_sample.graph.yml").ok()); + ASSERT(!graph_info.Dump().has_error()); + ASSERT(graph_info.Save("/tmp/ldbc_sample.graph.yml").ok()); } diff --git a/cpp/examples/pagerank_example.cc b/cpp/examples/pagerank_example.cc index bb99ff404..ed3a92012 100644 --- a/cpp/examples/pagerank_example.cc +++ b/cpp/examples/pagerank_example.cc @@ -31,10 +31,10 @@ int main(int argc, char* argv[]) { // construct vertices collection std::string label = "person"; - assert(graph_info.GetVertexInfo(label).status().ok()); + ASSERT(graph_info.GetVertexInfo(label).status().ok()); auto maybe_vertices = GAR_NAMESPACE::ConstructVerticesCollection(graph_info, label); - assert(maybe_vertices.status().ok()); + ASSERT(maybe_vertices.status().ok()); auto& vertices = maybe_vertices.value(); int num_vertices = vertices.size(); std::cout << "num_vertices: " << num_vertices << std::endl; @@ -44,7 +44,7 @@ int main(int argc, char* argv[]) { auto maybe_edges = GAR_NAMESPACE::ConstructEdgesCollection( graph_info, src_label, edge_label, dst_label, GAR_NAMESPACE::AdjListType::ordered_by_source); - assert(!maybe_edges.has_error()); + ASSERT(!maybe_edges.has_error()); auto& edges = std::get>(maybe_edges.value()); @@ -89,15 +89,15 @@ int main(int argc, char* argv[]) { GAR_NAMESPACE::FileType::PARQUET); // extend the vertex_info auto maybe_vertex_info = graph_info.GetVertexInfo(label); - assert(maybe_vertex_info.status().ok()); + ASSERT(maybe_vertex_info.status().ok()); auto vertex_info = maybe_vertex_info.value(); auto maybe_extend_info = vertex_info.Extend(group); - assert(maybe_extend_info.status().ok()); + ASSERT(maybe_extend_info.status().ok()); auto extend_info = maybe_extend_info.value(); // dump the extened vertex info - assert(extend_info.IsValidated()); - assert(extend_info.Dump().status().ok()); - assert(extend_info.Save("/tmp/person-new-pagerank.vertex.yml").ok()); + ASSERT(extend_info.IsValidated()); + 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/"); // convert results to arrow::Table @@ -107,12 +107,12 @@ int main(int argc, char* argv[]) { pagerank.name, GAR_NAMESPACE::DataType::DataTypeToArrowDataType(pagerank.type))); arrow::DoubleBuilder array_builder; - assert(array_builder.Reserve(num_vertices).ok()); - assert(array_builder.AppendValues(pr_curr).ok()); + ASSERT(array_builder.Reserve(num_vertices).ok()); + ASSERT(array_builder.AppendValues(pr_curr).ok()); std::shared_ptr array = array_builder.Finish().ValueOrDie(); arrays.push_back(array); auto schema = std::make_shared(schema_vector); std::shared_ptr table = arrow::Table::Make(schema, arrays); // dump the results through writer - assert(writer.WriteTable(table, group, 0).ok()); + ASSERT(writer.WriteTable(table, group, 0).ok()); } From 7bcbdd8668f4f84ef6df3286d611309f48b8b0a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=89=E7=90=86?= Date: Thu, 25 May 2023 11:14:00 +0800 Subject: [PATCH 2/5] Format --- cpp/examples/config.h | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/cpp/examples/config.h b/cpp/examples/config.h index 9f3d9a642..7ee9d7ac0 100644 --- a/cpp/examples/config.h +++ b/cpp/examples/config.h @@ -23,33 +23,33 @@ limitations under the License. // except that it works even in optimized builds (where NDEBUG is // defined) and it prints the failed assertion to stderr. #ifndef ASSERT -#define ASSERT(x) \ - if (!(x)) { \ - char buf[2048]; \ - snprintf (buf, 2048, "Assertion failed in \"%s\", line %d\n" \ - "\tProbable bug in software.\n", \ - __FILE__, __LINE__); \ - ABORT (buf); \ - } \ - else // This 'else' exists to catch the user's following semicolon +#define ASSERT(x) \ + if (!(x)) { \ + char buf[2048]; \ + snprintf(buf, 2048, \ + "Assertion failed in \"%s\", line %d\n" \ + "\tProbable bug in software.\n", \ + __FILE__, __LINE__); \ + ABORT(buf); \ + } else // This 'else' exists to catch the user's following semicolon #endif -// Define a new macro that is just like the standard C abort macro, +// Define a new macro that is just like the standard C abort macro, // except that it prints the failed assertion to stderr. #ifndef ABORT -#define ABORT(msg) \ - do { \ - fprintf (stderr, "%s", msg); \ - fflush (stderr); \ - abort (); \ - } while (0) +#define ABORT(msg) \ + do { \ + fprintf(stderr, "%s", msg); \ + fflush(stderr); \ + abort(); \ + } while (0) #endif // DASSERT is like ASSERT, but it only works in debug builds. #ifdef DEBUG -# define DASSERT(x) ASSERT(x) +#define DASSERT(x) ASSERT(x) #else -# define DASSERT(x) +#define DASSERT(x) #endif static const std::string TEST_DATA_DIR = // NOLINT From 7aeb9a3ef9478dfeb6c11964874e43a0ea79384e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=89=E7=90=86?= Date: Thu, 25 May 2023 11:14:13 +0800 Subject: [PATCH 3/5] Update testing data --- testing | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testing b/testing index ad3725825..d8dd7fd93 160000 --- a/testing +++ b/testing @@ -1 +1 @@ -Subproject commit ad3725825deceb6522be8a9b40b3e3c4706493e6 +Subproject commit d8dd7fd931a3893f81fa236b7be20952667ac716 From c5968e6ddbb358b867df8b3385c9d6af4b5f52f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=89=E7=90=86?= Date: Thu, 25 May 2023 11:37:16 +0800 Subject: [PATCH 4/5] Update & format --- cpp/CMakeLists.txt | 5 +++-- cpp/examples/bfs_father_example.cc | 2 +- cpp/examples/bfs_pull_example.cc | 2 +- cpp/examples/bfs_push_example.cc | 2 +- cpp/examples/bfs_stream_example.cc | 2 +- cpp/examples/bgl_example.cc | 2 +- cpp/examples/cc_push_example.cc | 2 +- cpp/examples/cc_stream_example.cc | 2 +- cpp/examples/config.h | 11 ++++++----- cpp/examples/construct_info_example.cc | 2 +- cpp/examples/pagerank_example.cc | 2 +- 11 files changed, 18 insertions(+), 16 deletions(-) diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt index 316ef32c0..be3abdc2f 100644 --- a/cpp/CMakeLists.txt +++ b/cpp/CMakeLists.txt @@ -338,10 +338,11 @@ endif() # Format code & cpplint # ------------------------------------------------------------------------------ file(GLOB_RECURSE FILES_NEED_FORMAT "include/gar/*.h" "src/*.cc" - "test/*.h" "test/*.cc") + "test/*.h" "test/*.cc" + "examples/*.cc" "examples/*.h") file(GLOB_RECURSE FILES_NEED_LINT "include/gar/*.h" "src/*.cc" "test/*.h" "test/*.cc" - ) + "examples/*.cc" "examples/*.h") add_custom_target(gar-clformat COMMAND clang-format --style=file -i ${FILES_NEED_FORMAT} diff --git a/cpp/examples/bfs_father_example.cc b/cpp/examples/bfs_father_example.cc index 76a4c6be4..9b0256814 100644 --- a/cpp/examples/bfs_father_example.cc +++ b/cpp/examples/bfs_father_example.cc @@ -17,7 +17,7 @@ limitations under the License. #include "arrow/api.h" -#include "config.h" +#include "./config.h" #include "gar/graph.h" #include "gar/graph_info.h" #include "gar/reader/arrow_chunk_reader.h" diff --git a/cpp/examples/bfs_pull_example.cc b/cpp/examples/bfs_pull_example.cc index 89eb1fd94..b59ff5824 100644 --- a/cpp/examples/bfs_pull_example.cc +++ b/cpp/examples/bfs_pull_example.cc @@ -16,7 +16,7 @@ limitations under the License. #include "arrow/api.h" -#include "config.h" +#include "./config.h" #include "gar/graph.h" #include "gar/graph_info.h" #include "gar/reader/arrow_chunk_reader.h" diff --git a/cpp/examples/bfs_push_example.cc b/cpp/examples/bfs_push_example.cc index 515a4aaba..f2c709054 100644 --- a/cpp/examples/bfs_push_example.cc +++ b/cpp/examples/bfs_push_example.cc @@ -16,7 +16,7 @@ limitations under the License. #include "arrow/api.h" -#include "config.h" +#include "./config.h" #include "gar/graph.h" #include "gar/graph_info.h" #include "gar/reader/arrow_chunk_reader.h" diff --git a/cpp/examples/bfs_stream_example.cc b/cpp/examples/bfs_stream_example.cc index 853d2bd5c..f4f52e082 100644 --- a/cpp/examples/bfs_stream_example.cc +++ b/cpp/examples/bfs_stream_example.cc @@ -16,7 +16,7 @@ limitations under the License. #include "arrow/api.h" -#include "config.h" +#include "./config.h" #include "gar/graph.h" #include "gar/graph_info.h" #include "gar/reader/arrow_chunk_reader.h" diff --git a/cpp/examples/bgl_example.cc b/cpp/examples/bgl_example.cc index 593175275..da3304c66 100644 --- a/cpp/examples/bgl_example.cc +++ b/cpp/examples/bgl_example.cc @@ -20,7 +20,7 @@ limitations under the License. #include "arrow/api.h" -#include "config.h" +#include "./config.h" #include "gar/graph.h" #include "gar/graph_info.h" #include "gar/reader/arrow_chunk_reader.h" diff --git a/cpp/examples/cc_push_example.cc b/cpp/examples/cc_push_example.cc index babe273bd..be3547d36 100644 --- a/cpp/examples/cc_push_example.cc +++ b/cpp/examples/cc_push_example.cc @@ -17,7 +17,7 @@ limitations under the License. #include "arrow/api.h" -#include "config.h" +#include "./config.h" #include "gar/graph.h" #include "gar/graph_info.h" #include "gar/reader/arrow_chunk_reader.h" diff --git a/cpp/examples/cc_stream_example.cc b/cpp/examples/cc_stream_example.cc index 41cb27c4d..cec84f5a2 100644 --- a/cpp/examples/cc_stream_example.cc +++ b/cpp/examples/cc_stream_example.cc @@ -17,7 +17,7 @@ limitations under the License. #include "arrow/api.h" -#include "config.h" +#include "./config.h" #include "gar/graph.h" #include "gar/graph_info.h" #include "gar/reader/arrow_chunk_reader.h" diff --git a/cpp/examples/config.h b/cpp/examples/config.h index 7ee9d7ac0..e69b42de5 100644 --- a/cpp/examples/config.h +++ b/cpp/examples/config.h @@ -16,8 +16,8 @@ limitations under the License. #include #include -#ifndef TEST_CONFIG_H_ -#define TEST_CONFIG_H_ +#ifndef CPP_EXAMPLES_CONFIG_H_ +#define CPP_EXAMPLES_CONFIG_H_ // Define a new macro that is just like the standard C assert macro, // except that it works even in optimized builds (where NDEBUG is @@ -26,12 +26,13 @@ limitations under the License. #define ASSERT(x) \ if (!(x)) { \ char buf[2048]; \ - snprintf(buf, 2048, \ + snprintf(buf, sizeof(buf), \ "Assertion failed in \"%s\", line %d\n" \ "\tProbable bug in software.\n", \ __FILE__, __LINE__); \ ABORT(buf); \ - } else // This 'else' exists to catch the user's following semicolon + } else // NOLINT +// The 'else' exists to catch the user's following semicolon #endif // Define a new macro that is just like the standard C abort macro, @@ -60,4 +61,4 @@ static const std::string TEST_DATA_DIR = // NOLINT .string() + "/testing"; -#endif // TEST_CONFIG_H_ +#endif // CPP_EXAMPLES_CONFIG_H_ diff --git a/cpp/examples/construct_info_example.cc b/cpp/examples/construct_info_example.cc index 34a1d7de6..c4ea5ada2 100644 --- a/cpp/examples/construct_info_example.cc +++ b/cpp/examples/construct_info_example.cc @@ -15,7 +15,7 @@ limitations under the License. #include -#include "config.h" +#include "./config.h" #include "gar/graph_info.h" int main(int argc, char* argv[]) { diff --git a/cpp/examples/pagerank_example.cc b/cpp/examples/pagerank_example.cc index ed3a92012..7ce81f4f5 100644 --- a/cpp/examples/pagerank_example.cc +++ b/cpp/examples/pagerank_example.cc @@ -17,7 +17,7 @@ limitations under the License. #include "arrow/api.h" #include "arrow/filesystem/api.h" -#include "config.h" +#include "./config.h" #include "gar/graph.h" #include "gar/graph_info.h" #include "gar/reader/arrow_chunk_reader.h" From 06544970ca9dde5093297e31fcd9ce980f6f0653 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=89=E7=90=86?= Date: Thu, 25 May 2023 11:43:24 +0800 Subject: [PATCH 5/5] Minor --- cpp/CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt index be3abdc2f..63440c90c 100644 --- a/cpp/CMakeLists.txt +++ b/cpp/CMakeLists.txt @@ -339,10 +339,10 @@ endif() # ------------------------------------------------------------------------------ file(GLOB_RECURSE FILES_NEED_FORMAT "include/gar/*.h" "src/*.cc" "test/*.h" "test/*.cc" - "examples/*.cc" "examples/*.h") + "examples/*.h" "examples/*.cc") file(GLOB_RECURSE FILES_NEED_LINT "include/gar/*.h" "src/*.cc" "test/*.h" "test/*.cc" - "examples/*.cc" "examples/*.h") + "examples/*.h" "examples/*.cc") add_custom_target(gar-clformat COMMAND clang-format --style=file -i ${FILES_NEED_FORMAT}