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

.

parent 8c352458
...@@ -44,10 +44,9 @@ import ( ...@@ -44,10 +44,9 @@ import (
"sync" "sync"
"syscall" "syscall"
"golang.org/x/sync/errgroup"
"lab.nexedi.com/kirr/go123/mem" "lab.nexedi.com/kirr/go123/mem"
"lab.nexedi.com/kirr/go123/xerr" "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"
"lab.nexedi.com/kirr/neo/go/zodb/btree" "lab.nexedi.com/kirr/neo/go/zodb/btree"
pickle "github.com/kisielk/og-rek" pickle "github.com/kisielk/og-rek"
...@@ -265,10 +264,10 @@ func (zb *ZBlk1) loadBlkData(ctx context.Context) ([]byte, zodb.Tid, error) { ...@@ -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 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) err := zd.PActivate(ctx)
if err != nil { if err != nil {
return err return err
...@@ -284,7 +283,7 @@ func (zb *ZBlk1) loadBlkData(ctx context.Context) ([]byte, zodb.Tid, error) { ...@@ -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 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) err := b.PActivate(ctx)
if err != nil { if err != nil {
return err return err
...@@ -305,8 +304,8 @@ func (zb *ZBlk1) loadBlkData(ctx context.Context) ([]byte, zodb.Tid, error) { ...@@ -305,8 +304,8 @@ func (zb *ZBlk1) loadBlkData(ctx context.Context) ([]byte, zodb.Tid, error) {
} }
offset := e.Key() offset := e.Key()
wg.Go(func() error { wg.Go(func(ctx context.Context) error {
return loadZData(offset, zd) return loadZData(ctx, offset, zd)
}) })
} }
...@@ -314,8 +313,8 @@ func (zb *ZBlk1) loadBlkData(ctx context.Context) ([]byte, zodb.Tid, error) { ...@@ -314,8 +313,8 @@ func (zb *ZBlk1) loadBlkData(ctx context.Context) ([]byte, zodb.Tid, error) {
} }
// loadBTree spawns loading of all BTree children. // loadBTree spawns loading of all BTree children.
var loadBTree func(t *btree.IOBTree) error var loadBTree func(ctx context.Context, t *btree.IOBTree) error
loadBTree = func(t *btree.IOBTree) error { loadBTree = func(ctx context.Context, t *btree.IOBTree) error {
err := t.PActivate(ctx) err := t.PActivate(ctx)
if err != nil { if err != nil {
return err return err
...@@ -327,13 +326,13 @@ func (zb *ZBlk1) loadBlkData(ctx context.Context) ([]byte, zodb.Tid, error) { ...@@ -327,13 +326,13 @@ func (zb *ZBlk1) loadBlkData(ctx context.Context) ([]byte, zodb.Tid, error) {
for _, e := range t.Entryv() { for _, e := range t.Entryv() {
switch child := e.Child().(type) { switch child := e.Child().(type) {
case *btree.IOBTree: case *btree.IOBTree:
wg.Go(func() error { wg.Go(func(ctx context.Context) error {
return loadBTree(child) return loadBTree(ctx, child)
}) })
case *btree.IOBucket: case *btree.IOBucket:
wg.Go(func() error { wg.Go(func(ctx context.Context) error {
return loadBucket(child) return loadBucket(ctx, child)
}) })
default: default:
...@@ -344,8 +343,8 @@ func (zb *ZBlk1) loadBlkData(ctx context.Context) ([]byte, zodb.Tid, error) { ...@@ -344,8 +343,8 @@ func (zb *ZBlk1) loadBlkData(ctx context.Context) ([]byte, zodb.Tid, error) {
return nil return nil
} }
wg.Go(func() error { wg.Go(func(ctx context.Context) error {
return loadBTree(zb.chunktab) return loadBTree(ctx, zb.chunktab)
}) })
err = wg.Wait() 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