Skip to content

Commit bdee5bd

Browse files
committed
grin api rename
1 parent 6f80b2d commit bdee5bd

File tree

21 files changed

+148
-7349
lines changed

21 files changed

+148
-7349
lines changed

modules/graph/fragment/arrow_fragment.grin.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ class GRIN_ArrowFragment {
318318
void init(GRIN_PARTITIONED_GRAPH partitioned_graph, GRIN_PARTITION partition) {
319319
pg_ = partitioned_graph;
320320
partition_ = partition;
321-
g_ = grin_get_local_graph_from_partition(pg_, partition_);
321+
g_ = grin_get_local_graph_by_partition(pg_, partition_);
322322
}
323323

324324
bool directed() const {
@@ -414,7 +414,7 @@ class GRIN_ArrowFragment {
414414
template <typename T>
415415
bool GetVertex(GRIN_VERTEX_TYPE label, T& oid, GRIN_VERTEX v) {
416416
if (GRIN_DATATYPE_ENUM<T>::value != grin_get_vertex_original_id_type(g_)) return false;
417-
v = grin_get_vertex_from_original_id_by_type(g_, label, (GRIN_VERTEX_ORIGINAL_ID)(&oid));
417+
v = grin_get_vertex_by_original_id_by_type(g_, label, (GRIN_VERTEX_ORIGINAL_ID)(&oid));
418418
return v != NULL;
419419
}
420420

@@ -430,7 +430,7 @@ class GRIN_ArrowFragment {
430430

431431
#ifdef GRIN_NATURAL_PARTITION_ID_TRAIT
432432
GRIN_PARTITION_ID GetPartition(GRIN_VERTEX u) const {
433-
auto vref = grin_get_vertex_ref_for_vertex(g_, u);
433+
auto vref = grin_get_vertex_ref_by_vertex(g_, u);
434434
auto partition = grin_get_master_partition_from_vertex_ref(g_, vref);
435435
return grin_get_partition_id(pg_, partition);
436436
}
@@ -612,7 +612,7 @@ class GRIN_ArrowFragment {
612612
if (in_edge) {
613613
auto es = GetIncomingAdjList(*v, etype);
614614
for (auto& e : es) {
615-
auto vref = grin_get_vertex_ref_for_vertex(g_, e.neighbor());
615+
auto vref = grin_get_vertex_ref_by_vertex(g_, e.neighbor());
616616
auto p = grin_get_master_partition_from_vertex_ref(g_, vref);
617617

618618
if (!grin_equal_partition(g_, p, partition_)) {
@@ -628,7 +628,7 @@ class GRIN_ArrowFragment {
628628
if (out_edge) {
629629
auto es = GetOutgoingAdjList(*v, etype);
630630
for (auto& e : es) {
631-
auto vref = grin_get_vertex_ref_for_vertex(g_, e.neighbor());
631+
auto vref = grin_get_vertex_ref_by_vertex(g_, e.neighbor());
632632
auto p = grin_get_master_partition_from_vertex_ref(g_, vref);
633633

634634
if (!grin_equal_partition(g_, p, partition_)) {

modules/graph/grin/c/test.c

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ GRIN_GRAPH get_graph(int argc, char** argv) {
2424
GRIN_PARTITION_LIST local_partitions = grin_get_local_partition_list(pg);
2525
GRIN_PARTITION partition =
2626
grin_get_partition_from_list(pg, local_partitions, 0);
27-
GRIN_GRAPH g = grin_get_local_graph_from_partition(pg, partition);
27+
GRIN_GRAPH g = grin_get_local_graph_by_partition(pg, partition);
2828
#else
2929
GRIN_GRAPH g = grin_get_graph_from_storage(argc - 1, &(argv[1]));
3030
#endif
@@ -108,7 +108,7 @@ void test_property_type(int argc, char** argv) {
108108
#ifdef GRIN_TRAIT_NATURAL_ID_FOR_VERTEX_TYPE
109109
printf("vertex type id: %u\n", grin_get_vertex_type_id(g, vt));
110110
GRIN_VERTEX_TYPE vt1 =
111-
grin_get_vertex_type_from_id(g, grin_get_vertex_type_id(g, vt));
111+
grin_get_vertex_type_by_id(g, grin_get_vertex_type_id(g, vt));
112112
if (!grin_equal_vertex_type(g, vt, vt1)) {
113113
printf("vertex type id not match\n");
114114
}
@@ -170,18 +170,18 @@ void test_property_type(int argc, char** argv) {
170170
#ifdef GRIN_TRAIT_NATURAL_ID_FOR_EDGE_TYPE
171171
printf("edge type id: %u\n", grin_get_edge_type_id(g, et));
172172
GRIN_EDGE_TYPE et1 =
173-
grin_get_edge_type_from_id(g, grin_get_edge_type_id(g, et));
173+
grin_get_edge_type_by_id(g, grin_get_edge_type_id(g, et));
174174
if (!grin_equal_edge_type(g, et, et1)) {
175175
printf("edge type id not match\n");
176176
}
177177
grin_destroy_edge_type(g, et1);
178178
#endif
179179
// relation
180-
GRIN_VERTEX_TYPE_LIST src_vtl = grin_get_src_types_from_edge_type(g, et);
180+
GRIN_VERTEX_TYPE_LIST src_vtl = grin_get_src_types_by_edge_type(g, et);
181181
size_t src_vtl_size = grin_get_vertex_type_list_size(g, src_vtl);
182182
printf("source vertex type list size: %zu\n", src_vtl_size);
183183

184-
GRIN_VERTEX_TYPE_LIST dst_vtl = grin_get_dst_types_from_edge_type(g, et);
184+
GRIN_VERTEX_TYPE_LIST dst_vtl = grin_get_dst_types_by_edge_type(g, et);
185185
size_t dst_vtl_size = grin_get_vertex_type_list_size(g, dst_vtl);
186186
printf("destination vertex type list size: %zu\n", dst_vtl_size);
187187

@@ -310,7 +310,7 @@ void test_property_topology(int argc, char** argv) {
310310
GRIN_DATATYPE dt = grin_get_vertex_original_id_type(g);
311311
if (dt == Int64) {
312312
long int v0id = 4;
313-
GRIN_VERTEX v0 = grin_get_vertex_from_original_id_by_type(g, vt, &v0id);
313+
GRIN_VERTEX v0 = grin_get_vertex_by_original_id_by_type(g, vt, &v0id);
314314
if (v0 == GRIN_NULL_VERTEX) {
315315
printf("(Wrong) vertex of id %ld can not be found\n", v0id);
316316
} else {
@@ -420,14 +420,14 @@ void test_property_vertex_table(int argc, char** argv) {
420420
GRIN_ROW row = grin_get_row_from_vertex_property_table(g, vpt, v, vpl);
421421
for (size_t j = 0; j < vpl_size; ++j) {
422422
GRIN_VERTEX_PROPERTY vp = grin_get_vertex_property_from_list(g, vpl, j);
423-
GRIN_VERTEX_TYPE vt1 = grin_get_vertex_property_vertex_type(g, vp);
423+
GRIN_VERTEX_TYPE vt1 = grin_get_vertex_type_from_property(g, vp);
424424
if (!grin_equal_vertex_type(g, vt, vt1)) {
425425
printf("vertex type not match by property\n");
426426
}
427427
grin_destroy_vertex_type(g, vt1);
428428
#ifdef GRIN_TRAIT_NATURAL_ID_FOR_VERTEX_PROPERTY
429429
unsigned int id = grin_get_vertex_property_id(g, vt, vp);
430-
GRIN_VERTEX_PROPERTY vp1 = grin_get_vertex_property_from_id(g, vt, id);
430+
GRIN_VERTEX_PROPERTY vp1 = grin_get_vertex_property_by_id(g, vt, id);
431431
if (!grin_equal_vertex_property(g, vp, vp1)) {
432432
printf("vertex property not match by id\n");
433433
}
@@ -437,7 +437,7 @@ void test_property_vertex_table(int argc, char** argv) {
437437
#endif
438438

439439
#ifdef GRIN_WITH_VERTEX_PROPERTY_NAME
440-
const char* vp_name = grin_get_vertex_property_name(g, vp);
440+
const char* vp_name = grin_get_vertex_property_name(g, vt, vp);
441441
GRIN_VERTEX_PROPERTY vp2 =
442442
grin_get_vertex_property_by_name(g, vt, vp_name);
443443
if (!grin_equal_vertex_property(g, vp, vp2)) {
@@ -449,7 +449,7 @@ void test_property_vertex_table(int argc, char** argv) {
449449
GRIN_DATATYPE dt = grin_get_vertex_property_data_type(g, vp);
450450
const void* pv =
451451
grin_get_value_from_vertex_property_table(g, vpt, v, vp);
452-
if (grin_get_last_error_code() == GRIN_NO_ERROR) {
452+
if (grin_get_last_error_code() == NO_ERROR) {
453453
printf("(Correct) no error\n");
454454
} else {
455455
printf("(Wrong) error code: %d\n", grin_get_last_error_code());
@@ -479,7 +479,7 @@ void test_property_vertex_table(int argc, char** argv) {
479479

480480
#ifdef GRIN_TRAIT_NATURAL_ID_FOR_VERTEX_PROPERTY
481481
GRIN_VERTEX_PROPERTY vp3 =
482-
grin_get_vertex_property_from_id(g, vt, vpl_size);
482+
grin_get_vertex_property_by_id(g, vt, vpl_size);
483483
if (vp3 == GRIN_NULL_VERTEX_PROPERTY) {
484484
printf("(Correct) vertex property of id %zu does not exist\n", vpl_size);
485485
} else {
@@ -518,8 +518,8 @@ void test_property_vertex_table(int argc, char** argv) {
518518
for (size_t i = 0; i < vpl2_size; ++i) {
519519
GRIN_VERTEX_PROPERTY vp5 =
520520
grin_get_vertex_property_from_list(g, vpl2, i);
521-
GRIN_VERTEX_TYPE vt5 = grin_get_vertex_property_vertex_type(g, vp5);
522-
const char* vp5_name = grin_get_vertex_property_name(g, vp5);
521+
GRIN_VERTEX_TYPE vt5 = grin_get_vertex_type_from_property(g, vp5);
522+
const char* vp5_name = grin_get_vertex_property_name(g, vt5, vp5);
523523
const char* vt5_name = grin_get_vertex_type_name(g, vt5);
524524
printf("vertex type name: %s, vertex property name: %s\n", vt5_name,
525525
vp5_name);
@@ -588,18 +588,18 @@ void test_property_edge_table(int argc, char** argv) {
588588
GRIN_ROW row = grin_get_row_from_edge_property_table(g, ept, e, epl);
589589
for (size_t k = 0; k < epl_size; ++k) {
590590
GRIN_EDGE_PROPERTY ep = grin_get_edge_property_from_list(g, epl, k);
591-
GRIN_EDGE_TYPE et2 = grin_get_edge_property_edge_type(g, ep);
591+
GRIN_EDGE_TYPE et2 = grin_get_edge_type_from_property(g, ep);
592592
if (!grin_equal_edge_type(g, et, et2)) {
593593
printf("edge type does not match\n");
594594
}
595595
grin_destroy_edge_type(g, et2);
596596

597-
const char* ep_name = grin_get_edge_property_name(g, ep);
597+
const char* ep_name = grin_get_edge_property_name(g, et, ep);
598598
printf("edge property name: %s\n", ep_name);
599599

600600
#ifdef GRIN_TRAIT_NATURAL_ID_FOR_EDGE_PROPERTY
601601
unsigned int id = grin_get_edge_property_id(g, et, ep);
602-
GRIN_EDGE_PROPERTY ep1 = grin_get_edge_property_from_id(g, et, id);
602+
GRIN_EDGE_PROPERTY ep1 = grin_get_edge_property_by_id(g, et, id);
603603
if (!grin_equal_edge_property(g, ep, ep1)) {
604604
printf("edge property not match by id\n");
605605
}
@@ -644,11 +644,11 @@ void test_property_edge_table(int argc, char** argv) {
644644

645645
for (size_t j = 0; j < epl_size; ++j) {
646646
GRIN_EDGE_PROPERTY ep = grin_get_edge_property_from_list(g, epl, j);
647-
GRIN_EDGE_TYPE et1 = grin_get_edge_property_edge_type(g, ep);
647+
GRIN_EDGE_TYPE et1 = grin_get_edge_type_from_property(g, ep);
648648
if (!grin_equal_edge_type(g, et, et1)) {
649649
printf("edge type does not match\n");
650650
}
651-
const char* ep_name1 = grin_get_edge_property_name(g, ep);
651+
const char* ep_name1 = grin_get_edge_property_name(g, et, ep);
652652
const char* et_name = grin_get_edge_type_name(g, et);
653653
printf("edge property name: %s, edge property type name: %s\n", ep_name1,
654654
et_name);
@@ -658,7 +658,7 @@ void test_property_edge_table(int argc, char** argv) {
658658
grin_destroy_name(g, et_name);
659659

660660
#ifdef GRIN_WITH_EDGE_PROPERTY_NAME
661-
const char* ep_name = grin_get_edge_property_name(g, ep);
661+
const char* ep_name = grin_get_edge_property_name(g, et, ep);
662662
GRIN_EDGE_PROPERTY ep2 = grin_get_edge_property_by_name(g, et, ep_name);
663663
if (!grin_equal_edge_property(g, ep, ep2)) {
664664
printf("edge property not match by name\n");
@@ -669,7 +669,7 @@ void test_property_edge_table(int argc, char** argv) {
669669
grin_destroy_edge_property(g, ep);
670670
}
671671
#ifdef GRIN_TRAIT_NATURAL_ID_FOR_EDGE_PROPERTY
672-
GRIN_EDGE_PROPERTY ep3 = grin_get_edge_property_from_id(g, et, epl_size);
672+
GRIN_EDGE_PROPERTY ep3 = grin_get_edge_property_by_id(g, et, epl_size);
673673
if (ep3 == GRIN_NULL_EDGE_PROPERTY) {
674674
printf("(Correct) edge property of id %zu does not exist\n", epl_size);
675675
} else {
@@ -705,8 +705,8 @@ void test_property_edge_table(int argc, char** argv) {
705705
size_t epl2_size = grin_get_edge_property_list_size(g, epl2);
706706
for (size_t i = 0; i < epl2_size; ++i) {
707707
GRIN_EDGE_PROPERTY ep5 = grin_get_edge_property_from_list(g, epl2, i);
708-
GRIN_EDGE_TYPE et5 = grin_get_edge_property_edge_type(g, ep5);
709-
const char* ep5_name = grin_get_edge_property_name(g, ep5);
708+
GRIN_EDGE_TYPE et5 = grin_get_edge_type_from_property(g, ep5);
709+
const char* ep5_name = grin_get_edge_property_name(g, et5, ep5);
710710
const char* et5_name = grin_get_edge_type_name(g, et5);
711711
printf("edge type name: %s, edge property name: %s\n", et5_name,
712712
ep5_name);
@@ -751,7 +751,7 @@ void test_property_primary_key(int argc, char** argv) {
751751

752752
for (size_t j = 0; j < vpl_size; ++j) {
753753
GRIN_VERTEX_PROPERTY vp = grin_get_vertex_property_from_list(g, vpl, j);
754-
const char* vp_name = grin_get_vertex_property_name(g, vp);
754+
const char* vp_name = grin_get_vertex_property_name(g, vt, vp);
755755
printf("primary key name: %s\n", vp_name);
756756
grin_destroy_name(g, vp_name);
757757
grin_destroy_vertex_property(g, vp);
@@ -802,7 +802,7 @@ void test_error_code(int argc, char** argv) {
802802
GRIN_VERTEX v = get_one_vertex(g);
803803

804804
const void* value = grin_get_value_from_vertex_property_table(g, vpt, v, vp);
805-
if (grin_get_last_error_code() == GRIN_INVALID_VALUE) {
805+
if (grin_get_last_error_code() == INVALID_VALUE) {
806806
printf("(Correct) invalid value\n");
807807
} else {
808808
printf("(Wrong) error code: %d\n", grin_get_last_error_code());

modules/graph/grin/docs/README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,11 @@ The example demonstrates how to synchronize property values of vertices associat
3131

3232
```CPP
3333
void sync_property(GRIN_PARTITIONED_GRAPH partitioned_graph, GRIN_PARTITION partition, const char* edge_type_name, const char* vertex_property_name) {
34-
GRIN_GRAPH g = grin_get_local_graph_from_partition(partitioned_graph, partition); // get local graph of partition
34+
GRIN_GRAPH g = grin_get_local_graph_by_partition(partitioned_graph, partition); // get local graph of partition
3535

3636
GRIN_EDGE_TYPE etype = grin_get_edge_type_by_name(g, edge_type_name); // get edge type from name
37-
GRIN_VERTEX_TYPE_LIST src_vtypes = grin_get_src_types_from_edge_type(g, etype); // get related source vertex type list
38-
GRIN_VERTEX_TYPE_LIST dst_vtypes = grin_get_dst_types_from_edge_type(g, etype); // get related destination vertex type list
37+
GRIN_VERTEX_TYPE_LIST src_vtypes = grin_get_src_types_by_edge_type(g, etype); // get related source vertex type list
38+
GRIN_VERTEX_TYPE_LIST dst_vtypes = grin_get_dst_types_by_edge_type(g, etype); // get related destination vertex type list
3939

4040
size_t src_vtypes_num = grin_get_vertex_type_list_size(g, src_vtypes);
4141
size_t dst_vtypes_num = grin_get_vertex_type_list_size(g, dst_vtypes);
@@ -76,7 +76,7 @@ The example demonstrates how to synchronize property values of vertices associat
7676
GRIN_VERTEX u = grin_get_neighbor_from_adjacent_list(g, adj_list, k); // get the dst vertex u
7777
const void* value = grin_get_value_from_vertex_property_table(g, dst_vpt, u, dst_vp); // get the property value of "features" of u
7878

79-
GRIN_VERTEX_REF uref = grin_get_vertex_ref_for_vertex(g, u); // get the reference of u that can be recoginized by other partitions
79+
GRIN_VERTEX_REF uref = grin_get_vertex_ref_by_vertex(g, u); // get the reference of u that can be recoginized by other partitions
8080
GRIN_PARTITION u_master_partition = grin_get_master_partition_from_vertex_ref(g, uref); // get the master partition for u
8181

8282
send_value(u_master_partition, uref, dst_vp_dt, value); // the value must be casted to the correct type based on dst_vp_dt before sending
@@ -297,7 +297,7 @@ be recognized in partitions other than the current partition where the instance
297297
```CPP
298298
/* grin/partition/partition.h */
299299

300-
GRIN_VERTEX_REF grin_get_vertex_ref_for_vertex(GRIN_GRAPH, GRIN_VERTEX);
300+
GRIN_VERTEX_REF grin_get_vertex_ref_by_vertex(GRIN_GRAPH, GRIN_VERTEX);
301301

302302
const char* grin_serialize_vertex_ref(GRIN_GRAPH, GRIN_VERTEX_REF);
303303

@@ -308,7 +308,7 @@ be recognized in partitions other than the current partition where the instance
308308

309309
/* run.cc in machine 1 */
310310
{
311-
auto vref = grin_get_vertex_ref_for_vertex(g, v); // get v's vertex ref which can be recgonized in machine 2
311+
auto vref = grin_get_vertex_ref_by_vertex(g, v); // get v's vertex ref which can be recgonized in machine 2
312312

313313
const char* msg = grin_serialize_vertex_ref(g, vref); // serialize into a message
314314

modules/graph/grin/predefine.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,10 @@ typedef enum {
5555

5656
/// Enumerates the error codes of grin
5757
typedef enum {
58-
GRIN_NO_ERROR = 0, ///< success
59-
GRIN_UNKNOWN_ERROR = 1, ///< unknown error
60-
GRIN_INVALID_VALUE = 2, ///< invalid value
61-
GRIN_UNKNOWN_DATATYPE = 3, ///< unknown datatype
58+
NO_ERROR = 0, ///< success
59+
UNKNOWN_ERROR = 1, ///< unknown error
60+
INVALID_VALUE = 2, ///< invalid value
61+
UNKNOWN_DATATYPE = 3, ///< unknown datatype
6262
} GRIN_ERROR_CODE;
6363

6464
/* Section 1: Toplogy */

0 commit comments

Comments
 (0)