Skip to content

Commit f77897e

Browse files
authored
[FEAT][C++] Change the default namespace to graphar (#413)
* [FEAT][C++] Change the default namespace to `graphar` Signed-off-by: acezen <qiaozi.zwb@alibaba-inc.com> * Fix the macro definition Signed-off-by: acezen <qiaozi.zwb@alibaba-inc.com> * Fix format Signed-off-by: acezen <qiaozi.zwb@alibaba-inc.com> --------- Signed-off-by: acezen <qiaozi.zwb@alibaba-inc.com>
1 parent 1592d34 commit f77897e

10 files changed

Lines changed: 108 additions & 109 deletions

File tree

cpp/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,15 @@ project(graph-archive LANGUAGES C CXX VERSION ${GAR_VERSION})
3737
# cmake options
3838
# ------------------------------------------------------------------------------
3939

40-
option(NAMESPACE "User specific namespace, default if GraphArchive" OFF)
40+
option(NAMESPACE "User specific namespace, default is graphar" OFF)
4141
option(BUILD_TESTS "Build unit tests" OFF)
4242
option(BUILD_EXAMPLES "Build examples" OFF)
4343
option(BUILD_BENCHMARKS "Build benchmarks" OFF)
4444

4545
if (NAMESPACE)
4646
add_definitions(-DGAR_NAMESPACE=${NAMESPACE})
4747
else()
48-
add_definitions(-DGAR_NAMESPACE=GraphArchive)
48+
add_definitions(-DGAR_NAMESPACE=graphar)
4949
endif()
5050
# ------------------------------------------------------------------------------
5151
# setting default cmake type to Release

cpp/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ Release build:
5959
Build with a custom namespace:
6060

6161
The `namespace` is configurable. By default,
62-
it is defined in `namespace GraphArchive`; however this can be toggled by
62+
it is defined in `namespace graphar`; however this can be toggled by
6363
setting `NAMESPACE` option with cmake:
6464

6565
```bash

cpp/examples/high_level_writer_example.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ void edges_builder() {
7575
auto edge_info = GAR_NAMESPACE::EdgeInfo::Load(edge_meta).value();
7676
auto vertex_count = 3;
7777
GAR_NAMESPACE::builder::EdgesBuilder builder(
78-
edge_info, "/tmp/", GraphArchive::AdjListType::ordered_by_dest,
78+
edge_info, "/tmp/", GAR_NAMESPACE::AdjListType::ordered_by_dest,
7979
vertex_count);
8080

8181
// set validate level

cpp/include/gar/fwd.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ class Status;
5050
* returns false. Sample usage:
5151
*
5252
* ```
53-
* GraphArchive::Result<Foo> result = CalculateFoo();
53+
* graphar::Result<Foo> result = CalculateFoo();
5454
* if (!result.has_error()) {
5555
* Foo foo = result.value();
5656
* foo.DoSomethingCool();

cpp/include/gar/util/macros.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
#if defined(GAR_NAMESPACE)
3939
#define GAR_NAMESPACE_INTERNAL GAR_NAMESPACE
4040
#else
41-
#define GAR_NAMESPACE_INTERNAL GraphArchive
41+
#define GAR_NAMESPACE_INTERNAL graphar
4242
#endif
4343

4444
#define GAR_EXPAND(x) x

cpp/test/test_builder.cc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,7 @@ TEST_CASE("test_edges_builder") {
141141
auto edge_info = EdgeInfo::Load(edge_meta).value();
142142
auto vertices_num = 903;
143143
auto maybe_builder = builder::EdgesBuilder::Make(
144-
edge_info, "/tmp/", GraphArchive::AdjListType::ordered_by_dest,
145-
vertices_num);
144+
edge_info, "/tmp/", AdjListType::ordered_by_dest, vertices_num);
146145
REQUIRE(!maybe_builder.has_error());
147146
auto builder = maybe_builder.value();
148147

docs/cpp/examples/bgl.rst

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@ The source code of CC based on BGL can be found at `bgl_example.cc`_. In this pr
1010
.. code:: C++
1111

1212
std::string path = ... // the path of the graph information file
13-
auto graph_info = GraphArchive::GraphInfo::Load(path).value();
13+
auto graph_info = graphar::GraphInfo::Load(path).value();
1414

1515
And then, the vertex collection and the edge collection are established as the handles to access the graph data:
1616

1717
.. code:: C++
1818

19-
auto maybe_vertices = GraphArchive::VerticesCollection::Make(graph_info, "person");
19+
auto maybe_vertices = graphar::VerticesCollection::Make(graph_info, "person");
2020
auto vertices = maybe_vertices.value();
21-
auto maybe_edges = GraphArchive::EdgesCollection::Make(graph_info, "person", "knows", "person", GraphArchive::AdjListType::ordered_by_source);
21+
auto maybe_edges = graphar::EdgesCollection::Make(graph_info, "person", "knows", "person", graphar::AdjListType::ordered_by_source);
2222
auto edges = maybe_edges.value();
2323

2424
Next, we construct the in-memory graph data structure for BGL by traversing the vertices and edges via GraphAr's high-level reading interface (the vertex iterator and the edge iterator):
@@ -35,7 +35,7 @@ Next, we construct the in-memory graph data structure for BGL by traversing the
3535
typedef typename boost::graph_traits<Graph>::vertex_descriptor Vertex;
3636

3737
// declare a graph object with (num_vertices) vertices and an edge iterator
38-
std::vector<std::pair<GraphArchive::IdType, GraphArchive::IdType>> edges_array;
38+
std::vector<std::pair<graphar::IdType, graphar::IdType>> edges_array;
3939
auto it_begin = edges->begin(), it_end = edges->end();
4040
for (auto it = it_begin; it != it_end; ++it)
4141
edges_array.push_back(std::make_pair(it.source(), it.destination()));
@@ -64,14 +64,14 @@ Finally, we could use a **VerticesBuilder** of GraphAr to write the results to n
6464
.. code:: C++
6565

6666
// construct a new property group
67-
GraphArchive::Property cc = {"cc", GraphArchive::int32(), false};
68-
std::vector<GraphArchive::Property> property_vector = {cc};
69-
auto group = GraphArchive::CreatePropertyGroup(property_vector, GraphArchive::FileType::PARQUET);
67+
graphar::Property cc = {"cc", graphar::int32(), false};
68+
std::vector<graphar::Property> property_vector = {cc};
69+
auto group = graphar::CreatePropertyGroup(property_vector, graphar::FileType::PARQUET);
7070

7171
// construct the new vertex info
7272
std::string vertex_label = "cc_result", vertex_prefix = "result/";
7373
int chunk_size = 100;
74-
auto new_info = GraphArchive::CreateVertexInfo(vertex_label, chunk_size, {group}, vertex_prefix);
74+
auto new_info = graphar::CreateVertexInfo(vertex_label, chunk_size, {group}, vertex_prefix);
7575

7676
// access the vertices via the index map and vertex iterator of BGL
7777
typedef boost::property_map<Graph, boost::vertex_index_t>::type IndexMap;
@@ -80,10 +80,10 @@ Finally, we could use a **VerticesBuilder** of GraphAr to write the results to n
8080
std::pair<vertex_iter, vertex_iter> vp;
8181

8282
// dump the results through the VerticesBuilder
83-
GraphArchive::builder::VerticesBuilder builder(new_info, "/tmp/");
83+
graphar::builder::VerticesBuilder builder(new_info, "/tmp/");
8484
for (vp = boost::vertices(g); vp.first!= vp.second; ++vp.first) {
8585
Vertex v = *vp.first;
86-
GraphArchive::builder::Vertex vertex(index[v]);
86+
graphar::builder::Vertex vertex(index[v]);
8787
vertex.AddProperty(cc.name, component[index[v]]);
8888
builder.AddVertex(vertex);
8989
}

docs/cpp/examples/out-of-core.rst

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,15 @@ This algorithm can be implemented based on streaming the edges via GraphAr's rea
3232
auto it_begin = edges->begin(), it_end = edges->end();
3333

3434
// initialize for all vertices
35-
std::vector<GraphArchive::IdType> component(num_vertices);
36-
for (GraphArchive::IdType i = 0; i < num_vertices; i++)
35+
std::vector<graphar::IdType> component(num_vertices);
36+
for (graphar::IdType i = 0; i < num_vertices; i++)
3737
component[i] = i;
3838

3939
// stream all edges for each iteration
4040
for (int iter = 0; ; iter++) {
4141
bool flag = false;
4242
for (auto it = it_begin; it != it_end; ++it) {
43-
GraphArchive::IdType src = it.source(), dst = it.destination();
43+
graphar::IdType src = it.source(), dst = it.destination();
4444
// update
4545
if (component[src] < component[dst]) {
4646
component[dst] = component[src];
@@ -76,16 +76,16 @@ An out-of-core BFS algorithm could be implemented based on streaming the graph d
7676
auto it_begin = edges->begin(), it_end = edges->end();
7777

7878
// initialize for all vertices
79-
GraphArchive::IdType root = 0; // the BFS root
79+
graphar::IdType root = 0; // the BFS root
8080
std::vector<int32_t> distance(num_vertices);
81-
for (GraphArchive::IdType i = 0; i < num_vertices; i++)
81+
for (graphar::IdType i = 0; i < num_vertices; i++)
8282
distance[i] = (i == root ? 0 : -1);
8383

8484
// stream all edges for each iteration
8585
for (int iter = 0; ; iter++) {
86-
GraphArchive::IdType count = 0;
86+
graphar::IdType count = 0;
8787
for (auto it = it_begin; it != it_end; ++it) {
88-
GraphArchive::IdType src = it.source(), dst = it.destination();
88+
graphar::IdType src = it.source(), dst = it.destination();
8989
// update
9090
if (distance[src] == iter && distance[dst] == -1) {
9191
distance[dst] = distance[src] + 1;

docs/cpp/getting-started.rst

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ Also, the metadata of a graph can be constructed easily through reading the alre
7979

8080
// construct graph information from file
8181
std::string path = ... // the path of the graph information file (e.g., ldbc_sample.graph.yml)
82-
auto graph_info = GraphArchive::GraphInfo::Load(path).value();
82+
auto graph_info = graphar::GraphInfo::Load(path).value();
8383

8484
// get vertex information
8585
auto vertex_info = graph_info->GetVertexInfo("person");
@@ -103,7 +103,7 @@ As a simple case, the following example shows how to read all vertices with labe
103103
.. code:: C++
104104

105105
graph_info = ...
106-
auto vertices = GraphArchive::VerticesCollection::Make(graph_info, "person").value();
106+
auto vertices = graphar::VerticesCollection::Make(graph_info, "person").value();
107107

108108
for (auto it = vertices->begin(); it != vertices->end(); ++it) {
109109
// get a vertex and access its data
@@ -116,7 +116,7 @@ The next example reads all edges with label "person_knows_person" from the above
116116
.. code:: C++
117117

118118
graph_info = ...
119-
auto expect = GraphArchive::EdgesCollection::Make(graph_info, "person", "konws", "person", GraphArchive::AdjListType::ordered_by_source);
119+
auto expect = graphar::EdgesCollection::Make(graph_info, "person", "konws", "person", graphar::AdjListType::ordered_by_source);
120120
auto edges = expect.value();
121121

122122
for (auto it = edges->begin(); it != edges->end(); ++it) {
@@ -137,10 +137,10 @@ As the simplest cases, the fist example below adds vertices to **VerticesBuilder
137137

138138
vertex_info = ...
139139
prefix = ...
140-
GraphArchive::builder::VerticesBuilder builder(vertex_info, prefix);
140+
graphar::builder::VerticesBuilder builder(vertex_info, prefix);
141141

142142
// add a vertex
143-
GraphArchive::builder::Vertex v;
143+
graphar::builder::Vertex v;
144144
v.AddProperty("id", 933);
145145
v.AddProperty("firstName", "Alice");
146146
builder.AddVertex(v);
@@ -155,10 +155,10 @@ As the simplest cases, the fist example below adds vertices to **VerticesBuilder
155155
edge_info = ...
156156
prefix = ...
157157
vertices_num = ...
158-
GraphArchive::builder::EdgesBuilder builder(edge_info, prefix, GraphArchive::AdjListType::ordered_by_source, vertices_num);
158+
graphar::builder::EdgesBuilder builder(edge_info, prefix, graphar::AdjListType::ordered_by_source, vertices_num);
159159

160160
// add an edge (0 -> 3)
161-
GraphArchive::builder::Edge e(0, 3);
161+
graphar::builder::Edge e(0, 3);
162162
e.AddProperty("creationDate", "2011-07-20T20:02:04.233+0000");
163163
builder.AddEdge(e);
164164
// add other edges

0 commit comments

Comments
 (0)