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

Function target_size

nodedb-codec/src/vector_quant/layout.rs:105–110  ·  view source on GitHub ↗

Compute the buffer size (rounded up to a 128-byte multiple) required to hold a [`UnifiedQuantizedVector`] with the given parameters. This is the pre-sizing helper for callers that want to allocate before constructing.

(quant_mode: QuantMode, dim: u16, outlier_count: u32)

Source from the content-addressed store, hash-verified

103/// This is the pre-sizing helper for callers that want to allocate before
104/// constructing.
105pub fn target_size(quant_mode: QuantMode, dim: u16, outlier_count: u32) -> usize {
106 let packed_bits_bytes = packed_bits_len(quant_mode, dim);
107 let outlier_bytes = outlier_count as usize * OUTLIER_ENTRY_BYTES;
108 let raw = core::mem::size_of::<QuantHeader>() + packed_bits_bytes + outlier_bytes;
109 round_up_128(raw)
110}
111
112// ── Internal helpers ────────────────────────────────────────────────────────
113

Callers 1

Calls 2

packed_bits_lenFunction · 0.85
round_up_128Function · 0.85

Tested by 1