Commit 6a1e4f53 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 8c352458
......@@ -44,10 +44,9 @@ import (
"sync"
"syscall"
"golang.org/x/sync/errgroup"
"lab.nexedi.com/kirr/go123/mem"
"lab.nexedi.com/kirr/go123/xerr"
"lab.nexedi.com/kirr/go123/xsync"
"lab.nexedi.com/kirr/neo/go/zodb"
"lab.nexedi.com/kirr/neo/go/zodb/btree"
pickle "github.com/kisielk/og-rek"
......@@ -265,10 +264,10 @@ func (zb *ZBlk1) loadBlkData(ctx context.Context) ([]byte, zodb.Tid, error) {
}()
wg, ctx := errgroup.WithContext(ctx)
wg := xsync.NewWorkGroup(ctx)
// loadZData loads 1 ZData object into chunktab and leaves it activated.
loadZData := func(offset int32, zd *ZData) error {
loadZData := func(ctx context.Context, offset int32, zd *ZData) error {
err := zd.PActivate(ctx)
if err != nil {
return err
......@@ -284,7 +283,7 @@ func (zb *ZBlk1) loadBlkData(ctx context.Context) ([]byte, zodb.Tid, error) {
}
// loadBucket loads all ZData objects from leaf BTree bucket.
loadBucket := func(b *btree.IOBucket) error {
loadBucket := func(ctx context.Context, b *btree.IOBucket) error {
err := b.PActivate(ctx)
if err != nil {
return err
......@@ -305,8 +304,8 @@ func (zb *ZBlk1) loadBlkData(ctx context.Context) ([]byte, zodb.Tid, error) {
}
offset := e.Key()
wg.Go(func() error {
return loadZData(offset, zd)
wg.Go(func(ctx context.Context) error {
return loadZData(ctx, offset, zd)
})
}
......@@ -314,8 +313,8 @@ func (zb *ZBlk1) loadBlkData(ctx context.Context) ([]byte, zodb.Tid, error) {
}
// loadBTree spawns loading of all BTree children.
var loadBTree func(t *btree.IOBTree) error
loadBTree = func(t *btree.IOBTree) error {
var loadBTree func(ctx context.Context, t *btree.IOBTree) error
loadBTree = func(ctx context.Context, t *btree.IOBTree) error {
err := t.PActivate(ctx)
if err != nil {
return err
......@@ -327,13 +326,13 @@ func (zb *ZBlk1) loadBlkData(ctx context.Context) ([]byte, zodb.Tid, error) {
for _, e := range t.Entryv() {
switch child := e.Child().(type) {
case *btree.IOBTree:
wg.Go(func() error {
return loadBTree(child)
wg.Go(func(ctx context.Context) error {
return loadBTree(ctx, child)
})
case *btree.IOBucket:
wg.Go(func() error {
return loadBucket(child)
wg.Go(func(ctx context.Context) error {
return loadBucket(ctx, child)
})
default:
......@@ -344,8 +343,8 @@ func (zb *ZBlk1) loadBlkData(ctx context.Context) ([]byte, zodb.Tid, error) {
return nil
}
wg.Go(func() error {
return loadBTree(zb.chunktab)
wg.Go(func(ctx context.Context) error {
return loadBTree(ctx, zb.chunktab)
})
err = wg.Wait()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment