Skip to content
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

Merged
merged 1 commit into from
Jul 5, 2021
Merged

add carv2.WrapV1 based on io interfaces #136

merged 1 commit into from
Jul 5, 2021

Conversation

mvdan
Copy link
Contributor

@mvdan mvdan commented Jul 5, 2021

(see commit message)

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.
@mvdan mvdan requested a review from masih July 5, 2021 13:05
@mvdan
Copy link
Contributor Author

mvdan commented Jul 5, 2021

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...).

@mvdan
Copy link
Contributor Author

mvdan commented Jul 5, 2021

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.

@mvdan
Copy link
Contributor Author

mvdan commented Jul 5, 2021

Also, the change of API in index.Generate just works with the rest of the codebase, because CarV1Reader already implements ReadSeeker, too :)

Copy link
Member

@masih masih left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice 🍻

@mvdan mvdan merged commit f6309d5 into ipld:wip-v2 Jul 5, 2021
@mvdan mvdan deleted the wip-v2-wrapv1 branch July 5, 2021 17:19
mvdan pushed a commit that referenced this pull request Jul 5, 2021
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.
mvdan pushed a commit that referenced this pull request Jul 16, 2021
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants