MCPcopy Create free account
hub / github.com/carsonpo/haystackdb / new

Method new

src/structures/mmap_tree.rs:23–41  ·  view source on GitHub ↗
(path: PathBuf)

Source from the content-addressed store, hash-verified

21 V: Clone + TreeSerialization + TreeDeserialization,
22{
23 pub fn new(path: PathBuf) -> io::Result<Self> {
24 let mut storage_manager = StorageManager::<K, V>::new(path)?;
25
26 // println!("INIT Used space: {}", storage_manager.used_space);
27
28 if storage_manager.used_space() == 0 {
29 let root_offset: usize;
30 let mut root = Node::new_leaf(0);
31 root.is_root = true;
32 root_offset = storage_manager.store_node(&mut root)?;
33 storage_manager.set_root_offset(root_offset);
34 // println!("Initialized from scratch with Root offset: {}", root_offset);
35 }
36
37 Ok(Tree {
38 storage_manager,
39 b: 32,
40 })
41 }
42
43 pub fn insert(&mut self, key: K, value: V) -> Result<(), io::Error> {
44 // println!("Inserting key: {}, value: {}", key, value);

Callers

nothing calls this directly

Calls 3

used_spaceMethod · 0.80
store_nodeMethod · 0.80
set_root_offsetMethod · 0.80

Tested by

no test coverage detected