-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Add reader option to local content reader at #7414
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
Conversation
Allows optimized copying from a local content file into another file. Signed-off-by: Derek McGowan <[email protected]>
|
Skipping CI for Draft Pull Request. |
| func NewReader(ra ReaderAt) io.Reader { | ||
| rd := io.NewSectionReader(ra, 0, ra.Size()) | ||
| return rd | ||
| if rd, ok := ra.(reader); ok { |
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.
| if rd, ok := ra.(reader); ok { | |
| if rd, ok := ra.(io.Reader); ok { |
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.
io.Reader doesn't help here since the instance cannot be type asserted to *os.File. It needs a new reader instance and ideally carrying the size data, which *LimitedReader does.
estesp
left a comment
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.
LGTM
kzys
left a comment
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.
Allows optimized copying from a local content file into another file.
Using a
*LimitedReaderallows for an optimized copy file range to be performed when copying into a*os.Fileon Linux. Currently our custom type or use of section reader hide the source*os.File.See https://cs.opensource.google/go/go/+/refs/tags/go1.19.1:src/os/readfrom_linux.go;drc=f1b7b2fc52947711b8e78f7078c9e0bda35320d3;l=14