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

Method encode_batch

nodedb-vector/src/quantize/pq.rs:140–148  ·  view source on GitHub ↗

Batch encode all vectors into a contiguous byte array. Charges `m * vectors.len()` bytes to the governor budget (if set) before allocating the output buffer. The guard is released at the end of this call — the buffer itself remains alive.

(&self, vectors: &[&[f32]])

Source from the content-addressed store, hash-verified

138 /// before allocating the output buffer. The guard is released at
139 /// the end of this call — the buffer itself remains alive.
140 pub fn encode_batch(&self, vectors: &[&[f32]]) -> Result<Vec<u8>, VectorError> {
141 let capacity = self.m * vectors.len();
142 let _g = try_reserve_or_skip(&self.governor, capacity * size_of::<u8>())?;
143 let mut out = Vec::with_capacity(capacity);
144 for v in vectors {
145 out.extend(self.encode(v));
146 }
147 Ok(out)
148 }
149
150 /// Build an asymmetric distance table for a query vector.
151 ///

Callers 3

build_pq_for_indexMethod · 0.80
batch_encodeFunction · 0.80
unique_centroid_countFunction · 0.80

Calls 4

try_reserve_or_skipFunction · 0.85
lenMethod · 0.45
extendMethod · 0.45
encodeMethod · 0.45

Tested by 2

batch_encodeFunction · 0.64
unique_centroid_countFunction · 0.64