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

Function changes

nodedb/src/control/promql/functions.rs:174–183  ·  view source on GitHub ↗

`changes(v range-vector)` — number of times the value changed.

(samples: &[Sample])

Source from the content-addressed store, hash-verified

172
173/// `changes(v range-vector)` — number of times the value changed.
174pub fn changes(samples: &[Sample]) -> Option<f64> {
175 if samples.len() < 2 {
176 return Some(0.0);
177 }
178 let count = samples
179 .windows(2)
180 .filter(|w| (w[1].value - w[0].value).abs() > f64::EPSILON)
181 .count();
182 Some(count as f64)
183}
184
185/// `resets(v range-vector)` — number of counter resets (value decreases).
186pub fn resets(samples: &[Sample]) -> Option<f64> {

Callers 1

call_range_funcFunction · 0.85

Calls 2

lenMethod · 0.45
countMethod · 0.45

Tested by

no test coverage detected