Skip to main content

TripletSampler

Struct TripletSampler 

Source
pub struct TripletSampler<S: SplitStore + EpochStateStore + SamplerStateStore + 'static> { /* private fields */ }
Expand description

Sampler that draws anchors from a single shared epoch cursor and then selects chunks from those records. Ingestion happens on demand when sampling.

Implementations§

Source§

impl<S: SplitStore + EpochStateStore + SamplerStateStore + 'static> TripletSampler<S>

Source

pub fn new(config: SamplerConfig, split_store: Arc<S>) -> Self

Create a sampler from config and a split-state backend.

Source

pub fn new_with_chunker( config: SamplerConfig, split_store: Arc<S>, chunker: Arc<dyn ChunkingAlgorithm>, ) -> Self

Create a sampler from config with a custom chunking implementation.

Source

pub fn next_pair_batch_for_split( &self, split: SplitLabel, ) -> Result<SampleBatch, SamplerError>

Return an unweighted pair batch for split.

Source

pub fn next_text_batch_for_split( &self, split: SplitLabel, ) -> Result<TextBatch, SamplerError>

Return an unweighted text batch for split.

Source

pub fn next_triplet_batch_for_split( &self, split: SplitLabel, ) -> Result<TripletBatch, SamplerError>

Return an unweighted triplet batch for split.

Source

pub fn next_pair_batch_with_weights_for_split( &self, split: SplitLabel, weights: &HashMap<SourceId, f32>, ) -> Result<SampleBatch, SamplerError>

Return a weighted pair batch for split using per-source weights.

Source

pub fn next_text_batch_with_weights_for_split( &self, split: SplitLabel, weights: &HashMap<SourceId, f32>, ) -> Result<TextBatch, SamplerError>

Return a weighted text batch for split using per-source weights.

Source

pub fn next_triplet_batch_with_weights_for_split( &self, split: SplitLabel, weights: &HashMap<SourceId, f32>, ) -> Result<TripletBatch, SamplerError>

Return a weighted triplet batch for split using per-source weights.

Source

pub fn prefetch_triplet_batches( self: Arc<Self>, split: SplitLabel, capacity: usize, ) -> BatchPrefetcher<TripletBatch>

Spawn a background prefetcher for triplet batches.

Source

pub fn prefetch_triplet_batches_with_weights( self: Arc<Self>, split: SplitLabel, capacity: usize, weights: HashMap<SourceId, f32>, ) -> BatchPrefetcher<TripletBatch>

Spawn a background prefetcher for weighted triplet batches.

Source

pub fn prefetch_pair_batches( self: Arc<Self>, split: SplitLabel, capacity: usize, ) -> BatchPrefetcher<SampleBatch>

Spawn a background prefetcher for pair batches.

Source

pub fn prefetch_pair_batches_with_weights( self: Arc<Self>, split: SplitLabel, capacity: usize, weights: HashMap<SourceId, f32>, ) -> BatchPrefetcher<SampleBatch>

Spawn a background prefetcher for weighted pair batches.

Source

pub fn prefetch_text_batches( self: Arc<Self>, split: SplitLabel, capacity: usize, ) -> BatchPrefetcher<TextBatch>

Spawn a background prefetcher for text batches.

Source

pub fn prefetch_text_batches_with_weights( self: Arc<Self>, split: SplitLabel, capacity: usize, weights: HashMap<SourceId, f32>, ) -> BatchPrefetcher<TextBatch>

Spawn a background prefetcher for weighted text batches.

Source

pub fn text_recipes(&self) -> Vec<TextRecipe>

Return the currently active text recipes.

Source

pub fn register_source( &self, source: Box<dyn DataSource + 'static>, ) -> Result<(), SamplerError>

Register a data source for ingestion and sampling.

Returns an error if the source’s id() matches the reserved __*__ pattern used for internal synthetic/metadata source identifiers.

Source

pub fn set_epoch(&self, epoch: u64) -> Result<(), SamplerError>

Force sampler epoch to epoch (advanced deterministic replay control).

Source

pub fn save_sampler_state( &self, save_to: Option<&Path>, ) -> Result<(), SamplerError>

Persist sampler and split runtime state for restart-resume.

When save_to is Some(path), current persisted runtime state is also mirrored to path when supported by the split-store backend.

Trait Implementations§

Source§

impl<S: SplitStore + EpochStateStore + SamplerStateStore + 'static> Sampler for TripletSampler<S>

Source§

fn next_pair_batch( &self, split: SplitLabel, ) -> Result<SampleBatch, SamplerError>

Returns a batch of pairs. Consumes the shared epoch cursor for anchor selection.
Source§

fn next_pair_batch_with_weights( &self, split: SplitLabel, weights: &HashMap<SourceId, f32>, ) -> Result<SampleBatch, SamplerError>

Returns a batch of pairs with per-call source weights.
Source§

fn next_text_batch(&self, split: SplitLabel) -> Result<TextBatch, SamplerError>

Returns a batch of text samples. Consumes the shared epoch cursor for anchor selection.
Source§

fn next_text_batch_with_weights( &self, split: SplitLabel, weights: &HashMap<SourceId, f32>, ) -> Result<TextBatch, SamplerError>

Returns a batch of text samples with per-call source weights.
Source§

fn next_triplet_batch( &self, split: SplitLabel, ) -> Result<TripletBatch, SamplerError>

Returns a batch of triplets. Consumes the shared epoch cursor for anchor selection.
Source§

fn next_triplet_batch_with_weights( &self, split: SplitLabel, weights: &HashMap<SourceId, f32>, ) -> Result<TripletBatch, SamplerError>

Returns a batch of triplets with per-call source weights.

Auto Trait Implementations§

§

impl<S> !Freeze for TripletSampler<S>

§

impl<S> RefUnwindSafe for TripletSampler<S>

§

impl<S> Send for TripletSampler<S>

§

impl<S> Sync for TripletSampler<S>

§

impl<S> Unpin for TripletSampler<S>

§

impl<S> UnsafeUnpin for TripletSampler<S>

§

impl<S> UnwindSafe for TripletSampler<S>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more