ParallelReader

Trait ParallelReader 

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

Source

fn process_parallel<P: ParallelProcessor + Clone + 'static>( self, processor: P, num_threads: usize, ) -> Result<()>

Source

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 record
  • num_threads - The number of threads to spawn
  • range - The range of record indices to process
§Returns
  • Ok(()) - If all records were processed successfully
  • Err(Error) - If an error occurred during processing

Provided Methods§

Source

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 file
  • range - The range of record indices to validate
§Returns
  • Ok(()) - If the range is valid
  • Err(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§

Source§

impl ParallelReader for BinseqReader

Source§

impl ParallelReader for binseq::bq::MmapReader

Parallel processing implementation for memory-mapped readers

Source§

impl ParallelReader for binseq::cbq::MmapReader

Source§

impl ParallelReader for binseq::vbq::MmapReader