Skip to main content

byte_range_reader

Function byte_range_reader 

Source
pub fn byte_range_reader(
    path: &Path,
    index: usize,
    peers: usize,
) -> Option<(BufReader<File>, u64)>
Expand description

Open a byte-range slice of path for worker index out of peers.

Returns Some((reader, bytes_to_read)) on success. The reader is pre-seeked to the start of the worker’s range (aligned to the next line boundary for non-zero workers). The caller should read up to bytes_to_read bytes, stopping at the first complete line beyond that budget.

Returns None on I/O error (logged to stderr).