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

Method _bulk_load_sorted

python/bplustree/bplus_tree.py:98–112  ·  view source on GitHub ↗

Internal bulk loading implementation for sorted items.

(self, items)

Source from the content-addressed store, hash-verified

96 return tree
97
98 def _bulk_load_sorted(self, items) -> None:
99 """Internal bulk loading implementation for sorted items."""
100 items_list = list(items)
101 if not items_list:
102 return
103 optimal_batch_size = max(
104 self.capacity * BULK_LOAD_BATCH_MULTIPLIER, MIN_BULK_LOAD_BATCH_SIZE
105 )
106
107 for i in range(0, len(items_list), optimal_batch_size):
108 batch_end = min(i + optimal_batch_size, len(items_list))
109
110 for j in range(i, batch_end):
111 key, value = items_list[j]
112 self._insert_sorted_optimized(key, value)
113
114 def _insert_sorted_optimized(self, key: Any, value: Any) -> None:
115 """Optimized insertion for sorted data - avoids repeated tree traversals.

Callers 1

from_sorted_itemsMethod · 0.80

Calls 1

Tested by

no test coverage detected