@@ -803,3 +803,36 @@ def PbDataType2InfoType(str):
803
803
with open (graph_info_path , "w" ) as f :
804
804
yaml .dump (graph_info , f , Dumper = Dumper , default_flow_style = False )
805
805
return graph_info_path
806
+
807
+ def get_oid_type_from_graph_info (path ):
808
+ if "file://" in path :
809
+ path = path .replace ("file://" , "" )
810
+ with open (path , "r" ) as f :
811
+ graph_info = yaml .safe_load (f )
812
+ if "vertices" not in graph_info :
813
+ raise ValueError ("Invalid graph info file, no vertices found." )
814
+ vertex_info_path = graph_info ["vertices" ][0 ]
815
+ if "prefix" in graph_info :
816
+ prefix = graph_info ["prefix" ]
817
+ else :
818
+ prefix = os .path .dirname (path )
819
+ with open (os .path .join (prefix , vertex_info_path ), "r" ) as f :
820
+ vertex_info = yaml .safe_load (f )
821
+ property_groups = vertex_info ["property_groups" ]
822
+ if len (property_groups ) == 0 :
823
+ raise ValueError ("Invalid vertex info file, no property groups found." )
824
+ data_type = None
825
+ for property_group in property_groups :
826
+ properties = property_group ["properties" ]
827
+ if len (properties ) == 0 :
828
+ raise ValueError ("Invalid vertex info file, no properties found." )
829
+ for property in properties :
830
+ if property ["is_primary" ]:
831
+ data_type = property ["data_type" ]
832
+ break
833
+ if data_type == "int64" :
834
+ return "int64_t"
835
+ elif data_type == "string" :
836
+ return "std::string"
837
+ else :
838
+ raise ValueError ("Invalid vertex info file, primary key is not int64 or string." )
0 commit comments