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

Function insert_entry

nodedb-spatial/src/rtree/insert.rs:28–51  ·  view source on GitHub ↗
(
    tree: &mut RTree,
    entry: RTreeEntry,
    target_level: u32,
    reinserted_levels: &mut Vec<u32>,
)

Source from the content-addressed store, hash-verified

26}
27
28fn insert_entry(
29 tree: &mut RTree,
30 entry: RTreeEntry,
31 target_level: u32,
32 reinserted_levels: &mut Vec<u32>,
33) {
34 let leaf_idx = choose_subtree(tree, tree.root, &entry.bbox, target_level);
35
36 match &mut tree.nodes[leaf_idx].kind {
37 NodeKind::Leaf { entries } => entries.push(entry),
38 NodeKind::Internal { .. } => {
39 // choose_subtree guarantees a leaf at target_level; if we reach
40 // here the tree structure is corrupted. Insert into root as
41 // a fallback rather than crashing a production system.
42 debug_assert!(false, "choose_subtree must return a leaf node");
43 return;
44 }
45 }
46 tree.nodes[leaf_idx].recompute_bbox();
47
48 if tree.nodes[leaf_idx].is_overflow() {
49 treat_overflow(tree, leaf_idx, reinserted_levels);
50 }
51}
52
53/// R*-tree ChooseSubtree: navigate to the best leaf for this entry.
54fn choose_subtree(

Callers 3

insertMethod · 0.85
reinsert_entryMethod · 0.85
treat_overflowFunction · 0.85

Calls 5

choose_subtreeFunction · 0.85
treat_overflowFunction · 0.85
recompute_bboxMethod · 0.80
pushMethod · 0.45
is_overflowMethod · 0.45

Tested by

no test coverage detected