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

Function calculate_path

src/models/utils.rs:13–24  ·  view source on GitHub ↗

Calculates the path from `current_dim_index` to `target_dim_index`. Decomposes the difference into powers of 4 and returns the indices.

(target_dim_index: u32, current_dim_index: u32)

Source from the content-addressed store, hash-verified

11/// Calculates the path from `current_dim_index` to `target_dim_index`.
12/// Decomposes the difference into powers of 4 and returns the indices.
13pub fn calculate_path(target_dim_index: u32, current_dim_index: u32) -> Vec<u8> {
14 let mut path = Vec::new();
15 let mut remaining = target_dim_index - current_dim_index;
16
17 while remaining > 0 {
18 let (child_index, pow_4) = largest_power_of_4_below(remaining);
19 path.push(child_index);
20 remaining -= pow_4;
21 }
22
23 path
24}

Callers 12

insertMethod · 0.85
deleteMethod · 0.85
get_latestMethod · 0.85
get_versionedMethod · 0.85
pushMethod · 0.85
getMethod · 0.85
find_nodeMethod · 0.85
insertMethod · 0.85
find_nodeMethod · 0.85
insertMethod · 0.85
find_nodeMethod · 0.85
insertMethod · 0.85

Calls 2

largest_power_of_4_belowFunction · 0.70
pushMethod · 0.45

Tested by

no test coverage detected