refactor: use get_nerghbors in storage instead of building adj_list#164
refactor: use get_nerghbors in storage instead of building adj_list#164ChenZiHong-Gavin merged 3 commits intomainfrom
Conversation
Summary of ChangesHello @ChenZiHong-Gavin, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly refactors the graph partitioning mechanism by shifting the responsibility of neighbor retrieval from individual partitioner algorithms to the core graph storage layer. This change centralizes the logic for fetching node neighbors, reducing code duplication across different partitioners and allowing for storage-specific optimizations. The result is a cleaner, more modular, and potentially more performant architecture for graph operations. Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request is a good refactoring that centralizes neighbor retrieval logic into the storage layer by introducing a get_neighbors method. This simplifies the partitioner implementations by removing the need for them to build their own adjacency lists. I've identified a critical issue in the KuzuStorage implementation of get_neighbors that would lead to incorrect partitioning, as well as a couple of medium-severity issues related to code correctness and best practices. My review includes specific suggestions to address these points. Overall, this is a valuable change once the feedback is incorporated.
| print(f"Node {node_id} not found in the graph.") | ||
| return [] |
There was a problem hiding this comment.
Printing to standard output in a library function is generally discouraged. It can clutter the output of the application using the library and may not be desirable in all contexts (e.g., when running in production or as part of a larger pipeline). It's better to either use a proper logging framework or simply return an empty list, letting the caller decide how to handle the 'node not found' case. The empty list sufficiently signals that there are no neighbors, which is true if the node doesn't exist.
| print(f"Node {node_id} not found in the graph.") | |
| return [] | |
| return [] |
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
This PR refactors the graph partitioning mechanism by shifting the responsibility of neighbor retrieval from individual partitioner algorithms to the core graph storage layer.