Commit a50da567 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 37b8404c
......@@ -39,7 +39,6 @@ package main
import (
"context"
"fmt"
"log"
"reflect"
"sort"
"sync"
......@@ -141,13 +140,17 @@ func (zb *zBlk0State) DropState() {
zb.blkdata = ""
}
func (zb *zBlk0State) PyGetState() interface{} {
return zb.blkdata
}
func (zb *zBlk0State) PySetState(pystate interface{}) error {
blkdata, ok := pystate.(string)
if !ok {
return fmt.Errorf("expect str; got %s", typeOf(pystate))
}
log.Printf("ZBlk0.PySetState #%d", len(blkdata))
//log.Printf("ZBlk0.PySetState #%d", len(blkdata))
zb.blkdata = blkdata
return nil
}
......@@ -168,7 +171,7 @@ func (zb *ZBlk0) loadBlkData(ctx context.Context) ([]byte, error) {
// ZData mimics ZData from python.
type ZData struct {
zBlkBase
zBlkBase // XXX -> ZBlk1, not here?
zodb.Persistent
// XXX py source uses bytes(buf) but on python2 it still results in str
......@@ -181,6 +184,10 @@ func (zd *zDataState) DropState() {
zd.data = ""
}
func (zd *zDataState) PyGetState() interface{} {
return zd.data
}
func (zd *zDataState) PySetState(pystate interface{}) error {
//log.Printf("ZData.PySetState")
data, ok := pystate.(string)
......@@ -205,8 +212,12 @@ func (zb *zBlk1State) DropState() {
zb.chunktab = nil
}
func (zb *zBlk1State) PyGetState() interface{} {
return zb.chunktab
}
func (zb *zBlk1State) PySetState(pystate interface{}) error {
log.Printf("ZBlk1.PySetState")
//log.Printf("ZBlk1.PySetState")
chunktab, ok := pystate.(*btree.IOBTree)
if !ok {
return fmt.Errorf("expect IOBTree; got %s", typeOf(pystate))
......@@ -380,6 +391,7 @@ func (zb *ZBlk1) loadBlkData(ctx context.Context) ([]byte, error) {
type ZBigFile struct {
zodb.Persistent
// state: (.blksize, .blktab)
blksize int64
blktab *btree.LOBTree // {} blk -> ZBlk*(blkdata)
}
......@@ -393,14 +405,13 @@ func (bf *zBigFileState) DropState() {
bf.blktab = nil
}
// PyGetState implements zodb.PyStateful.
func (bf *zBigFileState) PyGetState() interface{} {
return pickle.Tuple{bf.blksize, bf.blktab}
}
// PySetState implements zodb.PyStateful.
func (bf *zBigFileState) PySetState(pystate interface{}) (err error) {
// ZBigFile
// .blksize xint
// .blktab LOBtree{} blk -> ZBlk*(blkdata)
//
// state: (.blksize, .blktab)
t, ok := pystate.(pickle.Tuple)
if !ok {
return fmt.Errorf("expect [2](); got %s", typeOf(pystate))
......
......@@ -115,4 +115,5 @@ func TestZBlk(t *testing.T) {
// XXX check zf.blktab.MaxKey ?
// XXX check zf.LoadBlk()
// XXX PyGetState vs PySetState
}
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