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

Function apply_rank

nodedb-query/src/window/ranking.rs:21–43  ·  view source on GitHub ↗
(
    rows: &mut [(String, serde_json::Value)],
    indices: &[usize],
    alias: &str,
    order_by: &[(SqlExpr, bool)],
)

Source from the content-addressed store, hash-verified

19}
20
21pub(super) fn apply_rank(
22 rows: &mut [(String, serde_json::Value)],
23 indices: &[usize],
24 alias: &str,
25 order_by: &[(SqlExpr, bool)],
26) {
27 if indices.is_empty() {
28 return;
29 }
30 let mut current_rank = 1;
31 set_window_col(&mut rows[indices[0]].1, alias, serde_json::json!(1));
32
33 for pos in 1..indices.len() {
34 if !order_keys_equal(rows, indices[pos - 1], indices[pos], order_by) {
35 current_rank = pos + 1;
36 }
37 set_window_col(
38 &mut rows[indices[pos]].1,
39 alias,
40 serde_json::json!(current_rank),
41 );
42 }
43}
44
45pub(super) fn apply_dense_rank(
46 rows: &mut [(String, serde_json::Value)],

Callers 1

Calls 4

set_window_colFunction · 0.85
order_keys_equalFunction · 0.85
is_emptyMethod · 0.45
lenMethod · 0.45

Tested by

no test coverage detected