kvikio icon indicating copy to clipboard operation
kvikio copied to clipboard

Add `seek` and `tell` to Python `CuFile` object

Open jakirkham opened this issue 11 months ago • 3 comments

To make it easier to drop CuFile objects in where other Python file objects are accepted, it would be nice to have seek and tell methods. This would allow a user to go to a file offset and also check what file offset they are at.

jakirkham avatar Dec 10 '24 23:12 jakirkham

I think it could be a good idea, but it will require some smart chunking under the hood. This is because all of our reads and writes (incl. all of the cuFile API) takes ranges.

madsbk avatar Dec 11 '24 07:12 madsbk

Could we simply store an off_t offset inside the CuFile object that we then simply do some integer math with to determine where to read and write from?

Or is there some existing behavior under-the-hood that would complicate this approach?

jakirkham avatar Dec 11 '24 08:12 jakirkham

Sorry, yes that would work. I was more thinking of using it together with https://github.com/rapidsai/kvikio/issues/577 where stream read and write would not use GDS or parallel IO if we don't do something clever :)

madsbk avatar Dec 11 '24 08:12 madsbk