Skip to content

Commit 18b4abd

Browse files
committed
impl for value/original_id update
1 parent 86cba7c commit 18b4abd

File tree

12 files changed

+327
-597
lines changed

12 files changed

+327
-597
lines changed

modules/graph/grin/c/test.c

Lines changed: 39 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#include "../include/common/error.h"
33
#include "../include/index/label.h"
44
#include "../include/index/order.h"
5+
#include "../include/index/original_id.h"
56
#include "../include/partition/partition.h"
67
#include "../include/partition/reference.h"
78
#include "../include/partition/topology.h"
@@ -25,6 +26,9 @@ GRIN_GRAPH get_graph(int argc, char** argv) {
2526
GRIN_PARTITION partition =
2627
grin_get_partition_from_list(pg, local_partitions, 0);
2728
GRIN_GRAPH g = grin_get_local_graph_by_partition(pg, partition);
29+
grin_destroy_partition(pg, partition);
30+
grin_destroy_partition_list(pg, local_partitions);
31+
grin_destroy_partitioned_graph(pg);
2832
#else
2933
GRIN_GRAPH g = grin_get_graph_from_storage(argc - 1, &(argv[1]));
3034
#endif
@@ -99,7 +103,7 @@ void test_property_type(int argc, char** argv) {
99103
const char* vt_name = grin_get_vertex_type_name(g, vt);
100104
printf("vertex type name: %s\n", vt_name);
101105
GRIN_VERTEX_TYPE vt0 = grin_get_vertex_type_by_name(g, vt_name);
102-
grin_destroy_name(g, vt_name);
106+
//grin_destroy_name(g, vt_name);
103107
if (!grin_equal_vertex_type(g, vt, vt0)) {
104108
printf("vertex type name not match\n");
105109
}
@@ -132,7 +136,7 @@ void test_property_type(int argc, char** argv) {
132136
} else {
133137
const char* vt2_name = grin_get_vertex_type_name(g, vt2);
134138
printf("vertex type name: %s\n", vt2_name);
135-
grin_destroy_name(g, vt2_name);
139+
//grin_destroy_name(g, vt2_name);
136140
}
137141
#else
138142
GRIN_VERTEX_TYPE vt2 = get_one_vertex_type(g);
@@ -161,7 +165,7 @@ void test_property_type(int argc, char** argv) {
161165
const char* et_name = grin_get_edge_type_name(g, et);
162166
printf("edge type name: %s\n", et_name);
163167
GRIN_EDGE_TYPE et0 = grin_get_edge_type_by_name(g, et_name);
164-
grin_destroy_name(g, et_name);
168+
//grin_destroy_name(g, et_name);
165169
if (!grin_equal_edge_type(g, et, et0)) {
166170
printf("edge type name not match\n");
167171
}
@@ -195,9 +199,9 @@ void test_property_type(int argc, char** argv) {
195199
const char* dst_vt_name = grin_get_vertex_type_name(g, dst_vt);
196200
const char* et_name = grin_get_edge_type_name(g, et);
197201
printf("edge type name: %s-%s-%s\n", src_vt_name, et_name, dst_vt_name);
198-
grin_destroy_name(g, src_vt_name);
199-
grin_destroy_name(g, dst_vt_name);
200-
grin_destroy_name(g, et_name);
202+
//grin_destroy_name(g, src_vt_name);
203+
//grin_destroy_name(g, dst_vt_name);
204+
//grin_destroy_name(g, et_name);
201205
grin_destroy_vertex_type(g, src_vt);
202206
grin_destroy_vertex_type(g, dst_vt);
203207
}
@@ -221,7 +225,7 @@ void test_property_type(int argc, char** argv) {
221225
} else {
222226
const char* et2_name = grin_get_edge_type_name(g, et2);
223227
printf("edge type name: %s\n", et2_name);
224-
grin_destroy_name(g, et2_name);
228+
//grin_destroy_name(g, et2_name);
225229
}
226230
#else
227231
GRIN_EDGE_TYPE et2 = get_one_edge_type(g);
@@ -297,17 +301,17 @@ void test_property_topology(int argc, char** argv) {
297301
grin_destroy_vertex_list(g, vl);
298302
#endif
299303

300-
#ifdef GRIN_ASSUME_BY_TYPE_VERTEX_ORIGINAL_ID
301-
GRIN_DATATYPE dt = grin_get_vertex_original_id_data_type(g);
304+
#ifdef GRIN_ENABLE_VERTEX_ORIGINAL_ID_OF_INT64
305+
GRIN_DATATYPE dt = grin_get_vertex_original_id_datatype(g);
302306
if (dt == Int64) {
303307
long long int v0id = 4;
304-
GRIN_VERTEX v0 = grin_get_vertex_by_original_id_by_type(g, vt, dt, &v0id);
308+
GRIN_VERTEX v0 = grin_get_vertex_by_original_id_of_int64(g, v0id);
305309
if (v0 == GRIN_NULL_VERTEX) {
306310
printf("(Wrong) vertex of id %lld can not be found\n", v0id);
307311
} else {
308312
printf("vertex of original id %lld found\n", v0id);
309-
const void* oid0 = grin_get_vertex_original_id_value(g, v0);
310-
printf("get vertex original id: %lld\n", *((long long int*) oid0));
313+
long long int oid0 = grin_get_vertex_original_id_of_int64(g, v0);
314+
printf("get vertex original id: %lld\n", oid0);
311315
}
312316
grin_destroy_vertex(g, v0);
313317
} else {
@@ -362,8 +366,8 @@ void test_property_topology(int argc, char** argv) {
362366
grin_destroy_edge_list(g, el);
363367
#endif
364368

365-
grin_destroy_name(g, vt_name);
366-
grin_destroy_name(g, et_name);
369+
//grin_destroy_name(g, vt_name);
370+
//grin_destroy_name(g, et_name);
367371
grin_destroy_vertex_type(g, vt);
368372
grin_destroy_edge_type(g, et);
369373
grin_destroy_graph(g);
@@ -438,7 +442,7 @@ void test_property_vertex_table(int argc, char** argv) {
438442
#else
439443
const char* vp_name = "unknown";
440444
#endif
441-
GRIN_DATATYPE dt = grin_get_vertex_property_data_type(g, vp);
445+
GRIN_DATATYPE dt = grin_get_vertex_property_datatype(g, vp);
442446
const void* pv =
443447
grin_get_value_from_vertex_property_table(g, vpt, v, vp);
444448
if (grin_get_last_error_code() == NO_ERROR) {
@@ -454,8 +458,8 @@ void test_property_vertex_table(int argc, char** argv) {
454458
printf("vp_id %u v%zu %s value: %s %s\n", id, i, vp_name, (char*) pv,
455459
(char*) rv);
456460
}
457-
grin_destroy_value(g, dt, pv);
458-
grin_destroy_value(g, dt, rv);
461+
//grin_destroy_value(g, dt, pv);
462+
//grin_destroy_value(g, dt, rv);
459463
grin_destroy_vertex_property(g, vp);
460464
}
461465
grin_destroy_row(g, row);
@@ -517,8 +521,8 @@ void test_property_vertex_table(int argc, char** argv) {
517521
vp5_name);
518522
grin_destroy_vertex_property(g, vp5);
519523
grin_destroy_vertex_type(g, vt5);
520-
grin_destroy_name(g, vt5_name);
521-
grin_destroy_name(g, vp5_name);
524+
//grin_destroy_name(g, vt5_name);
525+
//grin_destroy_name(g, vp5_name);
522526
}
523527
grin_destroy_vertex_property_list(g, vpl2);
524528
}
@@ -599,7 +603,7 @@ void test_property_edge_table(int argc, char** argv) {
599603
#else
600604
unsigned int id = ~0;
601605
#endif
602-
GRIN_DATATYPE dt = grin_get_edge_property_data_type(g, ep);
606+
GRIN_DATATYPE dt = grin_get_edge_property_datatype(g, ep);
603607
const void* pv = grin_get_value_from_edge_property_table(g, ept, e, ep);
604608
const void* rv = grin_get_value_from_row(g, row, dt, k);
605609
if (dt == Int64) {
@@ -613,9 +617,9 @@ void test_property_edge_table(int argc, char** argv) {
613617
*((double*) pv), *((double*) rv));
614618
}
615619
grin_destroy_edge_property(g, ep);
616-
grin_destroy_name(g, ep_name);
617-
grin_destroy_value(g, dt, pv);
618-
grin_destroy_value(g, dt, rv);
620+
//grin_destroy_name(g, ep_name);
621+
//grin_destroy_value(g, dt, pv);
622+
//grin_destroy_value(g, dt, rv);
619623
}
620624

621625
grin_destroy_row(g, row);
@@ -646,8 +650,8 @@ void test_property_edge_table(int argc, char** argv) {
646650
et_name);
647651

648652
grin_destroy_edge_type(g, et1);
649-
grin_destroy_name(g, ep_name1);
650-
grin_destroy_name(g, et_name);
653+
//grin_destroy_name(g, ep_name1);
654+
//grin_destroy_name(g, et_name);
651655

652656
#ifdef GRIN_WITH_EDGE_PROPERTY_NAME
653657
const char* ep_name = grin_get_edge_property_name(g, et, ep);
@@ -704,8 +708,8 @@ void test_property_edge_table(int argc, char** argv) {
704708
ep5_name);
705709
grin_destroy_edge_property(g, ep5);
706710
grin_destroy_edge_type(g, et5);
707-
grin_destroy_name(g, et5_name);
708-
grin_destroy_name(g, ep5_name);
711+
//grin_destroy_name(g, et5_name);
712+
//grin_destroy_name(g, ep5_name);
709713
}
710714
grin_destroy_edge_property_list(g, epl2);
711715
}
@@ -735,7 +739,7 @@ void test_property_primary_key(int argc, char** argv) {
735739
GRIN_VERTEX_TYPE vt = grin_get_vertex_type_from_list(g, vtl, i);
736740
const char* vt_name = grin_get_vertex_type_name(g, vt);
737741
printf("vertex type name: %s\n", vt_name);
738-
grin_destroy_name(g, vt_name);
742+
//grin_destroy_name(g, vt_name);
739743

740744
GRIN_VERTEX_PROPERTY_LIST vpl = grin_get_primary_keys_by_vertex_type(g, vt);
741745
size_t vpl_size = grin_get_vertex_property_list_size(g, vpl);
@@ -745,29 +749,25 @@ void test_property_primary_key(int argc, char** argv) {
745749
GRIN_VERTEX_PROPERTY vp = grin_get_vertex_property_from_list(g, vpl, j);
746750
const char* vp_name = grin_get_vertex_property_name(g, vt, vp);
747751
printf("primary key name: %s\n", vp_name);
748-
grin_destroy_name(g, vp_name);
752+
//grin_destroy_name(g, vp_name);
749753
grin_destroy_vertex_property(g, vp);
750754
}
751755

752756
GRIN_VERTEX_PROPERTY vp = grin_get_vertex_property_from_list(g, vpl, 0);
753-
GRIN_DATATYPE dt = grin_get_vertex_property_data_type(g, vp);
757+
GRIN_DATATYPE dt = grin_get_vertex_property_datatype(g, vp);
754758

755759
for (size_t j = 1; j <= 6; ++j) {
756760
GRIN_ROW r = grin_create_row(g);
757-
grin_insert_value_to_row(g, r, dt, (void*) (&j));
761+
if (dt == Int64) {
762+
grin_insert_int64_to_row(g, r, j);
763+
} else {
764+
printf("(Wrong) the primary key type is not int64");
765+
}
758766
GRIN_VERTEX v = grin_get_vertex_by_primary_keys(g, vt, r);
759767
if (id_type[j] == i) {
760768
if (v == GRIN_NULL_VERTEX) {
761769
printf("(Wrong) vertex of primary keys %zu does not exist\n", j);
762770
} else {
763-
GRIN_DATATYPE dt0 = grin_get_vertex_original_id_data_type(g);
764-
const void* oid0 = grin_get_vertex_original_id_value(g, v);
765-
if (dt0 == Int64) {
766-
printf("(Correct) vertex of primary keys %zu exists %lld\n", j,
767-
*((long long int*) oid0));
768-
} else {
769-
printf("(Wrong) unmatch original id type\n");
770-
}
771771
grin_destroy_vertex(g, v);
772772
}
773773
} else {

modules/graph/grin/c/test.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@
55
# 4. in build folder, run: bin/vineyard-graph-loader --socket tmp.sock --config modern_graph/config.json
66

77
rm -rf ./test
8-
gcc test.c -I. -L/home/graphscope/gie-grin/v6d/build/shared-lib/ -lvineyard_grin -lvineyard_graph -lvineyard_basic -o test
9-
./test /home/graphscope/gie-grin/v6d/build/tmp.sock 134785075056209698
8+
gcc test.c -I. -L/workspaces/v6d/build/shared-lib/ -lvineyard_grin -lvineyard_graph -lvineyard_basic -o test
9+
./test /workspaces/v6d/build/tmp.sock 4510456268948890

modules/graph/grin/predefine.h

Lines changed: 31 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -83,13 +83,6 @@ typedef enum {
8383
*/
8484
#define GRIN_ASSUME_HAS_MULTI_EDGE_GRAPH
8585

86-
/** @ingroup TopologyMacros
87-
* @brief There is original ID for a vertex.
88-
* This facilitates queries starting from a specific vertex,
89-
* since one can get the vertex handler directly using its original ID.
90-
*/
91-
#define GRIN_WITH_VERTEX_ORIGINAL_ID
92-
9386
/** @ingroup TopologyMacros
9487
* @brief There is data on vertex. E.g., the PageRank value of a vertex.
9588
*/
@@ -161,7 +154,6 @@ typedef enum {
161154
#undef GRIN_ASSUME_HAS_DIRECTED_GRAPH
162155
#undef GRIN_ASSUME_HAS_UNDIRECTED_GRAPH
163156
#undef GRIN_ASSUME_HAS_MULTI_EDGE_GRAPH
164-
#undef GRIN_WITH_VERTEX_ORIGINAL_ID
165157
#undef GRIN_WITH_VERTEX_DATA
166158
#undef GRIN_WITH_EDGE_DATA
167159
#undef GRIN_ENABLE_VERTEX_LIST
@@ -179,7 +171,6 @@ typedef enum {
179171
#define GRIN_ASSUME_HAS_DIRECTED_GRAPH
180172
#define GRIN_ASSUME_HAS_UNDIRECTED_GRAPH
181173
#define GRIN_ASSUME_HAS_MULTI_EDGE_GRAPH
182-
#define GRIN_WITH_VERTEX_ORIGINAL_ID
183174
#define GRIN_ENABLE_VERTEX_LIST
184175
#define GRIN_ENABLE_VERTEX_LIST_ARRAY
185176
#define GRIN_ENABLE_VERTEX_LIST_ITERATOR
@@ -463,6 +454,11 @@ typedef enum {
463454
*/
464455
#define GRIN_ENABLE_ROW
465456

457+
/** @ingroup PropertyMacros
458+
* @brief Enable the pure data structure Row, which is used in primary keys and tables.
459+
*/
460+
#define GRIN_TRAIT_CONST_VALUE_PTR
461+
466462
/** @ingroup PropertyMacros
467463
* @brief There are properties bound to vertices. When vertices are typed, vertex
468464
* properties are bound to vertex types, according to the definition of vertex type.
@@ -502,7 +498,7 @@ typedef enum {
502498
*
503499
* With primary keys, one can get the vertex from the graph or a certain type
504500
* by providing the values of the primary keys. The macro is unset if GRIN_WITH_VERTEX_PROPERTY
505-
* is NOT defined, in which case, one can use GRIN_WITH_VERTEX_ORIGINAL_ID when vertices have
501+
* is NOT defined, in which case, one can use ORIGINAL_ID when vertices have
506502
* no properties.
507503
*/
508504
#define GRIN_ENABLE_VERTEX_PRIMARY_KEYS
@@ -514,12 +510,6 @@ typedef enum {
514510
*/
515511
#define GRIN_TRAIT_NATURAL_ID_FOR_VERTEX_PROPERTY
516512

517-
/** @ingroup PropertyMacros
518-
* @brief Assume the original id is ONLY unique under each vertex type. This means
519-
* to get a vertex from the original id, the caller must also provide the vertex type.
520-
*/
521-
#define GRIN_ASSUME_BY_TYPE_VERTEX_ORIGINAL_ID
522-
523513

524514
/** @ingroup PropertyMacros
525515
* @brief There are properties bound to edges. When edges are typed, edge
@@ -560,8 +550,7 @@ typedef enum {
560550
*
561551
* With primary keys, one can get the edge from the graph or a certain type
562552
* by providing the values of the primary keys. The macro is unset if GRIN_WITH_EDGE_PROPERTY
563-
* is NOT defined, in which case, one can use GRIN_WITH_EDGE_ORIGINAL_ID when edges have
564-
* no properties.
553+
* is NOT defined.
565554
*/
566555
#define GRIN_ENABLE_EDGE_PRIMARY_KEYS
567556

@@ -671,14 +660,14 @@ typedef enum {
671660
#ifndef GRIN_DOXYGEN_SKIP
672661
// GRIN_DEFAULT_DISABLE
673662
#undef GRIN_ENABLE_ROW
663+
#undef GRIN_TRAIT_CONST_VALUE_PTR
674664
#undef GRIN_WITH_VERTEX_PROPERTY
675665
#undef GRIN_WITH_VERTEX_PROPERTY_NAME
676666
#undef GRIN_WITH_VERTEX_TYPE_NAME
677667
#undef GRIN_TRAIT_NATURAL_ID_FOR_VERTEX_TYPE
678668
#undef GRIN_ENABLE_VERTEX_PROPERTY_TABLE
679669
#undef GRIN_ENABLE_VERTEX_PRIMARY_KEYS
680670
#undef GRIN_TRAIT_NATURAL_ID_FOR_VERTEX_PROPERTY
681-
#undef GRIN_ASSUME_BY_TYPE_VERTEX_ORIGINAL_ID
682671
#undef GRIN_WITH_EDGE_PROPERTY
683672
#undef GRIN_WITH_EDGE_PROPERTY_NAME
684673
#undef GRIN_WITH_EDGE_TYPE_NAME
@@ -703,14 +692,14 @@ typedef enum {
703692

704693
// GRIN_STORAGE_ENABLE
705694
#define GRIN_ENABLE_ROW
695+
#define GRIN_TRAIT_CONST_VALUE_PTR
706696
#define GRIN_WITH_VERTEX_PROPERTY
707697
#define GRIN_WITH_VERTEX_PROPERTY_NAME
708698
#define GRIN_WITH_VERTEX_TYPE_NAME
709699
#define GRIN_TRAIT_NATURAL_ID_FOR_VERTEX_TYPE
710700
#define GRIN_ENABLE_VERTEX_PROPERTY_TABLE
711701
#define GRIN_ENABLE_VERTEX_PRIMARY_KEYS
712702
#define GRIN_TRAIT_NATURAL_ID_FOR_VERTEX_PROPERTY
713-
#define GRIN_ASSUME_BY_TYPE_VERTEX_ORIGINAL_ID
714703
#define GRIN_WITH_EDGE_PROPERTY
715704
#define GRIN_WITH_EDGE_PROPERTY_NAME
716705
#define GRIN_WITH_EDGE_TYPE_NAME
@@ -790,15 +779,37 @@ typedef enum {
790779
#define GRIN_ASSUME_ALL_VERTEX_LIST_SORTED
791780
///@}
792781

782+
/** @name IndexOIDMacros
783+
* @brief Macros for label features
784+
*/
785+
///@{
786+
/** @ingroup IndexOIDMacros
787+
* @brief There is original ID of type int64 for each vertex
788+
* This facilitates queries starting from a specific vertex,
789+
* since one can get the vertex handler directly using its original ID.
790+
*/
791+
#define GRIN_ENABLE_VERTEX_ORIGINAL_ID_OF_INT64
792+
793+
/** @ingroup IndexOIDMacros
794+
* @brief There is original ID of type string for each vertex
795+
* This facilitates queries starting from a specific vertex,
796+
* since one can get the vertex handler directly using its original ID.
797+
*/
798+
#define GRIN_ENABLE_VERTEX_ORIGINAL_ID_OF_STRING
799+
///@}
800+
793801
#ifndef GRIN_DOXYGEN_SKIP
794802
// GRIN_DEFAULT_DISABLE
795803
#undef GRIN_WITH_VERTEX_LABEL
796804
#undef GRIN_WITH_EDGE_LABEL
797805
#undef GRIN_ASSUME_ALL_VERTEX_LIST_SORTED
806+
#undef GRIN_ENABLE_VERTEX_ORIGINAL_ID_OF_INT64
807+
#undef GRIN_ENABLE_VERTEX_ORIGINAL_ID_OF_STRING
798808
// GRIN_END
799809

800810
// GRIN_STORAGE_ENABLE
801811
#define GRIN_ASSUME_ALL_VERTEX_LIST_SORTED
812+
#define GRIN_ENABLE_VERTEX_ORIGINAL_ID_OF_INT64
802813
// GRIN_END
803814

804815
// GRIN_FEATURE_DEPENDENCY
@@ -851,10 +862,6 @@ typedef void* GRIN_GRAPH;
851862
typedef void* GRIN_VERTEX;
852863
typedef void* GRIN_EDGE;
853864

854-
#ifdef GRIN_WITH_VERTEX_ORIGINAL_ID
855-
typedef void* GRIN_VERTEX_ORIGINAL_ID;
856-
#endif
857-
858865
#ifdef GRIN_WITH_VERTEX_DATA
859866
typedef void* GRIN_VERTEX_DATA;
860867
#endif

0 commit comments

Comments
 (0)