Skip to content

MOD-14470 Add VecSimParams_GetQueryBlobSize API for safe query vector allocatio#915

Merged
meiravgri merged 4 commits intomainfrom
meiravg_query_blob_size
Mar 12, 2026
Merged

MOD-14470 Add VecSimParams_GetQueryBlobSize API for safe query vector allocatio#915
meiravgri merged 4 commits intomainfrom
meiravg_query_blob_size

Conversation

@meiravgri
Copy link
Collaborator

@meiravgri meiravgri commented Mar 11, 2026

Adds a new public API function VecSimParams_GetQueryBlobSize(type, dim, metric) to calculate the required buffer size for query vectors that will be normalized via VecSim_Normalize.

Background

When normalizing INT8/UINT8 vectors with Cosine metric, VecSim_Normalize appends 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_GetQueryBlobSize

Mark 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 using VecSim_Normalize, including the extra float norm appended for INT8/UINT8 under Cosine metric.

Extends unit coverage with a parameterized test for the new sizing logic, and hardens CommonTypeMetricTests teardown to avoid freeing a null index.

Written by Cursor Bugbot for commit e657913. This will update automatically on new commits. Configure here.

@jit-ci
Copy link

jit-ci bot commented Mar 11, 2026

🛡️ Jit Security Scan Results

CRITICAL HIGH MEDIUM

✅ No security findings were detected in this PR


Security scan by Jit

@meiravgri meiravgri changed the title api for VecSimParams_GetQueryBlobSize MOD-14470 Add VecSimParams_GetQueryBlobSize API for safe query vector allocatio Mar 11, 2026
Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link

codecov bot commented Mar 11, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.11%. Comparing base (586a220) to head (e657913).
⚠️ Report is 1 commits behind head on main.

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Collaborator

@ofiryanai ofiryanai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

overall fine, one suggestion. ping to reapprove if you decide to change it

@meiravgri meiravgri added this pull request to the merge queue Mar 12, 2026
Merged via the queue into main with commit 8d37cf1 Mar 12, 2026
17 checks passed
@meiravgri meiravgri deleted the meiravg_query_blob_size branch March 12, 2026 10:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants