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

Function apply_lag

nodedb-query/src/window/offset.rs:40–57  ·  view source on GitHub ↗
(
    rows: &mut [(String, serde_json::Value)],
    indices: &[usize],
    spec: &WindowFuncSpec,
)

Source from the content-addressed store, hash-verified

38}
39
40pub(super) fn apply_lag(
41 rows: &mut [(String, serde_json::Value)],
42 indices: &[usize],
43 spec: &WindowFuncSpec,
44) {
45 let field = col_arg(spec, 0);
46 let offset = usize_arg(spec, 1, 1);
47 let default = default_arg(spec, 2);
48
49 for (pos, &i) in indices.iter().enumerate() {
50 let val = if pos >= offset {
51 get_field(&rows[indices[pos - offset]].1, field)
52 } else {
53 default.clone()
54 };
55 set_window_col(&mut rows[i].1, &spec.alias, val);
56 }
57}
58
59pub(super) fn apply_lead(
60 rows: &mut [(String, serde_json::Value)],

Callers 1

Calls 7

col_argFunction · 0.85
default_argFunction · 0.85
get_fieldFunction · 0.85
set_window_colFunction · 0.85
usize_argFunction · 0.70
iterMethod · 0.45
cloneMethod · 0.45

Tested by

no test coverage detected