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

Function encode_payload

nodedb-vector/src/rerank/codecs/bbq.rs:29–37  ·  view source on GitHub ↗
(query_norm: f32, centered: &[f32])

Source from the content-addressed store, hash-verified

27// ── Payload helpers ───────────────────────────────────────────────────────────
28
29fn encode_payload(query_norm: f32, centered: &[f32]) -> Vec<u8> {
30 // Layout: 4 bytes alpha (query_norm f32 LE) || dim * 4 bytes centered f32 LE
31 let mut buf = Vec::with_capacity(4 + centered.len() * 4);
32 buf.extend_from_slice(&query_norm.to_le_bytes());
33 for &x in centered {
34 buf.extend_from_slice(&x.to_le_bytes());
35 }
36 buf
37}
38
39fn decode_payload(payload: &[u8], dim: usize) -> Result<(f32, Vec<f32>), RerankError> {
40 let expected = 4 + dim * 4;

Callers 1

prepare_queryMethod · 0.70

Calls 1

lenMethod · 0.45

Tested by

no test coverage detected