Skip to content

Commit 11347c9

Browse files
committed
fix: drop instead of truncate
1 parent 69124a4 commit 11347c9

File tree

4 files changed

+27
-20
lines changed

4 files changed

+27
-20
lines changed

nx_arangodb/classes/digraph.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -126,10 +126,11 @@ class DiGraph(Graph, nx.DiGraph):
126126
as expected.
127127
128128
overwrite_graph : bool (optional, default: False)
129-
Whether to truncate the graph collections when the graph is loaded from
130-
the database. If set to True, the graph collections will be truncated
131-
before loading the graph data. NOTE: This parameter only applies if the
132-
graph already exists in the database.
129+
Whether to drop & re-create the graph collections before loading
130+
**incoming_graph_data** into the graph. NOTE: This parameter only
131+
applies if the graph already exists in the database. NOTE: Dropping
132+
the graph collections will erase all properties of the collections, including
133+
created indexes.
133134
134135
args: positional arguments for nx.Graph
135136
Additional arguments passed to nx.Graph.

nx_arangodb/classes/graph.py

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -160,10 +160,11 @@ class Graph(nx.Graph):
160160
as expected.
161161
162162
overwrite_graph : bool (optional, default: False)
163-
Whether to truncate the graph collections when the graph is loaded from
164-
the database. If set to True, the graph collections will be truncated
165-
before loading the graph data. NOTE: This parameter only applies if the
166-
graph already exists in the database.
163+
Whether to drop & re-create the graph collections before loading
164+
**incoming_graph_data** into the graph. NOTE: This parameter only
165+
applies if the graph already exists in the database. NOTE: Dropping
166+
the graph collections will erase all properties of the collections, including
167+
created indexes.
167168
168169
args: positional arguments for nx.Graph
169170
Additional arguments passed to nx.Graph.
@@ -231,13 +232,16 @@ def __init__(
231232
self.__set_arangodb_backend_config(read_parallelism, read_batch_size)
232233

233234
if overwrite_graph:
234-
logger.info("Truncating graph collections...")
235+
logger.info("Overwriting graph collections...")
235236

236237
for col in self.adb_graph.vertex_collections():
237-
self.db.collection(col).truncate()
238+
self.db.delete_collection(col)
239+
self.db.create_collection(col)
238240

239-
for col in self.adb_graph.edge_definitions():
240-
self.db.collection(col["edge_collection"]).truncate()
241+
for ed in self.adb_graph.edge_definitions():
242+
col = ed["edge_collection"]
243+
self.db.delete_collection(col)
244+
self.db.create_collection(col, edge=True)
241245

242246
if isinstance(incoming_graph_data, nx.Graph):
243247
self._load_nx_graph(incoming_graph_data, write_batch_size, write_async)

nx_arangodb/classes/multidigraph.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -136,10 +136,11 @@ class MultiDiGraph(MultiGraph, DiGraph, nx.MultiDiGraph):
136136
as expected.
137137
138138
overwrite_graph : bool (optional, default: False)
139-
Whether to truncate the graph collections when the graph is loaded from
140-
the database. If set to True, the graph collections will be truncated
141-
before loading the graph data. NOTE: This parameter only applies if the
142-
graph already exists in the database.
139+
Whether to drop & re-create the graph collections before loading
140+
**incoming_graph_data** into the graph. NOTE: This parameter only
141+
applies if the graph already exists in the database. NOTE: Dropping
142+
the graph collections will erase all properties of the collections, including
143+
created indexes.
143144
144145
args: positional arguments for nx.Graph
145146
Additional arguments passed to nx.Graph.

nx_arangodb/classes/multigraph.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -137,10 +137,11 @@ class MultiGraph(Graph, nx.MultiGraph):
137137
as expected.
138138
139139
overwrite_graph : bool (optional, default: False)
140-
Whether to truncate the graph collections when the graph is loaded from
141-
the database. If set to True, the graph collections will be truncated
142-
before loading the graph data. NOTE: This parameter only applies if the
143-
graph already exists in the database.
140+
Whether to drop & re-create the graph collections before loading
141+
**incoming_graph_data** into the graph. NOTE: This parameter only
142+
applies if the graph already exists in the database. NOTE: Dropping
143+
the graph collections will erase all properties of the collections, including
144+
created indexes.
144145
145146
args: positional arguments for nx.Graph
146147
Additional arguments passed to nx.Graph.

0 commit comments

Comments
 (0)