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

Function build_peer_groups

nodedb-query/src/window/frame.rs:51–61  ·  view source on GitHub ↗

Build a per-row peer-group index array for a partition. Two rows are in the same peer group when they share the same order-by value. The returned vec has the same length as the partition; each element is the zero-based group index of that row.

(order_values: &[serde_json::Value])

Source from the content-addressed store, hash-verified

49/// value. The returned vec has the same length as the partition; each element
50/// is the zero-based group index of that row.
51pub(super) fn build_peer_groups(order_values: &[serde_json::Value]) -> Vec<usize> {
52 let mut groups = Vec::with_capacity(order_values.len());
53 let mut current_group = 0usize;
54 for (i, val) in order_values.iter().enumerate() {
55 if i > 0 && val != &order_values[i - 1] {
56 current_group += 1;
57 }
58 groups.push(current_group);
59 }
60 groups
61}
62
63// ── ROWS ─────────────────────────────────────────────────────────────────────
64

Callers 3

per_row_aggregateFunction · 0.85
build_peer_groups_basicFunction · 0.85

Calls 3

lenMethod · 0.45
iterMethod · 0.45
pushMethod · 0.45

Tested by 2

build_peer_groups_basicFunction · 0.68