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

Method borrow_from_left

python/bplustree/bplus_tree.py:707–715  ·  view source on GitHub ↗

Borrow the rightmost key-value from left sibling

(self, left_sibling: "LeafNode")

Source from the content-addressed store, hash-verified

705 return len(self.keys) > min_keys
706
707 def borrow_from_left(self, left_sibling: "LeafNode") -> None:
708 """Borrow the rightmost key-value from left sibling"""
709 if not left_sibling.can_donate():
710 raise ValueError("Left sibling cannot donate")
711
712 key = left_sibling.keys.pop()
713 value = left_sibling.values.pop()
714 self.keys.insert(0, key)
715 self.values.insert(0, value)
716
717 def borrow_from_right(self, right_sibling: "LeafNode") -> None:
718 """Borrow the leftmost key-value from right sibling"""

Callers 2

Calls 3

can_donateMethod · 0.45
popMethod · 0.45
insertMethod · 0.45

Tested by 1