[CPP Runtime] Add get_distance and reconstruct_at to VamanaIndex API#315
Open
yuejiaointel wants to merge 5 commits into
Open
[CPP Runtime] Add get_distance and reconstruct_at to VamanaIndex API#315yuejiaointel wants to merge 5 commits into
yuejiaointel wants to merge 5 commits into
Conversation
Add get_distance() and reconstruct_at() methods to the runtime library for OpenSearch integration. These expose existing orchestrator-layer functionality through the shared library ABI. - get_distance: computes distance between a stored vector and a query - reconstruct_at: decompresses/reconstructs vectors to float32 by ID - Works with all storage kinds (FP32, FP16, SQI8, LVQ, LeanVec) - Added to both VamanaIndex (static) and DynamicVamanaIndex - Includes tests for both index types
0ed65a3 to
9ac27bc
Compare
rfsaliev
requested changes
Apr 15, 2026
Member
rfsaliev
left a comment
There was a problem hiding this comment.
Please change new methods' signatures in VamanaIndexImpl and DynamicVamanaIndexImpl according to the signature style used in other existing methods i.e. typed containers rather than raw pointers
…terpret_cast - VamanaIndexImpl/DynamicVamanaIndexImpl: get_distance and reconstruct_at now take typed containers (std::span<const float>, SimpleDataView<float>, std::span<const size_t>), matching the existing add() convention. The Manager wrappers build the views from raw C-ABI pointers. - Public API: get_distance returns float* instead of double* to match the rest of the runtime API (search distances, etc.). - Replace unsafe reinterpret_cast<const uint64_t*>(ids) with a type-safe std::vector<uint64_t> copy.
rfsaliev
approved these changes
May 27, 2026
Member
rfsaliev
left a comment
There was a problem hiding this comment.
LGFM
nitpicking comment can be ignored or addressed - up to your perfectionism :)
Comment on lines
+89
to
+92
| get_distance(float* distance, size_t id, const float* query) const noexcept = 0; | ||
|
|
||
| // Reconstruct `n` vectors by ID into `output` buffer (n * dim floats). | ||
| virtual Status reconstruct_at(size_t n, const size_t* ids, float* output) noexcept = 0; |
Member
There was a problem hiding this comment.
nit: slight inconsistency: in get_distance(), the 'output' argument is the first, when reconstruct_at() - last.
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.
Summary
get_distance()andreconstruct_at()methods to the runtime shared library (VamanaIndexandDynamicVamanaIndex)get_distancecomputes distance between a stored vector (by ID) and a query vector, returning adoublereconstruct_atdecompresses/reconstructs stored vectors back tofloat32by ID — works transparently with all storage kinds (FP32, FP16, SQI8, LVQ, LeanVec)runtime_error_wrapperin the manager, orchestrator dispatch in the impl layer