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

Function apply_v_rank

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

Source from the content-addressed store, hash-verified

226}
227
228fn apply_v_rank(
229 rows: &mut [Vec<Value>],
230 indices: &[usize],
231 column_index: &HashMap<String, usize>,
232 spec: &WindowFuncSpec,
233 write_col: usize,
234) {
235 if indices.is_empty() {
236 return;
237 }
238 let mut current_rank = 1usize;
239 set_cell(rows, indices[0], write_col, Value::Integer(1));
240 for pos in 1..indices.len() {
241 if !order_keys_equal_v(
242 rows,
243 indices[pos - 1],
244 indices[pos],
245 column_index,
246 &spec.order_by,
247 ) {
248 current_rank = pos + 1;
249 }
250 set_cell(
251 rows,
252 indices[pos],
253 write_col,
254 Value::Integer(current_rank as i64),
255 );
256 }
257}
258
259fn apply_v_dense_rank(
260 rows: &mut [Vec<Value>],

Callers 1

Calls 4

set_cellFunction · 0.85
order_keys_equal_vFunction · 0.85
is_emptyMethod · 0.45
lenMethod · 0.45

Tested by

no test coverage detected