bbeaupain / nio_uring

High performance I/O library for Java using io_uring under the hood
MIT License
155 stars 11 forks source link

Support for seeking or continued file reading #20

Closed ohpauleez closed 1 month ago

ohpauleez commented 2 months ago

In the current implementation, it appears as though the file offset is always set to 0: https://github.com/bbeaupain/nio_uring/blob/main/src/main/c/liburing_provider.c#L239

I would like to continue reading large files with subsequent reads or seeking to a specific position within a known file and reading a specific number of bytes from that point. What are your thoughts on exposing a queueRead method that takes an offset argument to forward to prep_read?

(I'm happy to take some direction and make contributions)

bbeaupain commented 1 month ago

Great request! I think a good way to do this would be to:

A PR would be awesome if you're up to it! Otherwise I will try to get to this soon.

ohpauleez commented 1 month ago

I'm about to test this, but changes are sitting on this branch: https://github.com/ohpauleez/nio_uring/tree/queue_with_offset

Edit: Tested locally in a project that seeks across large files / datasets. Everything looks correct. Edit2: Included a unit test.

bbeaupain commented 1 month ago

Released on Maven Central as version 0.1.4, thank you for your contribution!