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

Method split_and_insert

python/bplustree/bplus_tree.py:800–810  ·  view source on GitHub ↗

Split leaf and insert key-value, returning (new_leaf, separator_key)

(self, key: Any, value: Any)

Source from the content-addressed store, hash-verified

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)"""
802 new_leaf = self.split()
803
804 # Insert into appropriate leaf
805 if key < new_leaf.keys[0]:
806 self.insert(key, value)
807 else:
808 new_leaf.insert(key, value)
809
810 return new_leaf, new_leaf.keys[0]
811
812 def find_leaf_for_key(self, _key: Any) -> "LeafNode":
813 """Find the leaf node that contains or would contain the given key"""

Callers 1

_insert_into_leafMethod · 0.80

Calls 2

splitMethod · 0.95
insertMethod · 0.95

Tested by

no test coverage detected