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

Function rows_to_msgpack

nodedb/src/engine/graph/pattern/executor/mod.rs:111–128  ·  view source on GitHub ↗

Serialize binding rows to MessagePack for SPSC transport. The Data Plane MUST produce MessagePack so that broadcast merge (`extract_msgpack_elements`) can correctly split and re-merge rows from multiple cores. BindingRow is `HashMap ` — all values are strings, so we write raw msgpack directly.

(rows: &[BindingRow])

Source from the content-addressed store, hash-verified

109/// from multiple cores. BindingRow is `HashMap<String, String>` — all
110/// values are strings, so we write raw msgpack directly.
111pub fn rows_to_msgpack(rows: &[BindingRow]) -> Result<Vec<u8>, crate::Error> {
112 use nodedb_query::msgpack_scan::{write_array_header, write_map_header, write_str};
113
114 // MATCH bindings now carry user-visible node ids directly. The
115 // CSR partition that produced them is tenant-scoped by
116 // construction, so there is no `<tid>:` prefix to strip — what
117 // the user inserted is what the user sees back.
118 let mut buf = Vec::with_capacity(rows.len() * 64);
119 write_array_header(&mut buf, rows.len());
120 for row in rows {
121 write_map_header(&mut buf, row.len());
122 for (k, v) in row {
123 write_str(&mut buf, k);
124 write_str(&mut buf, v);
125 }
126 }
127 Ok(buf)
128}
129
130/// Execute a single MATCH clause.
131pub(super) fn execute_clause(

Callers 2

execute_graph_matchMethod · 0.85
rows_to_msgpack_formatFunction · 0.85

Calls 4

write_array_headerFunction · 0.50
write_map_headerFunction · 0.50
write_strFunction · 0.50
lenMethod · 0.45

Tested by 1

rows_to_msgpack_formatFunction · 0.68