-
-
Notifications
You must be signed in to change notification settings - Fork 3k
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
implement ipfs pin update #3846
Conversation
I'll want a solid review of the algorithm here |
f8b0191
to
ecd1a24
Compare
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.
Would be also good to have sharness tests for it.
cmds.StringArg("to-path", true, false, "Path to new object to be pinned."), | ||
}, | ||
Options: []cmds.Option{ | ||
cmds.BoolOption("unpin", "Remove the old pin.").Default(true), |
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.
What is the use case of update with no unpin?
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.
Its if you want to use the optimized pinning functionality and still keep the old pin
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.
Ahh, right, because it will piggy bank on the already pinned hashes.
merkledag/utils/diffenum.go
Outdated
sset := cid.NewSet() | ||
for _, c := range diff { | ||
if c.a == nil { | ||
err := mdag.EnumerateChildrenAsync(ctx, mdag.GetLinksDirect(dserv), c.b, sset.Visit) |
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.
This line is really long
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 is really tho?
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.
aka. too wide for my vim setup.
merkledag/utils/diffenum.go
Outdated
} | ||
|
||
type diffpair struct { | ||
a, b *cid.Cid |
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 would rename it to old, new
. It clears up a lot.
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.
cant use 'new' lol, its a keyword
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.
ouch, annoying
merkledag/utils/diffenum.go
Outdated
a, b *cid.Cid | ||
} | ||
|
||
func getLinkDiff(a, b node.Node) []diffpair { |
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 took me a minute to properly get what this function does but now I understand.
It diffs links as a set, it doesn't matter for it if some link is repeated.
merkledag/utils/diffenum.go
Outdated
return err | ||
} | ||
} else { | ||
err := DiffEnumerate(ctx, dserv, c.a, c.b) |
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.
Are we worried here about too deep recursion? Should it be turned into loop with TODO list instead?
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.
Also coverage shows that this isn't tested at all.
@whyrusleeping I would like to review this but it may take up to week before I can get to it. |
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.
The algo from what I can tell looks solid. I would not use the phrase "edit distance" though as, at least for me, that made understanding what is going on more difficult than it needs to be.
merkledag/utils/diffenum.go
Outdated
type diffpair struct { | ||
bef, aft *cid.Cid | ||
} | ||
|
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.
Although it is fairly easy to figure out, I would add a note on the meaning of bef
and aft
, something along the line of replace bef
with aft
if bef
is nil, than insert aft
.
merkledag/utils/diffenum.go
Outdated
bef, aft *cid.Cid | ||
} | ||
|
||
// getLinkDiff returns a changset (minimum edit distance style) between nodes |
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 was rather confused by what this is doing. From the code it is fairly clear but the phrase "minimum edit distance style" confused me. As someone who wrote a spell checker I was expecting a traditional edit dist algo, and was very confused my the use of the maps. I would probably have had an easier time understanding what is going on if I wasn't trying to reconcile the code with what a traditional string edit dist. algo would be doing.
pin/pin.go
Outdated
// Update updates a recursive pin from one cid to another | ||
// this is more efficient than simply pinning the new one and unpinning the | ||
// old one | ||
Update(context.Context, *cid.Cid, *cid.Cid, bool) error |
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 would name the parameters here. The use of the bool in Update differs from the use in pin and unpin.
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.
Needs a rebase but other then that it LGTM now.
License: MIT Signed-off-by: Jeromy <jeromyj@gmail.com>
License: MIT Signed-off-by: Jeromy <jeromyj@gmail.com>
3d08011
to
f326dd8
Compare
License: MIT Signed-off-by: Jeromy <jeromyj@gmail.com>
f326dd8
to
0d3a86e
Compare
Makes re-pinning a slightly changed dataset much faster
License: MIT
Signed-off-by: Jeromy jeromyj@gmail.com