pub struct DistributedSampler<S> { /* private fields */ }Expand description
A source wrapper that shards samples across distributed ranks.
Only samples where index % world_size == rank are yielded. The source
item’s position within the underlying iterator determines the index.
use tenshift_core::sample::Sample;
use tenshift_core::source::Source;
use tenshift_core::sources::{DistributedSampler, MemorySource};
let source = MemorySource::new("demo", vec![Sample::new(), Sample::new(), Sample::new()]);
let shard = DistributedSampler::new(source, 1, 2).unwrap();
assert_eq!(shard.len_hint(), Some(1));Implementations§
Trait Implementations§
Auto Trait Implementations§
impl<S> Freeze for DistributedSampler<S>where
S: Freeze,
impl<S> RefUnwindSafe for DistributedSampler<S>where
S: RefUnwindSafe,
impl<S> Send for DistributedSampler<S>where
S: Send,
impl<S> Sync for DistributedSampler<S>where
S: Sync,
impl<S> Unpin for DistributedSampler<S>where
S: Unpin,
impl<S> UnsafeUnpin for DistributedSampler<S>where
S: UnsafeUnpin,
impl<S> UnwindSafe for DistributedSampler<S>where
S: UnwindSafe,
Blanket Implementations§
Source§impl<T> AsyncSource for Twhere
T: Source,
impl<T> AsyncSource for Twhere
T: Source,
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