Copilot commented on code in PR #243:
URL:
https://github.com/apache/incubator-hugegraph-ai/pull/243#discussion_r2097113970
##########
hugegraph-llm/src/hugegraph_llm/operators/index_op/build_semantic_index.py:
##########
@@ -53,6 +53,7 @@ def run(self, context: Dict[str, Any]) -> Dict[str, Any]:
present_vids = context["vertices"] # Warning: data truncated by
fetch_graph_data.py
removed_vids = set(past_vids) - set(present_vids)
removed_num = self.vid_index.remove(removed_vids)
+ self.vid_index.to_index_file(self.index_dir)
Review Comment:
Currently `to_index_file` is called unconditionally after removals, leading
to a disk write even when `removed_vids` is empty. Consider wrapping this call
in a condition (e.g., `if removed_vids:`) to avoid unnecessary I/O.
```suggestion
if removed_vids:
self.vid_index.to_index_file(self.index_dir)
```
##########
hugegraph-llm/src/hugegraph_llm/operators/index_op/build_semantic_index.py:
##########
@@ -53,6 +53,7 @@ def run(self, context: Dict[str, Any]) -> Dict[str, Any]:
present_vids = context["vertices"] # Warning: data truncated by
fetch_graph_data.py
removed_vids = set(past_vids) - set(present_vids)
removed_num = self.vid_index.remove(removed_vids)
+ self.vid_index.to_index_file(self.index_dir)
Review Comment:
The persistence logic is duplicated: once here and again inside the `if
added_vids:` block. To improve maintainability, consolidate the single call to
`to_index_file` after both removals and additions are processed.
```suggestion
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]