pub struct SparseBucket {
pub entries: Vec<SparseEntry>,
pub extra: BTreeMap<String, Ipld>,
}Expand description
Per-node bucket of sparse embeddings inside the
Commit.sparse Prolly tree.
One bucket per node. Each bucket holds a sorted
(vocab_id, SparseEmbed) list so a node may carry multiple
sparse embeddings simultaneously - e.g. one BGE-M3 vector plus
one OpenSearch-distill vector for the same chunk text. Lookups
index into the bucket by vocab_id string after the outer Prolly
walk has returned the bucket itself.
Fields§
§entries: Vec<SparseEntry>Entries sorted lexicographically by vocab_id for byte-stable
canonical form. The sort is enforced on every serialize, so
callers may push entries in any order without breaking CID
determinism on the bucket itself.
extra: BTreeMap<String, Ipld>Forward-compat extension carrier. Unknown CBOR fields land here on decode and are emitted verbatim on re-encode, so a future schema bump that adds a per-bucket field stays round-trippable on today’s reader.
Implementations§
Source§impl SparseBucket
impl SparseBucket
Sourcepub const KIND: &'static str = "sparse_bucket"
pub const KIND: &'static str = "sparse_bucket"
On-wire _kind discriminator. Every content-addressed object
in mnem/0.x carries a _kind field as the first canonical key
so a corrupt bucket / wrong-type decode fails fast with an
actionable error instead of silently mis-decoding.
Sourcepub fn get(&self, vocab_id: &str) -> Option<&SparseEmbed>
pub fn get(&self, vocab_id: &str) -> Option<&SparseEmbed>
Look up a sparse embedding by vocab_id string. Returns None when
this bucket has no entry for the requested vocabulary; the caller
typically falls back to lazy compute via the configured sparse
encoder adapter.
Sourcepub fn upsert(&mut self, vocab_id: String, sparse: SparseEmbed)
pub fn upsert(&mut self, vocab_id: String, sparse: SparseEmbed)
Insert or replace an entry by vocab_id. The bucket does not
return the previous value (unlike EmbeddingBucket::upsert)
because SparseEmbed contains Vec<f32> which is not PartialEq
in a meaningful sense for callers here.
Trait Implementations§
Source§impl Clone for SparseBucket
impl Clone for SparseBucket
Source§fn clone(&self) -> SparseBucket
fn clone(&self) -> SparseBucket
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more