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

Method __setitem__

python/bplustree/bplus_tree.py:141–157  ·  view source on GitHub ↗

Set a key-value pair (dict-like API). Args: key: The key to insert or update. value: The value to associate with the key.

(self, key: Any, value: Any)

Source from the content-addressed store, hash-verified

139 self._rightmost_leaf_cache = current
140
141 def __setitem__(self, key: Any, value: Any) -> None:
142 """Set a key-value pair (dict-like API).
143
144 Args:
145 key: The key to insert or update.
146 value: The value to associate with the key.
147 """
148 result = self._insert_recursive(self.root, key, value)
149
150 # If the root split, create a new root
151 if result is not None:
152 new_node, separator_key = result
153 new_root = BranchNode(self.capacity)
154 new_root.keys.append(separator_key)
155 new_root.children.append(self.root)
156 new_root.children.append(new_node)
157 self.root = new_root
158
159 def _insert_recursive(
160 self, node: "Node", key: Any, value: Any

Callers

nothing calls this directly

Calls 2

_insert_recursiveMethod · 0.95
BranchNodeClass · 0.70

Tested by

no test coverage detected