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

Function apply_v_ntile

nodedb-query/src/window/value_eval.rs:290–306  ·  view source on GitHub ↗
(
    rows: &mut [Vec<Value>],
    indices: &[usize],
    spec: &WindowFuncSpec,
    write_col: usize,
)

Source from the content-addressed store, hash-verified

288}
289
290fn apply_v_ntile(
291 rows: &mut [Vec<Value>],
292 indices: &[usize],
293 spec: &WindowFuncSpec,
294 write_col: usize,
295) -> Result<(), WindowError> {
296 let n = usize_arg(spec, 0, 1).max(1);
297 let total = indices.len();
298 if total == 0 {
299 return Ok(());
300 }
301 for (pos, &i) in indices.iter().enumerate() {
302 let bucket = (pos * n / total) + 1;
303 set_cell(rows, i, write_col, Value::Integer(bucket as i64));
304 }
305 Ok(())
306}
307
308fn apply_v_percent_rank(
309 rows: &mut [Vec<Value>],

Callers 1

Calls 4

set_cellFunction · 0.85
usize_argFunction · 0.70
lenMethod · 0.45
iterMethod · 0.45

Tested by

no test coverage detected