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])
| 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`. |
| 17 | pub 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. |
| 35 | pub fn build_group_key_indexed(doc: &[u8], group_fields: &[String], idx: &FieldIndex) -> String { |