1010#include "../include/property/primarykey.h"
1111#include "../include/property/property.h"
1212#include "../include/property/propertylist.h"
13- #include "../include/property/propertytable .h"
13+ #include "../include/property/row .h"
1414#include "../include/property/topology.h"
1515#include "../include/property/type.h"
1616#include "../include/topology/adjacentlist.h"
@@ -393,20 +393,17 @@ void test_property_topology(int argc, char** argv) {
393393 grin_destroy_graph (g );
394394}
395395
396- void test_property_vertex_table (int argc , char * * argv ) {
397- printf ("+++++++++++++++++++++ Test property/table +++++++++++++++++++++ \n" );
396+ void test_property_vertex_property_value (int argc , char * * argv ) {
397+ printf ("------------ Test Vertex property value ------------ \n" );
398398 GRIN_GRAPH g = get_graph (argc , argv );
399399
400- printf ("------------ Vertex property table ------------\n" );
401400 GRIN_VERTEX_TYPE_LIST vtl = grin_get_vertex_type_list (g );
402401 size_t vtl_size = grin_get_vertex_type_list_size (g , vtl );
403402 for (size_t vt_index = 0 ; vt_index < vtl_size ; ++ vt_index ) {
404403 GRIN_VERTEX_TYPE vt = grin_get_vertex_type_from_list (g , vtl , vt_index );
405404
406405 GRIN_VERTEX_PROPERTY_LIST vpl =
407406 grin_get_vertex_property_list_by_type (g , vt );
408- GRIN_VERTEX_PROPERTY_TABLE vpt =
409- grin_get_vertex_property_table_by_type (g , vt );
410407
411408#ifdef GRIN_TRAIT_SELECT_MASTER_FOR_VERTEX_LIST
412409 GRIN_VERTEX_LIST all_vl = grin_get_vertex_list (g );
@@ -433,7 +430,7 @@ void test_property_vertex_table(int argc, char** argv) {
433430 while (grin_is_vertex_list_end (g , vli ) == 0 ) {
434431 GRIN_VERTEX v = grin_get_vertex_from_iter (g , vli );
435432#endif
436- GRIN_ROW row = grin_get_row_from_vertex_property_table (g , vpt , v , vpl );
433+ GRIN_ROW row = grin_get_vertex_row (g , v );
437434 for (size_t j = 0 ; j < vpl_size ; ++ j ) {
438435 GRIN_VERTEX_PROPERTY vp = grin_get_vertex_property_from_list (g , vpl , j );
439436 GRIN_VERTEX_TYPE vt1 = grin_get_vertex_type_from_property (g , vp );
@@ -465,7 +462,7 @@ void test_property_vertex_table(int argc, char** argv) {
465462 GRIN_DATATYPE dt = grin_get_vertex_property_datatype (g , vp );
466463#ifdef GRIN_TRAIT_CONST_VALUE_PTR
467464 const void * pv =
468- grin_get_value_from_vertex_property_table ( g , vpt , v , vp );
465+ grin_get_vertex_property_value ( g , v , vp );
469466 if (grin_get_last_error_code () == NO_ERROR ) {
470467 printf ("(Correct) no error\n" );
471468 } else {
@@ -487,7 +484,7 @@ void test_property_vertex_table(int argc, char** argv) {
487484#else
488485 if (dt == Int64 ) {
489486 long long int pv =
490- grin_get_int64_from_vertex_property_table ( g , vpt , v , vp );
487+ grin_get_vertex_property_value_of_int64 ( g , v , vp );
491488 if (grin_get_last_error_code () == NO_ERROR ) {
492489 printf ("(Correct) no error\n" );
493490 } else {
@@ -497,7 +494,7 @@ void test_property_vertex_table(int argc, char** argv) {
497494 printf ("vp_id %u v%zu %s value: %lld %lld\n" , id , i , vp_name , pv , rv );
498495 } else if (dt == String ) {
499496 const char * pv =
500- grin_get_string_from_vertex_property_table ( g , vpt , v , vp );
497+ grin_get_vertex_property_value_of_string ( g , v , vp );
501498 if (grin_get_last_error_code () == NO_ERROR ) {
502499 printf ("(Correct) no error\n" );
503500 } else {
@@ -579,14 +576,13 @@ void test_property_vertex_table(int argc, char** argv) {
579576 grin_destroy_vertex_list (g , typed_vl );
580577 grin_destroy_vertex_list (g , vl );
581578 grin_destroy_vertex_property_list (g , vpl );
582- grin_destroy_vertex_property_table (g , vpt );
583579 }
584580 grin_destroy_vertex_type_list (g , vtl );
585581 grin_destroy_graph (g );
586582}
587583
588- void test_property_edge_table (int argc , char * * argv ) {
589- printf ("------------ Edge property table ------------\n" );
584+ void test_property_edge_property_value (int argc , char * * argv ) {
585+ printf ("------------ Test Edge property value ------------\n" );
590586 GRIN_GRAPH g = get_graph (argc , argv );
591587 // edge
592588 GRIN_VERTEX v = get_vertex_marco (g );
@@ -602,7 +598,6 @@ void test_property_edge_table(int argc, char** argv) {
602598
603599 for (size_t i = 0 ; i < etl_size ; ++ i ) {
604600 GRIN_EDGE_TYPE et = grin_get_edge_type_from_list (g , etl , i );
605- GRIN_EDGE_PROPERTY_TABLE ept = grin_get_edge_property_table_by_type (g , et );
606601 GRIN_EDGE_PROPERTY_LIST epl = grin_get_edge_property_list_by_type (g , et );
607602 size_t epl_size = grin_get_edge_property_list_size (g , epl );
608603 printf ("edge property list size: %zu\n" , epl_size );
@@ -629,7 +624,7 @@ void test_property_edge_table(int argc, char** argv) {
629624 printf ("edge type does not match\n" );
630625 }
631626
632- GRIN_ROW row = grin_get_row_from_edge_property_table (g , ept , e , epl );
627+ GRIN_ROW row = grin_get_edge_row (g , e );
633628 for (size_t k = 0 ; k < epl_size ; ++ k ) {
634629 GRIN_EDGE_PROPERTY ep = grin_get_edge_property_from_list (g , epl , k );
635630 GRIN_EDGE_TYPE et2 = grin_get_edge_type_from_property (g , ep );
@@ -653,8 +648,9 @@ void test_property_edge_table(int argc, char** argv) {
653648#endif
654649 GRIN_DATATYPE dt = grin_get_edge_property_datatype (g , ep );
655650#ifdef GRIN_TRAIT_CONST_VALUE_PTR
656- const void * pv = grin_get_value_from_edge_property_table ( g , ept , e , ep );
651+ const void * pv = grin_get_edge_property_value ( g , e , ep );
657652 const void * rv = grin_get_value_from_row (g , row , dt , k );
653+
658654 if (dt == Int64 ) {
659655 printf ("ep_id %u e%zu %s value: %ld %ld\n" , id , j , ep_name ,
660656 * ((long int * ) pv ), * ((long int * ) rv ));
@@ -672,22 +668,25 @@ void test_property_edge_table(int argc, char** argv) {
672668#else
673669 if (dt == Int64 ) {
674670 long long int pv =
675- grin_get_int64_from_edge_property_table (g , ept , e , ep );
671+ grin_get_edge_property_value_of_int64 (g , ept , e , ep );
676672 long long int rv = grin_get_int64_from_row (g , row , k );
677673 printf ("ep_id %u e%zu %s value: %lld %lld\n" , id , j , ep_name , pv , rv );
678674 } else if (dt == String ) {
679675 const char * pv =
680- grin_get_string_from_edge_property_table (g , ept , e , ep );
676+ grin_get_edge_property_value_of_string (g , ept , e , ep );
681677 const char * rv = grin_get_string_from_row (g , row , k );
682678 printf ("ep_id %u e%zu %s value: %s %s\n" , id , j , ep_name , pv , rv );
683679 grin_destroy_string_value (g , pv );
684680 grin_destroy_string_value (g , rv );
685681 } else if (dt == Double ) {
686- double pv = grin_get_double_from_edge_property_table (g , ept , e , ep );
682+ double pv = grin_get_edge_property_value_of_double (g , ept , e , ep );
687683 double rv = grin_get_double_from_row (g , row , k );
688684 printf ("ep_id %u e%zu %s value: %f %f\n" , id , j , ep_name , pv , rv );
689685 }
690686#endif
687+ // grin_destroy_name(g, ep_name);
688+ // grin_destroy_value(g, dt, pv);
689+ // grin_destroy_value(g, dt, rv);
691690 }
692691
693692 grin_destroy_row (g , row );
@@ -792,6 +791,7 @@ void test_property_edge_table(int argc, char** argv) {
792791 grin_destroy_graph (g );
793792}
794793
794+ #ifdef GRIN_ENABLE_VERTEX_PRIMARY_KEYS
795795void test_property_primary_key (int argc , char * * argv ) {
796796 printf (
797797 "+++++++++++++++++++++ Test property/primary key "
@@ -854,6 +854,7 @@ void test_property_primary_key(int argc, char** argv) {
854854 grin_destroy_vertex_type (g , vt );
855855 }
856856}
857+ #endif
857858
858859void test_error_code (int argc , char * * argv ) {
859860 printf ("+++++++++++++++++++++ Test error code +++++++++++++++++++++\n" );
@@ -862,14 +863,12 @@ void test_error_code(int argc, char** argv) {
862863 GRIN_VERTEX_TYPE vt1 = grin_get_vertex_type_by_name (g , "person" );
863864 GRIN_VERTEX_TYPE vt2 = grin_get_vertex_type_by_name (g , "software" );
864865 GRIN_VERTEX_PROPERTY vp = grin_get_vertex_property_by_name (g , vt2 , "lang" );
865- GRIN_VERTEX_PROPERTY_TABLE vpt =
866- grin_get_vertex_property_table_by_type (g , vt1 );
867866 GRIN_VERTEX v = get_one_vertex (g );
868867
869868#ifdef GRIN_TRAIT_CONST_VALUE_PTR
870- const void * value = grin_get_value_from_vertex_property_table ( g , vpt , v , vp );
869+ const void * value = grin_get_vertex_property_value ( g , v , vp );
871870#else
872- const char * value = grin_get_string_from_vertex_property_table ( g , vpt , v , vp );
871+ const char * value = grin_get_vertex_property_value_of_string ( g , v , vp );
873872#endif
874873 if (grin_get_last_error_code () == INVALID_VALUE ) {
875874 printf ("(Correct) invalid value\n" );
@@ -881,9 +880,11 @@ void test_error_code(int argc, char** argv) {
881880void test_property (int argc , char * * argv ) {
882881 test_property_type (argc , argv );
883882 test_property_topology (argc , argv );
884- test_property_vertex_table (argc , argv );
885- test_property_edge_table (argc , argv );
883+ test_property_vertex_property_value (argc , argv );
884+ test_property_edge_property_value (argc , argv );
885+ #ifdef GRIN_ENABLE_VERTEX_PRIMARY_KEYS
886886 test_property_primary_key (argc , argv );
887+ #endif
887888 test_error_code (argc , argv );
888889}
889890
@@ -893,12 +894,18 @@ void test_partition_reference(int argc, char** argv) {
893894 GRIN_GRAPH g = get_graph (argc , argv );
894895 GRIN_PARTITION p0 = get_partition (argc , argv );
895896
897+ #ifdef GRIN_TRAIT_SELECT_MASTER_FOR_VERTEX_LIST
896898 GRIN_VERTEX_LIST vlist = grin_get_vertex_list (g );
897- GRIN_VERTEX_LIST_ITERATOR vli = grin_get_vertex_list_begin (g , vlist );
898899 GRIN_VERTEX_LIST mvlist = grin_select_master_for_vertex_list (g , vlist );
900+ GRIN_VERTEX_LIST_ITERATOR vli = grin_get_vertex_list_begin (g , mvlist );
899901 grin_destroy_vertex_list (g , vlist );
902+ #else
903+ GRIN_VERTEX_LIST mvlist = grin_get_vertex_list (g );
904+ GRIN_VERTEX_LIST_ITERATOR vli = grin_get_vertex_list_begin (g , mvlist );
905+ #endif
900906
901907 size_t cnt = 0 ;
908+ size_t mcnt = 0 ;
902909 while (!grin_is_vertex_list_end (g , vli )) {
903910 cnt ++ ;
904911 GRIN_VERTEX v = grin_get_vertex_from_iter (g , vli );
@@ -916,13 +923,19 @@ void test_partition_reference(int argc, char** argv) {
916923 printf ("vertex not match\n" );
917924 }
918925
919- if (grin_is_master_vertex (g , v ) && !grin_is_mirror_vertex (g , v )) {
926+ if (grin_is_master_vertex (g , v )) {
927+ mcnt ++ ;
920928 GRIN_PARTITION p = grin_get_master_partition_from_vertex_ref (g , vref );
921929 if (!grin_equal_partition (g , p , p0 )) {
922- printf ("partition not match\n" );
930+ printf ("(Wrong) partition not match\n" );
931+ }
932+ } else if (grin_is_mirror_vertex (g , v )) {
933+ GRIN_PARTITION p = grin_get_master_partition_from_vertex_ref (g , vref );
934+ if (grin_equal_partition (g , p , p0 )) {
935+ printf ("(Wrong) partition match\n" );
923936 }
924937 } else {
925- printf ("(Wrong) test only has one partition \n" );
938+ printf ("(Wrong) vertex other than master or mirror \n" );
926939 }
927940
928941 grin_destroy_vertex_ref (g , vref );
@@ -933,8 +946,10 @@ void test_partition_reference(int argc, char** argv) {
933946
934947#ifdef GRIN_ENABLE_VERTEX_LIST_ARRAY
935948 size_t mvlist_size = grin_get_vertex_list_size (g , mvlist );
936- if (mvlist_size != cnt ) {
949+ if (mvlist_size != mcnt ) {
937950 printf ("(Wrong) master vertex list size not match\n" );
951+ } else {
952+ printf ("Master vertex number: %zu\n" , mcnt );
938953 }
939954#endif
940955
@@ -959,7 +974,6 @@ void test_topology_structure(int argc, char** argv) {
959974
960975void test_topology_adjacent_list (int argc , char * * argv , GRIN_DIRECTION dir ) {
961976 printf ("+++++++++++++++++++++ Test topology/adjacent_list +++++++++++++++++++++\n" );
962-
963977 GRIN_GRAPH g = get_graph (argc , argv );
964978
965979 GRIN_VERTEX_LIST vl = grin_get_vertex_list (g );
@@ -971,6 +985,13 @@ void test_topology_adjacent_list(int argc, char** argv, GRIN_DIRECTION dir) {
971985
972986 while (!grin_is_vertex_list_end (g , vli )) {
973987 GRIN_VERTEX v = grin_get_vertex_from_iter (g , vli );
988+ #ifdef GRIN_ENABLE_GRAPH_PARTITION
989+ if (!grin_is_master_vertex (g , v )) {
990+ grin_destroy_vertex (g , v );
991+ grin_get_next_vertex_list_iter (g , vli );
992+ continue ;
993+ }
994+ #endif
974995 GRIN_ADJACENT_LIST al = grin_get_adjacent_list (g , dir , v );
975996 for (size_t i = 0 ; i <= etl_size ; ++ i ) {
976997 GRIN_ADJACENT_LIST al1 = al ;
0 commit comments