#chunk #file #process-file #chunking #concurrency

file-chunker

Efficiently process a file in (approximately) equally-sized parts

2 releases

0.1.1 Feb 10, 2022
0.1.0 Feb 9, 2022

#953 in Filesystem

Download history 69/week @ 2023-11-27 37/week @ 2023-12-04 84/week @ 2023-12-11 87/week @ 2023-12-18 12/week @ 2023-12-25 89/week @ 2024-01-01 164/week @ 2024-01-08 77/week @ 2024-01-15 34/week @ 2024-01-22 102/week @ 2024-01-29 66/week @ 2024-02-05 49/week @ 2024-02-12 74/week @ 2024-02-19 123/week @ 2024-02-26 99/week @ 2024-03-04 105/week @ 2024-03-11

409 downloads per month
Used in krapslog

MIT license

17KB
222 lines

file-chunker

This crate provides the FileChunker type, which is useful for efficiently reading a file in (approximately) equally-sized parts.

The original use case was to process a log file in chunks, one thread per chunk, and to guarantee that each chunk ended with a full line of text.

Example

use file_chunker::FileChunker;
let file = std::fs::File::open("/path/to/file").unwrap();
let chunker = FileChunker::new(&file).unwrap();
chunker.chunks(1024, Some('\n'))
    .unwrap()
    .iter()
    .for_each(|chunk| {
        println!("{:?}", chunk);
    });

lib.rs:

This crate provides the FileChunker type, which is useful for efficiently reading a file in (approximately) equally-sized parts.

The original use case was to process a log file in chunks, one thread per chunk, and to guarantee that each chunk ended with a full line of text.

Example

use file_chunker::FileChunker;

let file = std::fs::File::open("/path/to/file").unwrap();
let chunker = FileChunker::new(&file).unwrap();
chunker.chunks(1024, Some('\n'))
    .unwrap()
    .iter()
    .for_each(|chunk| {
        println!("{:?}", chunk);
    });

Dependencies

~290KB