Skip to content

Commit

Permalink
tinkering with some iterator ideas. #24 #25
Browse files Browse the repository at this point in the history
  • Loading branch information
JackKelly committed Jan 18, 2024
1 parent 463c91a commit c560637
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions design.md
Original file line number Diff line number Diff line change
Expand Up @@ -453,3 +453,36 @@ impl Writer for IoUringLocal { }
impl GetFilesize for IoUringLocal { }
impl ReadThenWrite for IoUringLocal { }
```

### Trying out some iterator ideas again

```rust
let errors = reader.read(
vec![
// First group: All the source GRIB files which will be collated into
// a set of Zarr chunks.
HashMap::from([
("/foo/grib1.1", ByteRanges(vec![...])),
("/foo/grib1.2", ByteRanges(vec![...])),
]),
// Second group:
HashMap::from([
("/foo/grib2.1", ByteRanges(vec![...])),
("/foo/grib2.1", ByteRanges(vec![...])),
]),
])
// Behind the scenes, `reader.read()` launches a thread which owns its own
// io_uring, and continually keeps that io_uring topped up. All IO operations in group n
// are guaranteed to be completed before LSIO begins IO ops from group n+1.
.iter()
// `map` acts on each byte range.
// TODO: How to allow `map` to run concurrently across all tasks? Maybe:
// - Rayon's par_iter?
// - Return a Future? (Not sure that'll work?)
// - Use Tokio with Rayon?! See https://ryhl.io/blog/async-what-is-blocking/
.map(|(buffer, path, byte_range, group_index)| (decompress(buffer), path, byte_range, group_index))
// `reduce` collects all the buffers for a group, and outputs a vector of
// (output_buffer, output_path, output_byte_range)
.reduce(|buffers_with_paths_and_byte_range| collate(buffers_with_paths_and_byte_range))
// Now compress each
```

0 comments on commit c560637

Please sign in to comment.