-
Notifications
You must be signed in to change notification settings - Fork 10
Avoid loading all pins into memory during migration #5
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -219,13 +219,15 @@ func walkItems(ctx context.Context, dag ipld.DAGService, n *merkledag.ProtoNode, | |
// readHdr guarantees fanout is a safe value | ||
fanout := hdr.GetFanout() | ||
for i, l := range n.Links()[fanout:] { | ||
if err := fn(i, l); err != nil { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why remove the shadow here (and below)? it's fine since we never return There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I thought shadowing However, I can also see the other side of that, that shadowing guarantees that the variable in the outer scope is not overwritten. I generally tend to avoid shadowing as a general pattern since I think more bugs result from shadowing as opposed to not shadowing. |
||
if err = fn(i, l); err != nil { | ||
return err | ||
} | ||
} | ||
for _, l := range n.Links()[:fanout] { | ||
c := l.Cid | ||
children(c) | ||
if children != nil { | ||
children(c) | ||
} | ||
if c.Equals(emptyKey) { | ||
continue | ||
} | ||
|
@@ -239,7 +241,7 @@ func walkItems(ctx context.Context, dag ipld.DAGService, n *merkledag.ProtoNode, | |
return merkledag.ErrNotProtobuf | ||
} | ||
|
||
if err := walkItems(ctx, dag, stpb, fn, children); err != nil { | ||
if err = walkItems(ctx, dag, stpb, fn, children); err != nil { | ||
return err | ||
} | ||
} | ||
|
@@ -277,6 +279,33 @@ func loadSet(ctx context.Context, dag ipld.DAGService, root *merkledag.ProtoNode | |
return res, nil | ||
} | ||
|
||
func loadSetChan(ctx context.Context, dag ipld.DAGService, root *merkledag.ProtoNode, name string, keyChan chan<- cid.Cid) error { | ||
l, err := root.GetNodeLink(name) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
n, err := l.GetNode(ctx, dag) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
pbn, ok := n.(*merkledag.ProtoNode) | ||
if !ok { | ||
return merkledag.ErrNotProtobuf | ||
} | ||
|
||
walk := func(idx int, link *ipld.Link) error { | ||
keyChan <- link.Cid | ||
return nil | ||
} | ||
|
||
if err = walkItems(ctx, dag, pbn, walk, nil); err != nil { | ||
return err | ||
} | ||
return nil | ||
} | ||
|
||
func getCidListIterator(cids []cid.Cid) itemIterator { | ||
return func() (c cid.Cid, ok bool) { | ||
if len(cids) == 0 { | ||
|
Uh oh!
There was an error while loading. Please reload this page.