Skip to content

Commit c560637

Browse files
committed
tinkering with some iterator ideas. #24 #25
1 parent 463c91a commit c560637

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

design.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -453,3 +453,36 @@ impl Writer for IoUringLocal { }
453453
impl GetFilesize for IoUringLocal { }
454454
impl ReadThenWrite for IoUringLocal { }
455455
```
456+
457+
### Trying out some iterator ideas again
458+
459+
```rust
460+
let errors = reader.read(
461+
vec![
462+
// First group: All the source GRIB files which will be collated into
463+
// a set of Zarr chunks.
464+
HashMap::from([
465+
("/foo/grib1.1", ByteRanges(vec![...])),
466+
("/foo/grib1.2", ByteRanges(vec![...])),
467+
]),
468+
// Second group:
469+
HashMap::from([
470+
("/foo/grib2.1", ByteRanges(vec![...])),
471+
("/foo/grib2.1", ByteRanges(vec![...])),
472+
]),
473+
])
474+
// Behind the scenes, `reader.read()` launches a thread which owns its own
475+
// io_uring, and continually keeps that io_uring topped up. All IO operations in group n
476+
// are guaranteed to be completed before LSIO begins IO ops from group n+1.
477+
.iter()
478+
// `map` acts on each byte range.
479+
// TODO: How to allow `map` to run concurrently across all tasks? Maybe:
480+
// - Rayon's par_iter?
481+
// - Return a Future? (Not sure that'll work?)
482+
// - Use Tokio with Rayon?! See https://ryhl.io/blog/async-what-is-blocking/
483+
.map(|(buffer, path, byte_range, group_index)| (decompress(buffer), path, byte_range, group_index))
484+
// `reduce` collects all the buffers for a group, and outputs a vector of
485+
// (output_buffer, output_path, output_byte_range)
486+
.reduce(|buffers_with_paths_and_byte_range| collate(buffers_with_paths_and_byte_range))
487+
// Now compress each
488+
```

0 commit comments

Comments
 (0)