-
Notifications
You must be signed in to change notification settings - Fork 950
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
chore: add ForceUpdate to BPTree #3993
Conversation
Signed-off-by: kostas <[email protected]>
score_tree->Delete(old_obj); | ||
score_tree->Insert(new_obj); | ||
}; | ||
auto cb = [this](sds old_obj, sds new_obj) { score_tree->ForceUpdate(old_obj, new_obj); }; |
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.
when I checked if old_obj
is still alive when thsi callback is called, I realised that ReallocIfNeededGeneric
is really a bad name because it does not REALLOCATE. The better name would be DuplicateEntryIfFragmented
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.
LGTM besides one comment. Have you checked that ForceUpdate
works?
|
IMO It's not a bad idea to add a unit test so I will add one 😄 |
@@ -585,4 +589,15 @@ template <typename T, typename Policy> void BPTree<T, Policy>::DestroyNode(BPTre | |||
num_nodes_--; | |||
} | |||
|
|||
template <typename T, typename Policy> void BPTree<T, Policy>::ForceUpdate(KeyT old, KeyT new_obj) { |
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.
Maybe worth asserting that Policy::operator(old, new_obj)
returns 0
Please rebase. Also |
ReallocIfNeeded
deleted and reinserted the same key in theBPTree
stored inSortedMap
. This is not really needed since the key is actually the same and we can just update the pointer withinBPTree
instead of doing the deletion + insertion chore.Resolves #3963