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

Function apply_dense_rank

nodedb-query/src/window/ranking.rs:45–67  ·  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

43}
44
45pub(super) fn apply_dense_rank(
46 rows: &mut [(String, serde_json::Value)],
47 indices: &[usize],
48 alias: &str,
49 order_by: &[(SqlExpr, bool)],
50) {
51 if indices.is_empty() {
52 return;
53 }
54 let mut current_rank = 1;
55 set_window_col(&mut rows[indices[0]].1, alias, serde_json::json!(1));
56
57 for pos in 1..indices.len() {
58 if !order_keys_equal(rows, indices[pos - 1], indices[pos], order_by) {
59 current_rank += 1;
60 }
61 set_window_col(
62 &mut rows[indices[pos]].1,
63 alias,
64 serde_json::json!(current_rank),
65 );
66 }
67}
68
69pub(super) fn apply_ntile(
70 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