pub struct Compactor { /* private fields */ }Expand description
Compactor - applies compaction strategies to segments
Implementations§
Source§impl Compactor
impl Compactor
Sourcepub fn new(strategy: CompactionStrategy) -> Self
pub fn new(strategy: CompactionStrategy) -> Self
Create a new compactor with the given strategy
Sourcepub fn sliding_window(target_tokens: usize, window_size: usize) -> Self
pub fn sliding_window(target_tokens: usize, window_size: usize) -> Self
Create a sliding window compactor
Sourcepub fn strategy(&self) -> &CompactionStrategy
pub fn strategy(&self) -> &CompactionStrategy
Get the strategy
Sourcepub fn compact_truncate(
&self,
segments: &mut Vec<ContextSegment>,
current_tokens: usize,
) -> Result<usize, CompactionError>
pub fn compact_truncate( &self, segments: &mut Vec<ContextSegment>, current_tokens: usize, ) -> Result<usize, CompactionError>
Compact segments using truncation strategy
Removes oldest segments (lowest priority first) until target is reached.
Sourcepub fn compact_sliding_window(
&self,
segments: &mut Vec<ContextSegment>,
) -> Result<usize, CompactionError>
pub fn compact_sliding_window( &self, segments: &mut Vec<ContextSegment>, ) -> Result<usize, CompactionError>
Compact using sliding window strategy
Keeps only the most recent N messages in the history.
Auto Trait Implementations§
impl Freeze for Compactor
impl RefUnwindSafe for Compactor
impl Send for Compactor
impl Sync for Compactor
impl Unpin for Compactor
impl UnsafeUnpin for Compactor
impl UnwindSafe for Compactor
Blanket Implementations§
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
Mutably borrows from an owned value. Read more