pub struct EpisodeTracker { /* private fields */ }Expand description
Tracks episode boundaries within a ring buffer.
Maintains a list of EpisodeMeta entries, invalidating episodes
whose data has been overwritten by the ring buffer’s write pointer.
Provides efficient sampling of contiguous windows for sequence models.
Implementations§
Source§impl EpisodeTracker
impl EpisodeTracker
Sourcepub fn new(ring_capacity: usize) -> Self
pub fn new(ring_capacity: usize) -> Self
Create a new episode tracker for a ring buffer with the given capacity.
Sourcepub fn notify_push(&mut self, write_pos: usize, done: bool)
pub fn notify_push(&mut self, write_pos: usize, done: bool)
Record a push at write_pos. If done, the current episode is finalized.
Sourcepub fn invalidate_overwritten(&mut self, write_pos: usize, count: usize)
pub fn invalidate_overwritten(&mut self, write_pos: usize, count: usize)
Remove any episodes whose transitions have been overwritten.
Called when the ring buffer wraps. An episode is invalidated if any
of its positions overlap with the region [write_pos, write_pos + count)
modulo the ring capacity.
Sourcepub fn num_complete_episodes(&self) -> usize
pub fn num_complete_episodes(&self) -> usize
Number of complete episodes currently tracked.
Sourcepub fn episodes(&self) -> &[EpisodeMeta]
pub fn episodes(&self) -> &[EpisodeMeta]
All currently tracked episodes (complete and in-progress).
Sourcepub fn eligible_episodes(&self, min_length: usize) -> Vec<usize>
pub fn eligible_episodes(&self, min_length: usize) -> Vec<usize>
Indices of episodes long enough for a given sequence length.
Sourcepub fn sample_windows(
&self,
batch_size: usize,
seq_len: usize,
seed: u64,
) -> Result<Vec<EpisodeWindow>, RloxError>
pub fn sample_windows( &self, batch_size: usize, seq_len: usize, seed: u64, ) -> Result<Vec<EpisodeWindow>, RloxError>
Sample batch_size windows of seq_len consecutive transitions,
each entirely within a single complete episode.
Uses ChaCha8Rng seeded with seed.
Trait Implementations§
Source§impl Debug for EpisodeTracker
impl Debug for EpisodeTracker
Source§impl EpisodeAware for EpisodeTracker
impl EpisodeAware for EpisodeTracker
Source§fn notify_push(&mut self, write_pos: usize, done: bool)
fn notify_push(&mut self, write_pos: usize, done: bool)
write_pos with done flag.Source§fn invalidate_overwritten(&mut self, write_pos: usize, count: usize)
fn invalidate_overwritten(&mut self, write_pos: usize, count: usize)
Source§fn num_complete_episodes(&self) -> usize
fn num_complete_episodes(&self) -> usize
Auto Trait Implementations§
impl Freeze for EpisodeTracker
impl RefUnwindSafe for EpisodeTracker
impl Send for EpisodeTracker
impl Sync for EpisodeTracker
impl Unpin for EpisodeTracker
impl UnwindSafe for EpisodeTracker
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
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 more