Skip to content

Commit

Permalink
optimize __fetch_adb_docs
Browse files Browse the repository at this point in the history
  • Loading branch information
aMahanna committed Jan 19, 2024
1 parent e725a20 commit 3384fb1
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions adbnx_adapter/adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ def arangodb_to_networkx(

# 1. Fetch ArangoDB vertices
v_col_cursor, v_col_size = self.__fetch_adb_docs(
v_col, atribs, explicit_metagraph, **adb_export_kwargs
v_col, False, atribs, explicit_metagraph, **adb_export_kwargs
)

# 2. Process ArangoDB vertices
Expand All @@ -167,7 +167,7 @@ def arangodb_to_networkx(

# 1. Fetch ArangoDB edges
e_col_cursor, e_col_size = self.__fetch_adb_docs(
e_col, atribs, explicit_metagraph, **adb_export_kwargs
e_col, True, atribs, explicit_metagraph, **adb_export_kwargs
)

# 2. Process ArangoDB edges
Expand Down Expand Up @@ -421,6 +421,7 @@ def networkx_to_arangodb(
def __fetch_adb_docs(
self,
col: str,
is_edge: bool,
attributes: Set[str],
explicit_metagraph: bool,
**adb_export_kwargs: Any,
Expand All @@ -429,6 +430,8 @@ def __fetch_adb_docs(
:param col: The ArangoDB collection.
:type col: str
:param is_edge: True if **col** is an edge collection.
:type is_edge: bool
:param attributes: The set of document attributes.
:type attributes: Set[str]
:param explicit_metagraph: If True, only return the set of **attributes**
Expand All @@ -443,11 +446,11 @@ def __fetch_adb_docs(
"""
aql_return_value = "doc"
if explicit_metagraph:
edge_keys = "_from: doc._from, _to: doc._to" if is_edge else ""
aql_return_value = f"""
MERGE(
KEEP(doc, {list(attributes)}),
{{"_id": doc._id}},
doc._from ? {{"_from": doc._from, "_to": doc._to}}: {{}}
{{"_id": doc._id, {edge_keys}}}
)
"""

Expand Down

0 comments on commit 3384fb1

Please sign in to comment.