Commit eaa44e39 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent c187f0ba
......@@ -124,6 +124,8 @@ func (zb *zBlk1State) PySetState(pystate interface{}) error {
}
func (zb *ZBlk1) LoadBlkData(ctx context.Context) ([]byte, error) {
// XXX errctx
// // empty .chunktab -> ø
// ev := zb.chunktab.Entryv()
// if len(ev) == 0 {
......@@ -140,6 +142,22 @@ func (zb *ZBlk1) LoadBlkData(ctx context.Context) ([]byte, error) {
wg, ctx := errgroup.WithContext(ctx)
// loadZData loads 1 ZData object into chunktab and leaves it activated.
loadZData := func(offset int64, zd *ZData) error {
err := zd.PActivate(ctx)
if err != nil {
return err
}
// no PDeactivate
mu.Lock()
defer mu.Unlock()
// XXX check dup keys?
chunktab[offset] = zd
return nil
}
// loadBucket loads all ZData objects from leaf BTree bucket.
loadBucket := func(b *btree.Bucket) error {
err := b.PActivate(ctx)
......@@ -152,6 +170,16 @@ func (zb *ZBlk1) LoadBlkData(ctx context.Context) ([]byte, error) {
// XXX off < 0 !ok
// XXX off + len > blksize !ok
for _, e := range b.Entryv() {
zd, ok := e.Value().(*ZData)
if !ok {
return fmt.Errorf("!ZData (%T)", e.Value()) // XXX
}
wg.Go(func() error {
return loadZData(int64(e.Key()), zd) // XXX cast
})
}
return nil
}
......@@ -186,8 +214,20 @@ func (zb *ZBlk1) LoadBlkData(ctx context.Context) ([]byte, error) {
return nil
}
loadBTree(zb.chunktab) // XXX err
wg.Go(func() error {
return loadBTree(zb.chunktab)
})
err := wg.Wait()
// deactivate all loaded ZData objects in chunktab
for _, zd := range chunktab {
zd.PDeactivate()
}
if err != nil {
// XXX
}
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