MCPcopy Create free account
hub / github.com/NodeDB-Lab/nodedb / alloc_node

Method alloc_node

nodedb/src/engine/kv/sorted_index/tree.rs:149–166  ·  view source on GitHub ↗
(&mut self, sort_key: Vec<u8>, primary_key: Vec<u8>)

Source from the content-addressed store, hash-verified

147 // ── AVL internal methods ───────────────────────────────────────────
148
149 fn alloc_node(&mut self, sort_key: Vec<u8>, primary_key: Vec<u8>) -> u32 {
150 let node = Node {
151 sort_key,
152 primary_key,
153 left: NULL,
154 right: NULL,
155 height: 1,
156 count: 1,
157 };
158 if let Some(idx) = self.free_list.pop() {
159 self.nodes[idx as usize] = node;
160 idx
161 } else {
162 let idx = self.nodes.len() as u32;
163 self.nodes.push(node);
164 idx
165 }
166 }
167
168 fn free_node(&mut self, idx: u32) {
169 self.free_list.push(idx);

Callers 1

avl_insertMethod · 0.80

Calls 2

lenMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected