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

Function parse_msgpack_rows

nodedb/src/control/server/post_aggregate.rs:77–98  ·  view source on GitHub ↗

Parse a msgpack array payload into individual row slices.

(bytes: &[u8])

Source from the content-addressed store, hash-verified

75
76/// Parse a msgpack array payload into individual row slices.
77fn parse_msgpack_rows(bytes: &[u8]) -> crate::Result<Vec<&[u8]>> {
78 use nodedb_query::msgpack_scan::reader;
79
80 if bytes.is_empty() {
81 return Ok(Vec::new());
82 }
83
84 let (count, mut pos) =
85 reader::array_header(bytes, 0).ok_or_else(|| crate::Error::PlanError {
86 detail: "post-aggregation: invalid msgpack array header".into(),
87 })?;
88
89 let mut rows = Vec::with_capacity(count);
90 for _ in 0..count {
91 let start = pos;
92 pos = reader::skip_value(bytes, pos).ok_or_else(|| crate::Error::PlanError {
93 detail: "post-aggregation: truncated msgpack row".into(),
94 })?;
95 rows.push(&bytes[start..pos]);
96 }
97 Ok(rows)
98}
99
100/// Extract a field value as string from a msgpack map row.
101/// Handles "collection.field" suffix matching.

Callers 1

apply_post_aggregationFunction · 0.85

Calls 4

array_headerFunction · 0.85
skip_valueFunction · 0.85
is_emptyMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected