From eb7c2ccf9a1c5179cc10543400f8d5511d2e5c45 Mon Sep 17 00:00:00 2001 From: Anthony Mahanna Date: Mon, 30 Sep 2024 08:54:59 -0400 Subject: [PATCH] Revert "fix: drop instead of truncate" This reverts commit 11347c91d521a246f4e1a5694d278f6d32137d8b. --- nx_arangodb/classes/digraph.py | 9 ++++----- nx_arangodb/classes/graph.py | 20 ++++++++------------ nx_arangodb/classes/multidigraph.py | 9 ++++----- nx_arangodb/classes/multigraph.py | 9 ++++----- 4 files changed, 20 insertions(+), 27 deletions(-) diff --git a/nx_arangodb/classes/digraph.py b/nx_arangodb/classes/digraph.py index cfc8751..09df294 100644 --- a/nx_arangodb/classes/digraph.py +++ b/nx_arangodb/classes/digraph.py @@ -126,11 +126,10 @@ class DiGraph(Graph, nx.DiGraph): as expected. overwrite_graph : bool (optional, default: False) - Whether to drop & re-create the graph collections before loading - **incoming_graph_data** into the graph. NOTE: This parameter only - applies if the graph already exists in the database. NOTE: Dropping - the graph collections will erase all properties of the collections, including - created indexes. + Whether to truncate the graph collections when the graph is loaded from + the database. If set to True, the graph collections will be truncated + before loading the graph data. NOTE: This parameter only applies if the + graph already exists in the database. args: positional arguments for nx.Graph Additional arguments passed to nx.Graph. diff --git a/nx_arangodb/classes/graph.py b/nx_arangodb/classes/graph.py index 7ff312b..42a153c 100644 --- a/nx_arangodb/classes/graph.py +++ b/nx_arangodb/classes/graph.py @@ -160,11 +160,10 @@ class Graph(nx.Graph): as expected. overwrite_graph : bool (optional, default: False) - Whether to drop & re-create the graph collections before loading - **incoming_graph_data** into the graph. NOTE: This parameter only - applies if the graph already exists in the database. NOTE: Dropping - the graph collections will erase all properties of the collections, including - created indexes. + Whether to truncate the graph collections when the graph is loaded from + the database. If set to True, the graph collections will be truncated + before loading the graph data. NOTE: This parameter only applies if the + graph already exists in the database. args: positional arguments for nx.Graph Additional arguments passed to nx.Graph. @@ -232,16 +231,13 @@ def __init__( self.__set_arangodb_backend_config(read_parallelism, read_batch_size) if overwrite_graph: - logger.info("Overwriting graph collections...") + logger.info("Truncating graph collections...") for col in self.adb_graph.vertex_collections(): - self.db.delete_collection(col) - self.db.create_collection(col) + self.db.collection(col).truncate() - for ed in self.adb_graph.edge_definitions(): - col = ed["edge_collection"] - self.db.delete_collection(col) - self.db.create_collection(col, edge=True) + for col in self.adb_graph.edge_definitions(): + self.db.collection(col["edge_collection"]).truncate() if isinstance(incoming_graph_data, nx.Graph): self._load_nx_graph(incoming_graph_data, write_batch_size, write_async) diff --git a/nx_arangodb/classes/multidigraph.py b/nx_arangodb/classes/multidigraph.py index ddf394f..451b501 100644 --- a/nx_arangodb/classes/multidigraph.py +++ b/nx_arangodb/classes/multidigraph.py @@ -136,11 +136,10 @@ class MultiDiGraph(MultiGraph, DiGraph, nx.MultiDiGraph): as expected. overwrite_graph : bool (optional, default: False) - Whether to drop & re-create the graph collections before loading - **incoming_graph_data** into the graph. NOTE: This parameter only - applies if the graph already exists in the database. NOTE: Dropping - the graph collections will erase all properties of the collections, including - created indexes. + Whether to truncate the graph collections when the graph is loaded from + the database. If set to True, the graph collections will be truncated + before loading the graph data. NOTE: This parameter only applies if the + graph already exists in the database. args: positional arguments for nx.Graph Additional arguments passed to nx.Graph. diff --git a/nx_arangodb/classes/multigraph.py b/nx_arangodb/classes/multigraph.py index 491da91..0ce983e 100644 --- a/nx_arangodb/classes/multigraph.py +++ b/nx_arangodb/classes/multigraph.py @@ -137,11 +137,10 @@ class MultiGraph(Graph, nx.MultiGraph): as expected. overwrite_graph : bool (optional, default: False) - Whether to drop & re-create the graph collections before loading - **incoming_graph_data** into the graph. NOTE: This parameter only - applies if the graph already exists in the database. NOTE: Dropping - the graph collections will erase all properties of the collections, including - created indexes. + Whether to truncate the graph collections when the graph is loaded from + the database. If set to True, the graph collections will be truncated + before loading the graph data. NOTE: This parameter only applies if the + graph already exists in the database. args: positional arguments for nx.Graph Additional arguments passed to nx.Graph.