-
Notifications
You must be signed in to change notification settings - Fork 5
add AsLargeBytes support to unixfs files #24
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
} | ||
|
||
func (s *shardNodeFile) length() int64 { | ||
// see if we have size specified in the unixfs data. errors fall back to length from links |
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.
I'm slightly worried that, if a node is neither a "data" node nor a "links" node, you'll happily fall back to return 0
- you won't return any error at all, and you might swallow genuinely useful errors such as those from DecodeUnixFSData
.
case io.SeekCurrent: | ||
s.offset += offset | ||
case io.SeekEnd: | ||
s.offset = s.length() + offset |
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.
note that this will recompute the length for every Seek call; consider memoizing the computed length, or even computing it upfront in AsLargeBytes
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.
it should be a fairly cheap single field access in the map, and i don't know if lots of end seeks is a usage pattern that it makes sense to optimize for?
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.
hmm, if you're only using it for end seeks, you may be right that it's likely premature optimization
Supports seeking to relevant subset of a unixfs file.