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

Function build_group_key

nodedb-query/src/msgpack_scan/group_key.rs:17–32  ·  view source on GitHub ↗

Build a GROUP BY key string from raw msgpack bytes. Format: `[val1,val2,...]` where values are formatted as JSON literals. This is compatible with the legacy `sonic_rs::to_string(&key_parts)` format, so the result-construction code can parse it back with `sonic_rs::from_str`.

(doc: &[u8], group_fields: &[String])

Source from the content-addressed store, hash-verified

15/// This is compatible with the legacy `sonic_rs::to_string(&key_parts)` format,
16/// so the result-construction code can parse it back with `sonic_rs::from_str`.
17pub fn build_group_key(doc: &[u8], group_fields: &[String]) -> String {
18 if group_fields.is_empty() {
19 return "__all__".to_string();
20 }
21
22 let mut key_buf = String::new();
23 key_buf.push('[');
24 for (i, field) in group_fields.iter().enumerate() {
25 if i > 0 {
26 key_buf.push(',');
27 }
28 append_field_value(&mut key_buf, doc, field);
29 }
30 key_buf.push(']');
31 key_buf
32}
33
34/// Build a GROUP BY key using a pre-built `FieldIndex` for O(1) lookups.
35pub fn build_group_key_indexed(doc: &[u8], group_fields: &[String], idx: &FieldIndex) -> String {

Callers 9

single_string_fieldFunction · 0.85
single_int_fieldFunction · 0.85
multiple_fieldsFunction · 0.85
missing_field_is_nullFunction · 0.85
empty_group_fieldsFunction · 0.85
null_field_valueFunction · 0.85
float_fieldFunction · 0.85
execute_grouping_setsFunction · 0.85
execute_aggregateMethod · 0.85

Calls 5

append_field_valueFunction · 0.85
to_stringMethod · 0.80
is_emptyMethod · 0.45
pushMethod · 0.45
iterMethod · 0.45

Tested by 7

single_string_fieldFunction · 0.68
single_int_fieldFunction · 0.68
multiple_fieldsFunction · 0.68
missing_field_is_nullFunction · 0.68
empty_group_fieldsFunction · 0.68
null_field_valueFunction · 0.68
float_fieldFunction · 0.68