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

Function choose_best_split_internal

nodedb-spatial/src/rtree/split.rs:184–204  ·  view source on GitHub ↗
(children: &[ChildRef], min_fill: usize)

Source from the content-addressed store, hash-verified

182}
183
184fn choose_best_split_internal(children: &[ChildRef], min_fill: usize) -> usize {
185 let mut best_k = min_fill;
186 let mut best_overlap = f64::INFINITY;
187 let mut best_area = f64::INFINITY;
188 for k in min_fill..=(children.len() - min_fill) {
189 let left = children[..k]
190 .iter()
191 .fold(children[0].bbox, |a, c| a.union(&c.bbox));
192 let right = children[k..]
193 .iter()
194 .fold(children[k].bbox, |a, c| a.union(&c.bbox));
195 let overlap = left.overlap_area(&right);
196 let area = left.area() + right.area();
197 if overlap < best_overlap || (overlap == best_overlap && area < best_area) {
198 best_overlap = overlap;
199 best_area = area;
200 best_k = k;
201 }
202 }
203 best_k
204}
205
206fn sort_entries_by_axis(entries: &mut [RTreeEntry], axis: usize) {
207 entries.sort_by(|a, b| {

Callers 1

split_internal_childrenFunction · 0.85

Calls 6

foldMethod · 0.80
overlap_areaMethod · 0.80
areaMethod · 0.80
lenMethod · 0.45
iterMethod · 0.45
unionMethod · 0.45

Tested by

no test coverage detected