MOD-14470 Add VecSimParams_GetQueryBlobSize API for safe query vector allocatio#915
Merged
MOD-14470 Add VecSimParams_GetQueryBlobSize API for safe query vector allocatio#915
Conversation
🛡️ Jit Security Scan Results✅ No security findings were detected in this PR
Security scan by Jit
|
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #915 +/- ##
==========================================
- Coverage 97.13% 97.11% -0.03%
==========================================
Files 129 129
Lines 7551 7557 +6
==========================================
+ Hits 7335 7339 +4
- Misses 216 218 +2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
ofiryanai
approved these changes
Mar 12, 2026
Collaborator
ofiryanai
left a comment
There was a problem hiding this comment.
overall fine, one suggestion. ping to reapprove if you decide to change it
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds a new public API function
VecSimParams_GetQueryBlobSize(type, dim, metric)to calculate the required buffer size for query vectors that will be normalized viaVecSim_Normalize.Background
When normalizing
INT8/UINT8vectors withCosinemetric,VecSim_Normalizeappends the vector's norm (a float) at the end of the blob. Callers allocating buffers for query vectors need to account for this extra space to avoid buffer overflows.This API encapsulates the sizing logic so callers don't need to know the internal implementation details of how normalization works for different type/metric combinations.
Main objects this PR modified
•
src/VecSim/vec_sim.h- Added declaration and documentation for VecSimParams_GetQueryBlobSize•
src/VecSim/vec_sim.cpp- Added implementation of VecSimParams_GetQueryBlobSizeMark if applicable
[X] This PR introduces API changes
[ ] This PR introduces serialization changes
Note
Low Risk
Small, additive API plus tests; behavior is straightforward and only influences callers that opt into the new helper.
Overview
Adds a new public API
VecSimParams_GetQueryBlobSize(type, dim, metric)to let callers allocate query-vector buffers safely when usingVecSim_Normalize, including the extrafloatnorm appended forINT8/UINT8under Cosine metric.Extends unit coverage with a parameterized test for the new sizing logic, and hardens
CommonTypeMetricTeststeardown to avoid freeing a null index.Written by Cursor Bugbot for commit e657913. This will update automatically on new commits. Configure here.