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

Function encode_batch

nodedb-vector/src/quantize/binary.rs:31–38  ·  view source on GitHub ↗

Batch encode: encode all vectors into contiguous binary representation. Returns `ceil(dim/8) * N` bytes.

(vectors: &[&[f32]], dim: usize)

Source from the content-addressed store, hash-verified

29///
30/// Returns `ceil(dim/8) * N` bytes.
31pub fn encode_batch(vectors: &[&[f32]], dim: usize) -> Vec<u8> {
32 let bytes_per = dim.div_ceil(8);
33 let mut out = Vec::with_capacity(bytes_per * vectors.len());
34 for v in vectors {
35 out.extend(encode(v));
36 }
37 out
38}
39
40/// Hamming distance between two binary-encoded vectors.
41///

Callers 2

batch_encode_layoutFunction · 0.70

Calls 3

encodeFunction · 0.70
lenMethod · 0.45
extendMethod · 0.45

Tested by 2

batch_encode_layoutFunction · 0.56