-
Notifications
You must be signed in to change notification settings - Fork 53
decouple the DAG traversal logic from the DAG reader #12
Conversation
With ipfs/go-ipld-format#39 merged this is now unblocked, I'll give it the finishing touches and get it ready for review next week. |
@Stebalien There are some particulars pending but we can start the review process of this PR now, feel free to delegate the review to whomever you see fit. (edit: @warpfork might be the best choice here since he's already familiar with the |
/cc @warpfork |
@Stebalien This doesn't have a high priority but it's part of one of my Q4 OKRs, if @warpfork is busy at the moment is there anyone else who could help with the review? Basically what I need at this point is not an exhaustive review but just a check to see if this PR makes sense or not to help me plan how minor or major it will be the work needed to eventually make it land. |
I'll bring it up at the meeting tomorrow. Could you put it in the notes: ipfs/team-mgmt#674 (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.
Looks good, 1 question.
Thanks for taking a look @magik6k! ❤️ |
@schomatis Is this awaiting further review? |
No, thanks for the ping, I'll act on this during this week (and then I'll probably need a final review). |
Decouple the DAG traversal logic from the `PBDagReader` encapsulating it in the (new) `Walker` structure. Collapse PB and Buffer DAG readers into one (`dagReader`) removing the `bufdagreader.go` and `pbdagreader.go` files, moving all the code to `dagreader.go`. Remove `TestSeekAndReadLarge` and `TestReadAndCancel` which operated directly on the `NodePromise` structure that is now abstracted away in `NavigableIPLDNode`, in the `go-ipld-format` repo, where they should be recreated. License: MIT Signed-off-by: Lucas Molas <[email protected]>
This version writes one node at a time instead of first buffering the entire file contents in a single array (taking up too much memory) before actually writing it.
|
||
// Skip internal nodes, they shouldn't have any file data | ||
// (see the `balanced` package for more details). | ||
if len(node.Links()) > 0 { |
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.
We should probably check for data and return errors / warnings if preset.
}) | ||
|
||
if err == ipld.EndOfDag { | ||
return n, io.EOF |
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.
Looking at impl of bytes.Reader.WriteTo
, error should be nil here - https://golang.org/src/bytes/reader.go?s=3220:3278#L124
// searches in the `Walker` (see `Walker.Seek`). | ||
|
||
case io.SeekEnd: | ||
return dr.Seek(int64(dr.Size())-offset, io.SeekStart) |
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.
return dr.Seek(int64(dr.Size())-offset, io.SeekStart) | |
return dr.Seek(int64(dr.Size())+offset, io.SeekStart) |
This is also a bug in current implementation - https://golang.org/pkg/io/#Seeker - https://golang.org/src/bytes/reader.go?s=2744:2806#L103 - ipfs/kubo#5934
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's always nice when the SLOC goes down but the number of lines in a package goes up.
(I'll defer to @magik6k for an actual review/signoff).
return err | ||
} | ||
|
||
_, err = dr.currentNodeData.Seek(left, io.SeekStart) |
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.
We should probably sanity check to make sure this worked (i.e., we seeked the right amount).
Closed in favor of #60. |
Imported from ipfs/kubo#5257.
Based on #58 (should be merged first).
Fixes #14.
Fixes ipfs/kubo#5255.
Closes ipfs/kubo#5192.
TODO:
go-ipld-format
release with theWalker
WriteTo
method now in this PR, the previous (PBDagReader
) implementation was more performant (this doesn't block the review of the rest of the PR).TestSeekAndReadLarge
andTestReadAndCancel
togo-ipld-format