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

Function encode_msgpack_array

nodedb/src/control/server/broadcast.rs:390–409  ·  view source on GitHub ↗
(rows: &[Vec<u8>])

Source from the content-addressed store, hash-verified

388}
389
390fn encode_msgpack_array(rows: &[Vec<u8>]) -> Vec<u8> {
391 let total_data: usize = rows.iter().map(|row| row.len()).sum();
392 let mut out = Vec::with_capacity(total_data + 5);
393
394 let row_count = rows.len();
395 if row_count < 16 {
396 out.push(0x90 | row_count as u8);
397 } else if row_count <= u16::MAX as usize {
398 out.push(0xdc);
399 out.extend_from_slice(&(row_count as u16).to_be_bytes());
400 } else {
401 out.push(0xdd);
402 out.extend_from_slice(&(row_count as u32).to_be_bytes());
403 }
404
405 for row in rows {
406 out.extend_from_slice(row);
407 }
408 out
409}
410
411/// Broadcast a `DocumentOp::Register` plan to **every** Data Plane core
412/// and await an acknowledgement from each core before returning.

Callers 2

broadcast_to_all_coresFunction · 0.70

Calls 4

sumMethod · 0.80
iterMethod · 0.45
lenMethod · 0.45
pushMethod · 0.45

Tested by 1