Skip to content

Fix BTree for balance splitting. #5

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

TKONIY
Copy link

@TKONIY TKONIY commented Mar 11, 2023

A balance splitting for a full node with m max entries is as follows:

For example the Inner Node, m must be even (to support preemptive splitting), thus the number of the key is count=m-1, while count is odd. The node is split into two nodes each with floor(count/2) node, and the center node is inserted into the parent.

In previous implementation, the inner node is split into nodes with count-ceil(count/2)-1 and ceil(count/2) keys. For example, when m=4, the full inner node with 3 keys is split into nodes with 3-ceil(3/2)-1 = 0 and ceil(3/2) = 2 keys. Which is imbalance and conflict with to BTree's definition, that "Every internal node has at least ⌈m/2⌉ children".

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.

1 participant