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

Method pick

nodedb-vector/src/matryoshka.rs:48–59  ·  view source on GitHub ↗

Pick the largest supported dim ≤ `requested`. Returns the full dim (last in the list) when `requested` is `None`. Returns the smallest available dim when `requested` is smaller than all supported dims.

(&self, requested: Option<u32>)

Source from the content-addressed store, hash-verified

46 /// Returns the smallest available dim when `requested` is smaller than
47 /// all supported dims.
48 pub fn pick(&self, requested: Option<u32>) -> u32 {
49 let Some(req) = requested else {
50 return *self.truncation_dims.last().copied().get_or_insert(0);
51 };
52 // Find largest dim that is ≤ req.
53 self.truncation_dims
54 .iter()
55 .rev()
56 .find(|&&d| d <= req)
57 .copied()
58 .unwrap_or_else(|| self.truncation_dims.first().copied().unwrap_or(req))
59 }
60
61 /// Return `true` if `dim` is one of the supported truncation dims.
62 pub fn is_valid(&self, dim: u32) -> bool {

Callers

nothing calls this directly

Calls 4

firstMethod · 0.80
lastMethod · 0.45
findMethod · 0.45
iterMethod · 0.45

Tested by

no test coverage detected