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

Function build_group_key_indexed

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

Build a GROUP BY key using a pre-built `FieldIndex` for O(1) lookups.

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

Source from the content-addressed store, hash-verified

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 {
36 if group_fields.is_empty() {
37 return "__all__".to_string();
38 }
39
40 let mut key_buf = String::new();
41 key_buf.push('[');
42 for (i, field) in group_fields.iter().enumerate() {
43 if i > 0 {
44 key_buf.push(',');
45 }
46 let range = idx.get(field);
47 append_field_value_range(&mut key_buf, doc, range);
48 }
49 key_buf.push(']');
50 key_buf
51}
52
53/// Append a single field's value to the key buffer as a JSON literal.
54fn append_field_value(buf: &mut String, doc: &[u8], field: &str) {

Callers 1

execute_aggregateMethod · 0.85

Calls 6

append_field_value_rangeFunction · 0.85
to_stringMethod · 0.80
is_emptyMethod · 0.45
pushMethod · 0.45
iterMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected