Commit 5ed9cbc0 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 512d593d
......@@ -25,6 +25,9 @@ import (
"context"
"fmt"
"reflect"
"sync"
"golang.org/x/sync/errgroup"
"lab.nexedi.com/kirr/go123/mem"
"lab.nexedi.com/kirr/neo/go/zodb"
......@@ -121,7 +124,69 @@ func (zb *zBlk1State) PySetState(pystate interface{}) error {
}
func (zb *ZBlk1) LoadBlkData(ctx context.Context) ([]byte, error) {
// XXX empty .chunktab -> ø
// // empty .chunktab -> ø
// ev := zb.chunktab.Entryv()
// if len(ev) == 0 {
// return nil, nil
// }
// get to all ZData objects; activate them and build
//
// {} offset -> ZData
//
// with all ZData being live.
var mu sync.Mutex
chunktab := make(map[int64]*ZData)
wg, ctx := errgroup.WithContext(ctx)
// loadBTree spawns loading of all BTree children.
loadBTree := func(t *btree.BTree) error {
err := t.PActivate(ctx)
if err != nil {
return err
}
defer t.PDeactivate()
for _, e := range t.Entryv() {
switch child := e.Child().(type) {
case *btree.BTree:
wg.Go(func() error {
return loadBtree(child)
})
case *btree.Bucket:
wg.Go(func() error {
return loadBucket(child)
})
default:
panic(0) // XXX
}
}
return nil
}
// loadBucket loads all ZData objects from leaf BTree bucket.
loadBucket := func(b *btree.Bucket) error {
err := b.PActivate(ctx)
if err != nil {
return err
}
defer b.PDeactivate()
// XXX go through all bucket key/v -> chunktab
// XXX off < 0 !ok
// XXX off + len > blksize !ok
return nil
}
loadBTree(zb.chunktab) // XXX err
panic("TODO")
}
......
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