refactor(hnsw,io): correct error type for memory allocation (cherry-pick to 0.18)#1748
Conversation
Summary of ChangesHello, 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 refactors memory allocation error handling across the HNSW algorithm and Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. 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. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request refactors error handling in hnswlib and MemoryBlockIO by replacing std::runtime_error with VsagException for memory allocation failures. It introduces vsag_exception.h and uses VsagException(ErrorType::NO_ENOUGH_MEMORY, ...) for all memory allocation-related errors. A review comment suggests moving the using declarations for ErrorType and VsagException inside the hnswlib namespace for better code clarity and to avoid global namespace pollution.
| using vsag::ErrorType; | ||
| using vsag::VsagException; | ||
|
|
||
| namespace hnswlib { |
There was a problem hiding this comment.
To improve code clarity and avoid polluting the global namespace, it's recommended to place using declarations within the namespace where they are utilized. This change moves the using declarations for ErrorType and VsagException inside the hnswlib namespace.
namespace hnswlib {
using vsag::ErrorType;
using vsag::VsagException;6a16a64 to
7832f7b
Compare
Codecov Report❌ Patch coverage is ❌ Your patch status has failed because the patch coverage (19.23%) is below the target coverage (80.00%). You can increase the patch coverage or adjust the target coverage. @@ Coverage Diff @@
## 0.18 #1748 +/- ##
==========================================
- Coverage 91.21% 91.16% -0.06%
==========================================
Files 328 328
Lines 19327 19336 +9
==========================================
- Hits 17630 17627 -3
- Misses 1697 1709 +12
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report in Codecov by Sentry.
🚀 New features to boost your workflow:
|
Replace std::runtime_error with VsagException(ErrorType::NO_ENOUGH_MEMORY) for memory allocation failures in HNSW algorithm and MemoryBlockIO. Cherry-picked from PR #1658 to 0.18 branch. Co-Authored-By: Claude <noreply@anthropic.com> Signed-off-by: jinjiabao.jjb <jinjiabao.jjb@antgroup.com>
7832f7b to
4091ae3
Compare
Summary
Cherry-pick PR #1658 to 0.18 branch.
Replace std::runtime_error with VsagException(ErrorType::NO_ENOUGH_MEMORY) for memory allocation failures in HNSW algorithm and MemoryBlockIO.
Changes
Modified src/algorithm/hnswlib/hnswalg.cpp:
Modified src/io/memory_block_io.cpp: