[MMAP][CPPRuntime] Extend map_to_memory API to include output read_bytes param#341
Open
rfsaliev wants to merge 1 commit into
Open
[MMAP][CPPRuntime] Extend map_to_memory API to include output read_bytes param#341rfsaliev wants to merge 1 commit into
rfsaliev wants to merge 1 commit into
Conversation
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.
This pull request enhances the in-memory mapping functionality for both
FlatIndexandVamanaIndexby allowing the number of bytes read during deserialization to be reported. It also adds comprehensive tests to verify the correct behavior of this feature across different index types and storage kinds. The changes improve robustness and observability of index loading from memory buffers.API Enhancements
The
map_to_memorymethods for bothFlatIndexandVamanaIndexnow accept an optionalsize_t* read_bytesparameter, allowing callers to determine how many bytes were consumed during mapping. [1] [2] [3] [4]Implementation of
get_mapped_stream()accessor in bothFlatIndexImplandVamanaIndexImplto expose the stream position for calculatingread_bytes. [1] [2]Testing Improvements
Added a generic test helper,
write_and_map_index_from_memory, to build, serialize, and map indices from in-memory buffers, checking thatread_bytesis set correctly and that the loaded index is functional.Introduced new test cases for mapping from memory for all major index/storage kind combinations:
FlatIndexWriteAndMapToMemoryWriteAndMapToMemoryStaticIndexSVSWriteAndMapToMemoryStaticIndexSVSLVQ4x4WriteAndMapToMemoryStaticIndexSVSLeanVec4x4Robustness
read_bytesis provided and when it isnullptr, ensuring backward compatibility and correct handling in both scenarios.These changes together make the index mapping API more informative and thoroughly tested for different use cases.