File tree Expand file tree Collapse file tree 1 file changed +10
-10
lines changed Expand file tree Collapse file tree 1 file changed +10
-10
lines changed Original file line number Diff line number Diff line change @@ -446,18 +446,18 @@ def edge_type_func(u: str, v: str) -> str:
446446 def _load_nx_graph (
447447 self , nx_graph : nx .Graph , write_batch_size : int , write_async : bool
448448 ) -> None :
449- v_count = sum (
450- self .db .collection (v ).count () for v in self .adb_graph .vertex_collections ()
451- )
449+ collections = list (self .adb_graph .vertex_collections ())
450+ collections += [e ["edge_collection" ] for e in self .adb_graph .edge_definitions ()]
452451
453- e_count = sum (
454- self .db .collection (e ["edge_collection" ]).count ()
455- for e in self .adb_graph .edge_definitions ()
456- )
452+ for col in collections :
453+ cursor = self .db .aql .execute (
454+ "FOR doc IN @@collection LIMIT 1 RETURN 1" ,
455+ bind_vars = {"@collection" : col },
456+ )
457457
458- if v_count > 0 or e_count > 0 :
459- m = f"Graph '{ self .adb_graph .name } ' already has data. Use **overwrite_graph=True** to clear it." # noqa: E501
460- raise GraphNotEmpty (m )
458+ if not cursor . empty () :
459+ m = f"Graph '{ self .adb_graph .name } ' already has data (in ' { col } ') . Use **overwrite_graph=True** to clear it." # noqa: E501
460+ raise GraphNotEmpty (m )
461461
462462 controller = ADBNX_Controller
463463
You can’t perform that action at this time.
0 commit comments