MCPcopy Create free account
hub / github.com/cosdata/cosdata / find_or_create_node

Method find_or_create_node

src/models/tree_map.rs:296–306  ·  view source on GitHub ↗
(&self, path: &[u8])

Source from the content-addressed store, hash-verified

294 }
295
296 pub fn find_or_create_node(&self, path: &[u8]) -> &Self {
297 let mut current = self;
298 for &idx in path {
299 let new_node_idx = current.node_idx + (1u16 << (idx * 2));
300 let (child, _) = current.children.get_or_insert(idx as usize, || {
301 Box::into_raw(Box::new(Self::new(new_node_idx)))
302 });
303 current = unsafe { &*child };
304 }
305 current
306 }
307
308 pub fn insert(&self, version: VersionNumber, quotient: u64, value: T) {
309 self.quotients.insert(version, quotient, value);

Callers 6

insertMethod · 0.45
deleteMethod · 0.45
get_latestMethod · 0.45
get_versionedMethod · 0.45
pushMethod · 0.45
getMethod · 0.45

Calls 1

get_or_insertMethod · 0.45

Tested by

no test coverage detected