pub struct SemanticEmbeddingPool {
pub buffers: Vec<EmbeddingBuffer>,
pub config: PoolConfig,
pub stats: PoolStats,
/* private fields */
}Expand description
Managed pool of pre-allocated, fixed-dimension embedding buffers.
Callers acquire a buffer id, write data into it, read from it, and
release it back to the pool. Releasing zeroes the buffer data and increments
the buffer’s generation counter so stale ids are detectable.
Fields§
§buffers: Vec<EmbeddingBuffer>All buffers managed by this pool (both in-use and free).
config: PoolConfigPool configuration.
stats: PoolStatsAccumulated runtime statistics.
Implementations§
Source§impl SemanticEmbeddingPool
impl SemanticEmbeddingPool
Sourcepub fn new(config: PoolConfig) -> Self
pub fn new(config: PoolConfig) -> Self
Create a new pool, pre-allocating config.initial_capacity zeroed buffers.
Sourcepub fn acquire(&mut self) -> Option<u64>
pub fn acquire(&mut self) -> Option<u64>
Acquire a free buffer, allocating a new one if necessary.
Returns Some(buffer_id) on success, or None when the pool is at
max_capacity and every buffer is already in use.
Sourcepub fn write(&mut self, buffer_id: u64, data: &[f32]) -> bool
pub fn write(&mut self, buffer_id: u64, data: &[f32]) -> bool
Write data into the buffer identified by buffer_id.
Returns false when:
- No buffer with
buffer_idexists. - The buffer is not currently in use.
data.len()does not match the pool’s embedding dimension.
Sourcepub fn read(&self, buffer_id: u64) -> Option<&[f32]>
pub fn read(&self, buffer_id: u64) -> Option<&[f32]>
Read the data slice from an in-use buffer.
Returns None when the buffer is not found or is not currently in use.
Auto Trait Implementations§
impl Freeze for SemanticEmbeddingPool
impl RefUnwindSafe for SemanticEmbeddingPool
impl Send for SemanticEmbeddingPool
impl Sync for SemanticEmbeddingPool
impl Unpin for SemanticEmbeddingPool
impl UnsafeUnpin for SemanticEmbeddingPool
impl UnwindSafe for SemanticEmbeddingPool
Blanket Implementations§
impl<T> Allocation for T
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.