Add custom allocator support to SimpleBlockedGraph (resolves #81) #1
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.
Add custom allocator support to SimpleBlockedGraph (resolves intel#81)
Summary
This PR resolves issue #81 by adding custom allocator support to
SimpleBlockedGraphfor dynamic vamana index graph construction. Previously,SimpleBlockedGraphwas hardcoded to useHugepageAllocator, preventing users from providing their own allocators.Changes:
SimpleBlockedGraphwith defaultHugepageAllocator<Idx>(following the pattern already established inSimpleGraph)SimpleBlockedGraph(size_t num_nodes, size_t max_degree, const Alloc& allocator)load()methods to accept optional allocator parameter with defaultoperator==for comparing graphs with different allocatorsmulti.hto explicitly specifyHugepageAllocator<uint32_t>Backward Compatibility:
All existing code continues to work without modification because the allocator template parameter defaults to
HugepageAllocator<Idx>. Code usingSimpleBlockedGraph<uint32_t>will automatically resolve toSimpleBlockedGraph<uint32_t, HugepageAllocator<uint32_t>>.Review & Testing Checklist for Human
This PR has moderate risk due to lack of local compilation and runtime testing. Please verify:
SimpleBlockedGraph<uint32_t>should compile and work identically to beforemulti.hnow explicitly specifyHugepageAllocator<uint32_t>. Review these carefully to ensure they don't break template argument deductionSimpleBlockedGraph<uint32_t, CustomAllocator<uint32_t>>and use it withMutableVamanaIndexSimpleBlockedGraphto verify the feature works end-to-endTest Plan Recommendation
SimpleBlockedGraphwith a custom allocator (e.g.,std::allocator<uint32_t>) in a test fileMutableVamanaIndexfor graph constructionNotes
SimpleGraph(lines 337-377 ingraph.h), which already has custom allocator supportdata::BlockedDataproperly supports custom allocators (verified from Python bindings usage, but not verified in the actual implementation)SimpleGraphDevin Session: https://app.devin.ai/sessions/d6b3fe1407f141f3b43e774b3e91aa46
Requested by: @milind-cognition