pub struct ChunkedDataProcessor { /* private fields */ }Expand description
Memory-efficient chunked data processor
Processes large datasets in chunks to avoid memory overflow.
§Example
use torsh_cluster::utils::memory_efficient::ChunkedDataProcessor;
use torsh_tensor::Tensor;
let large_data = Tensor::from_vec(
(0..10000).map(|i| i as f32).collect(),
&[1000, 10]
)?;
let processor = ChunkedDataProcessor::new(100); // Process 100 samples at a time
let mut sum = 0.0;
processor.process(&large_data, |chunk| {
// Process each chunk
let chunk_sum: f32 = chunk.iter().sum();
sum += chunk_sum;
Ok(())
})?;Implementations§
Source§impl ChunkedDataProcessor
impl ChunkedDataProcessor
Sourcepub fn process<F>(&self, data: &Tensor, f: F) -> ClusterResult<()>
pub fn process<F>(&self, data: &Tensor, f: F) -> ClusterResult<()>
Process data in chunks
Applies the given function to each chunk of data sequentially.
Sourcepub fn process_parallel<F, R>(
&self,
data: &Tensor,
f: F,
) -> ClusterResult<Vec<R>>
pub fn process_parallel<F, R>( &self, data: &Tensor, f: F, ) -> ClusterResult<Vec<R>>
Process data in parallel chunks
Applies the given function to each chunk in parallel. Results from all chunks are collected and returned.
Auto Trait Implementations§
impl Freeze for ChunkedDataProcessor
impl RefUnwindSafe for ChunkedDataProcessor
impl Send for ChunkedDataProcessor
impl Sync for ChunkedDataProcessor
impl Unpin for ChunkedDataProcessor
impl UnsafeUnpin for ChunkedDataProcessor
impl UnwindSafe for ChunkedDataProcessor
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
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>
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 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>
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