Commit 1bbc897a authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 6e858c16
......@@ -18,7 +18,8 @@ import (
"context"
"sort"
"lab.nexedi.com/kirr/neo/go/zodb"
//"lab.nexedi.com/kirr/neo/go/zodb"
pickle "github.com/kisielk/og-rek"
)
// XXX -> template
......@@ -35,7 +36,7 @@ type KEY int64
// are chained together via 'next', so that the entire BTree contents
// can be traversed in sorted order quickly and easily.
type ZBucket struct {
pyobj *zodb.PyObject
pyobj *PyObject
next *ZBucket // the bucket with the next-larger keys
keys []KEY // 'len' keys, in increasing order
......@@ -53,7 +54,7 @@ type zBTreeItem struct {
// See https://github.com/zopefoundation/BTrees/blob/4.5.0-1-gc8bf24e/BTrees/Development.txt#L198
// for details.
type ZBTree struct {
pyobj *zodb.PyObject
pyobj *PyObject
// firstbucket points to the bucket containing the smallest key in
// the BTree. This is found by traversing leftmost child pointers
......@@ -194,7 +195,7 @@ func (b *ZBucket) PActivate(ctx context.Context) error {
}
t, ok := b.pyobj.pystate.(pickle.Tuple)
if !ok || !(1 <= len(q) && len(q) <= 2) {
if !ok || !(1 <= len(t) && len(t) <= 2) {
// XXX complain
}
......@@ -206,13 +207,13 @@ func (b *ZBucket) PActivate(ctx context.Context) error {
}
// main part
t, ok = t[0].(picklet.Tuple)
t, ok = t[0].(pickle.Tuple)
// XXX if !ok || (len(t) % 2 != 0)
// reset arrays just in case
n := len(t) / 2
t.keys = make([]KEY, 0, n)
t.values = make([]interface{}, 0, n)
b.keys = make([]KEY, 0, n)
b.values = make([]interface{}, 0, n)
for i := 0; i < n; i++ {
xk := t[2*i]
......@@ -221,7 +222,9 @@ func (b *ZBucket) PActivate(ctx context.Context) error {
k, ok := xk.(int64) // XXX use KEY
// XXX if !ok
t.keys = append(t.keys, k)
t.values = append(t.values, v)
b.keys = append(b.keys, KEY(k)) // XXX cast
b.values = append(b.values, v)
}
return nil
}
......@@ -24,7 +24,8 @@ package main
import (
"context"
"lab.nexedi.com/kirr/neo/go/zodb"
//"lab.nexedi.com/kirr/neo/go/zodb"
pickle "github.com/kisielk/og-rek"
)
......@@ -38,7 +39,7 @@ import (
// ZBigFile mimics ZBigFile from python.
type ZBigFile struct {
pyobj *zodb.PyObject
pyobj *PyObject
blksize int64
blktab *ZBTree // LOBtree{} blk -> ZBlk*(blkdata)
......@@ -121,12 +122,12 @@ func (bf *ZBigFile) PActivate(ctx context.Context) (err error) {
}()
// decode pystate
t, ok := pyobj.PyState.(pickle.Tuple)
t, ok := bf.pyobj.pystate.(pickle.Tuple)
if !ok || len(t) != 2 {
// XXX expected (.blksize, blktab)
}
blksize, ok = pickletools.Xint64(t[0])
blksize, ok := pickletools.Xint64(t[0])
// XXX if !ok
blktab, ok := t[1].(*ZBTree)
......
......@@ -50,12 +50,13 @@ type Connection struct {
// XXX this is needed if there are several persistent references to the same object.
// however wendelin.core does not do this.
func (conn *Connection) Get(ctx context.Context, oid zodb.Oid) (*PyObject, error) {
buf, serial, err := stor.Load(ctx, zodb.Xid{Oid: oid, At: conn.at})
// XXX -> loadpy
buf, serial, err := conn.stor.Load(ctx, zodb.Xid{Oid: oid, At: conn.at})
if err != nil {
return nil, err
}
pyclass, pystate, err := zodb.PyData(buf.Data()).Decode()
pyclass, pystate, err := zodb.PyData(buf.Data).Decode()
if err != nil {
return nil, err // XXX err ctx
}
......@@ -70,14 +71,14 @@ func (conn *Connection) Get(ctx context.Context, oid zodb.Oid) (*PyObject, error
}
func (conn *Connection) loadpy(ctx context.Context, oid zodb.Oid) (pyclass pickle.Class, pystate interface{}, serial zodb.Tid, _ error) {
buf, serial, err := stor.Load(ctx, zodb.Xid{Oid: oid, At: conn.at})
buf, serial, err := conn.stor.Load(ctx, zodb.Xid{Oid: oid, At: conn.at})
if err != nil {
return nil, err
return pickle.Class{}, nil, zodb.InvalidTID, err
}
pyclass, pystate, err := zodb.PyData(buf.Data()).Decode()
pyclass, pystate, err = zodb.PyData(buf.Data).Decode()
if err != nil {
return nil, err // XXX err ctx
return pickle.Class{}, nil, zodb.InvalidTID, err // XXX err ctx
}
buf.Release()
......@@ -127,4 +128,5 @@ func (pyobj *PyObject) PActivate(ctx context.Context) error {
pyobj.serial = serial
pyobj.pystate = pystate
return nil
}
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