MCPcopy Create free account
hub / github.com/KentBeck/BPlusTree3 / _redistribute_from_left

Method _redistribute_from_left

python/bplustree/bplus_tree.py:325–339  ·  view source on GitHub ↗

Redistribute keys from left sibling to child

(self, parent: "BranchNode", child_index: int)

Source from the content-addressed store, hash-verified

323 self._merge_with_sibling(parent, child_index)
324
325 def _redistribute_from_left(self, parent: "BranchNode", child_index: int) -> None:
326 """Redistribute keys from left sibling to child"""
327 child = parent.children[child_index]
328 left_sibling = parent.children[child_index - 1]
329
330 if child.is_leaf():
331 # Leaf redistribution
332 child.borrow_from_left(left_sibling)
333 # Update separator key in parent
334 parent.keys[child_index - 1] = child.keys[0]
335 else:
336 # Branch redistribution
337 separator_key = parent.keys[child_index - 1]
338 new_separator = child.borrow_from_left(left_sibling, separator_key)
339 parent.keys[child_index - 1] = new_separator
340
341 def _redistribute_from_right(self, parent: "BranchNode", child_index: int) -> None:
342 """Redistribute keys from right sibling to child"""

Callers 1

_handle_underflowMethod · 0.95

Calls 2

is_leafMethod · 0.45
borrow_from_leftMethod · 0.45

Tested by

no test coverage detected