Skip to content
Closed

Dev #317

Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions blarify/db_managers/neo4j_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,19 @@ def save_graph(self, nodes: List[Any], edges: List[Any]):
self.create_edges(edges)

def create_nodes(self, nodeList: List[Any]):
# Function to create nodes in the Neo4j database
batch_size: int = 5000
total_nodes: int = len(nodeList)
total_batches: int = (total_nodes + batch_size - 1) // batch_size
logger.info(f"Creating {total_nodes} nodes in batches of {batch_size}")

with self.driver.session() as session:
session.write_transaction(
self._create_nodes_txn, nodeList, 100, repoId=self.repo_id, entityId=self.entity_id
)
for i in range(0, total_nodes, batch_size):
batch: List[Any] = nodeList[i:i + batch_size]
batch_num: int = i // batch_size + 1
logger.info(f"Processing nodes batch {batch_num}/{total_batches} ({i}/{total_nodes})")
session.write_transaction(
self._create_nodes_txn, batch, 100, repoId=self.repo_id, entityId=self.entity_id
)

def create_edges(self, edgesList: List[Any]):
# Function to create edges between nodes in the Neo4j database
Expand Down
Loading