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

Method split

python/bplustree/bplus_tree.py:778–798  ·  view source on GitHub ↗

Split this leaf node, returning the new right node

(self)

Source from the content-addressed store, hash-verified

776 return None
777
778 def split(self) -> "LeafNode":
779 """Split this leaf node, returning the new right node"""
780 # Find the midpoint
781 mid = len(self.keys) // 2
782
783 # Create new leaf for right half
784 new_leaf = LeafNode(self.capacity)
785
786 # Move right half of keys/values to new leaf
787 new_leaf.keys = self.keys[mid:]
788 new_leaf.values = self.values[mid:]
789
790 # Keep left half in this leaf
791 self.keys = self.keys[:mid]
792 self.values = self.values[:mid]
793
794 # Update linked list pointers
795 new_leaf.next = self.next
796 self.next = new_leaf
797
798 return new_leaf
799
800 def split_and_insert(self, key: Any, value: Any) -> Tuple["LeafNode", Any]:
801 """Split leaf and insert key-value, returning (new_leaf, separator_key)"""

Callers 2

split_and_insertMethod · 0.95
get_versionFunction · 0.45

Calls 1

LeafNodeClass · 0.70

Tested by

no test coverage detected