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

Function apply_lead

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

Source from the content-addressed store, hash-verified

57}
58
59pub(super) fn apply_lead(
60 rows: &mut [(String, serde_json::Value)],
61 indices: &[usize],
62 spec: &WindowFuncSpec,
63) {
64 let field = col_arg(spec, 0);
65 let offset = usize_arg(spec, 1, 1);
66 let default = default_arg(spec, 2);
67
68 for (pos, &i) in indices.iter().enumerate() {
69 let val = if pos + offset < indices.len() {
70 get_field(&rows[indices[pos + offset]].1, field)
71 } else {
72 default.clone()
73 };
74 set_window_col(&mut rows[i].1, &spec.alias, val);
75 }
76}
77
78/// PostgreSQL `nth_value(expr, n)` — value of `expr` at the n'th row of the
79/// window frame, NULL if the frame doesn't yet contain n rows. Default frame

Callers 1

Calls 8

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

Tested by

no test coverage detected