-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
resizing to align blocksize #177
Conversation
… size fits blockSize
…ndexing_same_vector test
Codecov Report
@@ Coverage Diff @@
## main #177 +/- ##
==========================================
+ Coverage 93.54% 93.68% +0.14%
==========================================
Files 40 40
Lines 2338 2344 +6
==========================================
+ Hits 2187 2196 +9
+ Misses 151 148 -3
Continue to review full report at Codecov.
|
…leteVector in case an entire block is removed, the capacity is aligned to blocksize and a decreased by block size, added test for resize cases in hnswlib
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good first PR!! :)
I left some comments and questions
…orSimilarity into update_resize_logic
also changed HNSWIndex::delete vector to return false in this case (before checking if resizing is required) - this covers (hopedully) also empty index case and resizing only when actual deletion happend
…llements from addPoint (cant happen, we check this in addVector)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Last comments
Co-authored-by: alonre24 <alonreshef24@gmail.com>
Co-authored-by: alonre24 <alonreshef24@gmail.com>
Co-authored-by: alonre24 <alonreshef24@gmail.com>
…orSimilarity into update_resize_logic
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great
- Please edit the PR description to describe your changes
- please add a test where capacity is dropped to 0. If it is already covered by one of the existing tests, just mention it.
size_t extra_space_to_free = curr_capacity % blockSize; | ||
|
||
// Remove one block from the capacity. TODO check that we dont go below zero | ||
this->hnsw->resizeIndex(curr_capacity - blockSize - extra_space_to_free); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about this TODO?
Co-authored-by: DvirDukhan <dvir@redis.com>
Co-authored-by: DvirDukhan <dvir@redis.com>
* modified resize logic of BF addvector so that the ids2vectors mapping size fits blockSize * fixed increasing count in case od re-using id, update brute_force_reindexing_same_vector test * clang format * HNSWIndex::addVector aligns the capacity to block size, HNSWIndex::deleteVector in case an entire block is removed, the capacity is aligned to blocksize and a decreased by block size, added test for resize cases in hnswlib * make format * update size estimation test * fixed after Alon's review * clang format * cahnged hnsw::remove point to return false in case not found, also changed HNSWIndex::delete vector to return false in this case (before checking if resizing is required) - this covers (hopedully) also empty index case and resizing only when actual deletion happend * added tests for empty HNSW index * added isLabelExists to hnswlib and modified test of id overrrides * hnsw::removepoint return void, checking if label exists happens only in the wrrapper * clang format * update test to removed checking if element count is bigger than max_ellements from addPoint (cant happen, we check this in addVector) * override test intial size * remove if exists in addvector update * Update src/VecSim/algorithms/hnsw/hnsw_wrapper.cpp Co-authored-by: alonre24 <alonreshef24@gmail.com> * Update tests/unit/test_hnswlib.cpp Co-authored-by: alonre24 <alonreshef24@gmail.com> * Update tests/unit/test_hnswlib.cpp Co-authored-by: alonre24 <alonreshef24@gmail.com> * removed redudent tests after alon's review * fixed tests * Update src/VecSim/algorithms/brute_force/brute_force.cpp Co-authored-by: DvirDukhan <dvir@redis.com> * Update tests/unit/test_hnswlib.cpp Co-authored-by: DvirDukhan <dvir@redis.com> * empty index and capacity = 0 tests. removed todo from hnsw_wrapper Co-authored-by: alonre24 <alonreshef24@gmail.com> Co-authored-by: DvirDukhan <dvir@redis.com>
* modified resize logic of BF addvector so that the ids2vectors mapping size fits blockSize * fixed increasing count in case od re-using id, update brute_force_reindexing_same_vector test * clang format * HNSWIndex::addVector aligns the capacity to block size, HNSWIndex::deleteVector in case an entire block is removed, the capacity is aligned to blocksize and a decreased by block size, added test for resize cases in hnswlib * make format * update size estimation test * fixed after Alon's review * clang format * cahnged hnsw::remove point to return false in case not found, also changed HNSWIndex::delete vector to return false in this case (before checking if resizing is required) - this covers (hopedully) also empty index case and resizing only when actual deletion happend * added tests for empty HNSW index * added isLabelExists to hnswlib and modified test of id overrrides * hnsw::removepoint return void, checking if label exists happens only in the wrrapper * clang format * update test to removed checking if element count is bigger than max_ellements from addPoint (cant happen, we check this in addVector) * override test intial size * remove if exists in addvector update * Update src/VecSim/algorithms/hnsw/hnsw_wrapper.cpp Co-authored-by: alonre24 <alonreshef24@gmail.com> * Update tests/unit/test_hnswlib.cpp Co-authored-by: alonre24 <alonreshef24@gmail.com> * Update tests/unit/test_hnswlib.cpp Co-authored-by: alonre24 <alonreshef24@gmail.com> * removed redudent tests after alon's review * fixed tests * Update src/VecSim/algorithms/brute_force/brute_force.cpp Co-authored-by: DvirDukhan <dvir@redis.com> * Update tests/unit/test_hnswlib.cpp Co-authored-by: DvirDukhan <dvir@redis.com> * empty index and capacity = 0 tests. removed todo from hnsw_wrapper Co-authored-by: alonre24 <alonreshef24@gmail.com> Co-authored-by: DvirDukhan <dvir@redis.com>
* modified resize logic of BF addvector so that the ids2vectors mapping size fits blockSize * fixed increasing count in case od re-using id, update brute_force_reindexing_same_vector test * clang format * HNSWIndex::addVector aligns the capacity to block size, HNSWIndex::deleteVector in case an entire block is removed, the capacity is aligned to blocksize and a decreased by block size, added test for resize cases in hnswlib * make format * update size estimation test * fixed after Alon's review * clang format * cahnged hnsw::remove point to return false in case not found, also changed HNSWIndex::delete vector to return false in this case (before checking if resizing is required) - this covers (hopedully) also empty index case and resizing only when actual deletion happend * added tests for empty HNSW index * added isLabelExists to hnswlib and modified test of id overrrides * hnsw::removepoint return void, checking if label exists happens only in the wrrapper * clang format * update test to removed checking if element count is bigger than max_ellements from addPoint (cant happen, we check this in addVector) * override test intial size * remove if exists in addvector update * Update src/VecSim/algorithms/hnsw/hnsw_wrapper.cpp Co-authored-by: alonre24 <alonreshef24@gmail.com> * Update tests/unit/test_hnswlib.cpp Co-authored-by: alonre24 <alonreshef24@gmail.com> * Update tests/unit/test_hnswlib.cpp Co-authored-by: alonre24 <alonreshef24@gmail.com> * removed redudent tests after alon's review * fixed tests * Update src/VecSim/algorithms/brute_force/brute_force.cpp Co-authored-by: DvirDukhan <dvir@redis.com> * Update tests/unit/test_hnswlib.cpp Co-authored-by: DvirDukhan <dvir@redis.com> * empty index and capacity = 0 tests. removed todo from hnsw_wrapper Co-authored-by: alonre24 <alonreshef24@gmail.com> Co-authored-by: DvirDukhan <dvir@redis.com>
* modified resize logic of BF addvector so that the ids2vectors mapping size fits blockSize * fixed increasing count in case od re-using id, update brute_force_reindexing_same_vector test * clang format * HNSWIndex::addVector aligns the capacity to block size, HNSWIndex::deleteVector in case an entire block is removed, the capacity is aligned to blocksize and a decreased by block size, added test for resize cases in hnswlib * make format * update size estimation test * fixed after Alon's review * clang format * cahnged hnsw::remove point to return false in case not found, also changed HNSWIndex::delete vector to return false in this case (before checking if resizing is required) - this covers (hopedully) also empty index case and resizing only when actual deletion happend * added tests for empty HNSW index * added isLabelExists to hnswlib and modified test of id overrrides * hnsw::removepoint return void, checking if label exists happens only in the wrrapper * clang format * update test to removed checking if element count is bigger than max_ellements from addPoint (cant happen, we check this in addVector) * override test intial size * remove if exists in addvector update * Update src/VecSim/algorithms/hnsw/hnsw_wrapper.cpp Co-authored-by: alonre24 <alonreshef24@gmail.com> * Update tests/unit/test_hnswlib.cpp Co-authored-by: alonre24 <alonreshef24@gmail.com> * Update tests/unit/test_hnswlib.cpp Co-authored-by: alonre24 <alonreshef24@gmail.com> * removed redudent tests after alon's review * fixed tests * Update src/VecSim/algorithms/brute_force/brute_force.cpp Co-authored-by: DvirDukhan <dvir@redis.com> * Update tests/unit/test_hnswlib.cpp Co-authored-by: DvirDukhan <dvir@redis.com> * empty index and capacity = 0 tests. removed todo from hnsw_wrapper Co-authored-by: alonre24 <alonreshef24@gmail.com> Co-authored-by: DvirDukhan <dvir@redis.com>
Changes made in this PR:
1. in HNSW index
aligned to block size and decreased by block size.
2. in brute force index:
vector block size