MCPcopy Index your code
hub / github.com/carsonpo/haystackdb / insert

Method insert

src/structures/tree.rs:27–40  ·  view source on GitHub ↗
(&mut self, key: K, value: V)

Source from the content-addressed store, hash-verified

25 }
26
27 pub fn insert(&mut self, key: K, value: V) -> Result<(), io::Error> {
28 let mut root = std::mem::replace(&mut self.root, Box::new(Node::new_leaf()));
29 if self.is_node_full(&root)? {
30 let mut new_root = Node::new_internal();
31 let (median, sibling) = root.split()?;
32 new_root.keys.push(median);
33 new_root.children.push(root);
34 new_root.children.push(Box::new(sibling));
35 root = Box::new(new_root);
36 }
37 self.insert_non_full(&mut *root, key, value)?;
38 self.root = root;
39 Ok(())
40 }
41
42 fn insert_non_full(
43 &mut self,

Callers 15

insert_non_fullMethod · 0.45
add_to_commit_listMethod · 0.45
add_to_walMethod · 0.45
batch_add_to_walMethod · 0.45
mark_commit_finishedMethod · 0.45
set_key_valueMethod · 0.45
check_locksMethod · 0.45
test_search_in_leafFunction · 0.45
test_insert_search_leafFunction · 0.45

Calls 4

is_node_fullMethod · 0.80
pushMethod · 0.80
splitMethod · 0.45
insert_non_fullMethod · 0.45

Tested by 9

test_search_in_leafFunction · 0.36
test_insert_search_leafFunction · 0.36
test_complex_insertionsFunction · 0.36
test_batch_insertFunction · 0.36