Bulk load from sorted key-value pairs for 3-5x faster construction. Args: items: Iterable of (key, value) pairs that MUST be sorted by key. capacity: Node capacity (minimum 4). Returns: BPlusTreeMap instance with loaded data. Raises:
(
cls, items, capacity: int = DEFAULT_CAPACITY
)
| 77 | |
| 78 | @classmethod |
| 79 | def from_sorted_items( |
| 80 | cls, items, capacity: int = DEFAULT_CAPACITY |
| 81 | ) -> "BPlusTreeMap": |
| 82 | """Bulk load from sorted key-value pairs for 3-5x faster construction. |
| 83 | |
| 84 | Args: |
| 85 | items: Iterable of (key, value) pairs that MUST be sorted by key. |
| 86 | capacity: Node capacity (minimum 4). |
| 87 | |
| 88 | Returns: |
| 89 | BPlusTreeMap instance with loaded data. |
| 90 | |
| 91 | Raises: |
| 92 | InvalidCapacityError: If capacity is less than 4. |
| 93 | """ |
| 94 | tree = cls(capacity=capacity) |
| 95 | tree._bulk_load_sorted(items) |
| 96 | return tree |
| 97 | |
| 98 | def _bulk_load_sorted(self, items) -> None: |
| 99 | """Internal bulk loading implementation for sorted items.""" |