-
Notifications
You must be signed in to change notification settings - Fork 46
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add carv2.WrapV1 based on io interfaces #136
Conversation
This requires index.Generate to work on io.ReadSeeker, which is a good idea anyway, as it just needs to read and seek. The main advantage of ReaderAt is that it allows concurrent reads, but index generation is sequential by nature. Plus, it only needs seeking to skip blocks; it doesn't need random access to the carv1. Fixes #129.
FYI @raulk @willscott I ended up not touching any of the APIs taking io.ReaderAt, except for index.Generate. Its implementation gets a bit easier, and allows for WrapV1 to exist without hackery (such as implementing an io.ReaderAt on top of a io.ReadSeeker...). |
Also FYI @masih this removes a couple of uses of OffsetReader, which I think is a good thing - the fewer io layers we have, the better. |
Also, the change of API in index.Generate just works with the rest of the codebase, because CarV1Reader already implements ReadSeeker, too :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice 🍻
Accommodate to the `index.Generate` signature change, done in #136. Insead of implementng a new reader that converts `io.ReaderAt` to `io.ReadSeaker`, make `internalio.OffsetReader` partially implement `Seek`. The "partial" refers to inability to satisfy `Seek` calls with `io.SeekEnd` whence since the point of `internalio.OffsetReader` is that it needs not to know the total size of a file, i.e. cannot know its end. Instead, it panics if `Seek` is called with whence `io.SeekEnd`. None of this matterns much since it is all placed under internal APIs.
Accommodate to the `index.Generate` signature change, done in #136. Insead of implementng a new reader that converts `io.ReaderAt` to `io.ReadSeaker`, make `internalio.OffsetReader` partially implement `Seek`. The "partial" refers to inability to satisfy `Seek` calls with `io.SeekEnd` whence since the point of `internalio.OffsetReader` is that it needs not to know the total size of a file, i.e. cannot know its end. Instead, it panics if `Seek` is called with whence `io.SeekEnd`. None of this matterns much since it is all placed under internal APIs.
(see commit message)