feat(Hgraph): support tunning alpha in MRNG#1104
feat(Hgraph): support tunning alpha in MRNG#1104ShawnShawnYou merged 2 commits intoantgroup:mainfrom
Conversation
|
Important Installation incomplete: to start using Gemini Code Assist, please ask the organization owner(s) to visit the Gemini Code Assist Admin Console and sign the Terms of Services. |
Reviewer's GuideAdd support for a tunable “alpha” parameter in MRNG-based HGraph and Pyramid indices by propagating the new parameter through configuration parsing, class initialization, neighbor‐connection routines, constants, and examples. Sequence diagram for neighbor connection with alpha parameter in MRNGsequenceDiagram
participant HGraph
participant PruningStrategy
participant Graph
HGraph->>PruningStrategy: mutually_connect_new_element(..., alpha)
PruningStrategy->>Graph: select_edges_by_heuristic(..., alpha)
Note right of PruningStrategy: Alpha influences edge selection
Entity relationship diagram for new alpha field in index configurationerDiagram
HGRAPH_PARAMETER {
float alpha
}
PYRAMID_PARAMETERS {
float alpha
}
HGRAPH_PARAMETER ||--o| HGRAPH : configures
PYRAMID_PARAMETERS ||--o| PYRAMID : configures
Class diagram for updated HGraph and Pyramid with tunable alpha parameterclassDiagram
class HGraphParameter {
+float alpha
+FromJson(json)
+ToJson()
}
class PyramidParameters {
+float alpha
+FromJson(json)
+ToJson()
}
class HGraph {
+float alpha_
+HGraphParameter hgraph_params_
+HGraph(hgraph_param, common_param)
}
class Pyramid {
+float alpha_
+Pyramid(pyramid_param, common_param)
}
HGraphParameter <|-- HGraph
PyramidParameters <|-- Pyramid
HGraphParameter : FromJson(json)
HGraphParameter : ToJson()
PyramidParameters : FromJson(json)
PyramidParameters : ToJson()
File-Level Changes
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey there - I've reviewed your changes and they look great!
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location> `src/algorithm/hgraph_parameter.cpp:132` </location>
<code_context>
if (build_params.contains(BUILD_EF_CONSTRUCTION)) {
this->ef_construction = build_params[BUILD_EF_CONSTRUCTION];
}
+ if (build_params.contains(BUILD_ALPHA_KEY)) {
+ this->alpha = build_params[BUILD_ALPHA_KEY];
+ }
if (build_params.contains(BUILD_THREAD_COUNT)) {
</code_context>
<issue_to_address>
Type safety for alpha assignment from JSON should be ensured.
Validate or convert build_params[BUILD_ALPHA_KEY] to float before assignment to prevent type-related errors.
</issue_to_address>
<suggested_fix>
<<<<<<< SEARCH
if (build_params.contains(BUILD_ALPHA_KEY)) {
this->alpha = build_params[BUILD_ALPHA_KEY];
}
=======
if (build_params.contains(BUILD_ALPHA_KEY)) {
// Ensure type safety: convert to float if necessary
if (build_params[BUILD_ALPHA_KEY].is_number_float()) {
this->alpha = build_params[BUILD_ALPHA_KEY].get<float>();
} else if (build_params[BUILD_ALPHA_KEY].is_number_integer()) {
this->alpha = static_cast<float>(build_params[BUILD_ALPHA_KEY].get<int>());
} else {
// Handle unexpected type (optional: throw, log, or set default)
this->alpha = 0.0f; // or handle error as appropriate
}
}
>>>>>>> REPLACE
</suggested_fix>
### Comment 2
<location> `src/algorithm/pyramid_zparameters.cpp:53` </location>
<code_context>
if (build_params.contains(BUILD_EF_CONSTRUCTION)) {
this->ef_construction = build_params[BUILD_EF_CONSTRUCTION];
}
+ if (build_params.contains(BUILD_ALPHA_KEY)) {
+ this->alpha = build_params[BUILD_ALPHA_KEY];
+ }
if (build_params.contains(BUILD_THREAD_COUNT)) {
</code_context>
<issue_to_address>
Type conversion for alpha from JSON should be explicit.
Assigning directly from JSON can cause type issues if the value isn't a float. Use an explicit cast to ensure type safety.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
| if (build_params.contains(BUILD_ALPHA_KEY)) { | ||
| this->alpha = build_params[BUILD_ALPHA_KEY]; | ||
| } |
There was a problem hiding this comment.
suggestion: Type safety for alpha assignment from JSON should be ensured.
Validate or convert build_params[BUILD_ALPHA_KEY] to float before assignment to prevent type-related errors.
| if (build_params.contains(BUILD_ALPHA_KEY)) { | |
| this->alpha = build_params[BUILD_ALPHA_KEY]; | |
| } | |
| if (build_params.contains(BUILD_ALPHA_KEY)) { | |
| // Ensure type safety: convert to float if necessary | |
| if (build_params[BUILD_ALPHA_KEY].is_number_float()) { | |
| this->alpha = build_params[BUILD_ALPHA_KEY].get<float>(); | |
| } else if (build_params[BUILD_ALPHA_KEY].is_number_integer()) { | |
| this->alpha = static_cast<float>(build_params[BUILD_ALPHA_KEY].get<int>()); | |
| } else { | |
| // Handle unexpected type (optional: throw, log, or set default) | |
| this->alpha = 0.0f; // or handle error as appropriate | |
| } | |
| } |
| if (build_params.contains(BUILD_ALPHA_KEY)) { | ||
| this->alpha = build_params[BUILD_ALPHA_KEY]; |
There was a problem hiding this comment.
suggestion: Type conversion for alpha from JSON should be explicit.
Assigning directly from JSON can cause type issues if the value isn't a float. Use an explicit cast to ensure type safety.
Signed-off-by: HeHuMing <hehuming434@gmail.com>
Codecov Report❌ Patch coverage is @@ Coverage Diff @@
## main #1104 +/- ##
==========================================
- Coverage 92.14% 92.02% -0.12%
==========================================
Files 310 310
Lines 18526 18537 +11
==========================================
- Hits 17070 17058 -12
- Misses 1456 1479 +23
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:
|
Signed-off-by: HeHuMing <hehuming434@gmail.com>
close #1060
After alpha is exposed, with Recallavg aligned on the gist-960 dataset, QPS increases by 14.3%.