pub trait ParallelReader {
// Required methods
fn process_parallel<P: ParallelProcessor + Clone + 'static>(
self,
processor: P,
num_threads: usize,
) -> Result<()>;
fn process_parallel_range<P: ParallelProcessor + Clone + 'static>(
self,
processor: P,
num_threads: usize,
range: Range<usize>,
) -> Result<()>;
// Provided method
fn validate_range(
&self,
total_records: usize,
range: &Range<usize>,
) -> Result<()> { ... }
}Expand description
Trait for BINSEQ readers that can process records in parallel
This is implemented by the reader not by the processor.
For the processor, see the ParallelProcessor trait.
Required Methods§
fn process_parallel<P: ParallelProcessor + Clone + 'static>( self, processor: P, num_threads: usize, ) -> Result<()>
Sourcefn process_parallel_range<P: ParallelProcessor + Clone + 'static>(
self,
processor: P,
num_threads: usize,
range: Range<usize>,
) -> Result<()>
fn process_parallel_range<P: ParallelProcessor + Clone + 'static>( self, processor: P, num_threads: usize, range: Range<usize>, ) -> Result<()>
Process records in parallel within a specified range
This method allows parallel processing of a subset of records within the file, defined by a start and end index. The range is distributed across the specified number of threads.
§Arguments
processor- The processor to use for each recordnum_threads- The number of threads to spawnrange- The range of record indices to process
§Returns
Ok(())- If all records were processed successfullyErr(Error)- If an error occurred during processing
Provided Methods§
Sourcefn validate_range(
&self,
total_records: usize,
range: &Range<usize>,
) -> Result<()>
fn validate_range( &self, total_records: usize, range: &Range<usize>, ) -> Result<()>
Validate the specified range for the file.
This method checks if the provided range is valid for the file, ensuring that the start index is less than the end index and both indices are within the bounds of the file.
§Arguments
total_records- The total number of records in the filerange- The range of record indices to validate
§Returns
Ok(())- If the range is validErr(Error)- If the range is invalid
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.
Implementors§
impl ParallelReader for BinseqReader
impl ParallelReader for binseq::bq::MmapReader
Parallel processing implementation for memory-mapped readers