Skip to content
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

fix(core): fix an edge case for split_off operation for RrbVec #105

Merged
merged 1 commit into from
Oct 21, 2023

Conversation

arazabishov
Copy link
Owner

There is an edge case that brakes the push operation on RrbVec. Here are the steps to reproduce it:

  • Create a new RrbVec instance exactly of the BRANCH_FACTOR * BRANCH_FACTOR size.
  • Split it exactly at the following index: BRANCH_FACTOR * BRANCH_FACTOR - BRANCH_FACTOR.
  • Try pushing a new item onto the new (right-hand side) vector.

A simple example for a vector that has a branching factor of 4:

  • The in-memory representation of the following vector is going to be a complete and full tree: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15].
  • Trying to split it at index 12 will produce two new vectors: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11] and [12, 13, 14, 15].

The right hand size vector will have a full tail. The bug was that the tail was not pushed onto tree when full. When trying to push an ordinary item, 16 for example, it will overflow the vector and cause a panic.

@vercel
Copy link

vercel bot commented Oct 21, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
pvec-rs ✅ Ready (Inspect) Visit Preview Oct 21, 2023 8:10pm

@arazabishov arazabishov merged commit d9037c3 into trunk Oct 21, 2023
4 checks passed
@arazabishov arazabishov deleted the user/arazabishov/fix-split-off-edge-case branch October 21, 2023 20:17
@arazabishov arazabishov restored the user/arazabishov/fix-split-off-edge-case branch April 18, 2024 14:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant