Commit a8e778e6 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent acc6c2ec
......@@ -144,5 +144,5 @@ func TestBTree(t *testing.T) {
}
}
// XXX check links
// XXX check links (e.g. .firstbucket)
}
......@@ -20,6 +20,7 @@ import (
"sync"
"lab.nexedi.com/kirr/go123/mem"
"lab.nexedi.com/kirr/go123/xerr"
"lab.nexedi.com/kirr/neo/go/transaction"
"lab.nexedi.com/kirr/neo/go/zodb/internal/weak"
)
......@@ -187,8 +188,9 @@ func (conn *Connection) get(class string, oid Oid) (IPersistent, error) {
//
// The object's data is not necessarily loaded after Get returns. Use
// PActivate to make sure the object is fully loaded.
func (conn *Connection) Get(ctx context.Context, oid Oid) (IPersistent, error) {
func (conn *Connection) Get(ctx context.Context, oid Oid) (_ IPersistent, err error) {
conn.checkTxnCtx(ctx, "Get")
defer xerr.Contextf(&err, "Get %s", oid)
conn.objmu.Lock() // XXX -> rlock
wobj := conn.objtab[oid]
......@@ -207,12 +209,12 @@ func (conn *Connection) Get(ctx context.Context, oid Oid) (IPersistent, error) {
// XXX py hardcoded
class, pystate, serial, err := conn.loadpy(ctx, oid)
if err != nil {
return nil, err // XXX errctx
return nil, err
}
obj, err := conn.get(class, oid)
if err != nil {
return nil, err
return nil, err // XXX double err ctx? (see get)
}
// XXX we are dropping just loaded pystate. Usually Get should be used
......
......@@ -281,6 +281,11 @@ func (obj *Persistent) PDeactivate() {
return
}
// TODO try to keep some pool of object in live state
// TODO so that there is no constant load/unload on object access.
// XXX -> MRU cache?
// NOTE wcfs manages its objects explicitly and does not need this.
if cc := obj.jar.cacheControl; cc != nil {
if !cc.WantEvict(obj.instance) {
return
......@@ -334,7 +339,7 @@ var typeTab = make(map[reflect.Type]*zclass) // {} type -> zclass
//
// If ZODB class was not registered for obj's type, "" is returned.
func zclassOf(obj IPersistent) string {
zc, ok := typeTab[reflect.TypeOf(obj)]
zc, ok := typeTab[reflect.TypeOf(obj).Elem()]
if !ok {
return ""
}
......
......@@ -120,6 +120,8 @@ func TestPersistent(t *testing.T) {
checkObj(obj, nil, 11, InvalidTid, GHOST, 0, nil)
assert.Equal(zclassOf(obj), "t.zodb.MyObject")
// TODO activate - jar has to load, state changes
// TODO activate again - refcnt++
......
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