Commit ab73858d authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent e4125185
......@@ -25,6 +25,8 @@ import (
"github.com/hanwen/go-fuse/fuse"
"github.com/hanwen/go-fuse/fuse/nodefs"
"lab.nexedi.com/kirr/neo/go/zodb"
)
// asctx represents fuse context as context.Context ready for interrupt handling.
......@@ -78,3 +80,12 @@ func mkdir(parent nodefs.Node, name string, child nodefs.Node) {
func mkfile(parent nodefs.Node, name string, child nodefs.Node) {
parent.Inode().NewChild(name, false, child)
}
// typeOf returns ZODB type of an object.
//
// it differs from %T in fmt in that it supports printing zodb.Broken with
// details properly.
func typeOf(obj interface{}) string {
return zodb.ClassOf(obj)
}
......@@ -305,7 +305,7 @@ type BigFileData struct {
//parent *BigFileHead
// current read-only transaction under which we access ZODB data
txnCtx context.Context // XXX -> directly store txn
txnCtx context.Context // XXX -> better directly store txn
// connection via which ZODB object for this bigfile are accessed
// XXX do we need to keep it here explicitly?
......@@ -378,7 +378,7 @@ func (bfroot *BigFileRoot) Mkdir(name string, mode uint32, fctx *fuse.Context) (
zbf, ok := xzbf.(*ZBigFile)
if !ok {
log.Printf("/bigfile: mkdir %q: %T is not a ZBigFile", name, xzbf)
log.Printf("/bigfile: mkdir %q: %s is not a ZBigFile", name, typeOf(xzbf))
return nil, fuse.EINVAL
}
......@@ -426,22 +426,6 @@ func (bfroot *BigFileRoot) Mkdir(name string, mode uint32, fctx *fuse.Context) (
// XXX do we need to support rmdir? (probably no)
// module: "wendelin.bigfile.file_zodb"
//
// ZBigFile
// .blksize xint
// .blktab LOBtree{} blk -> ZBlk*(blkdata)
//
// ZBlk0 (aliased as ZBlk)
// str with trailing '\0' removed.
//
// ZBlk1
// .chunktab IOBtree{} offset -> ZData(chunk)
//
// ZData
// str (chunk)
// Read implements reading from /bigfile/<bigfileX>/head/data.
// XXX and from /bigfile/<bigfileX>/@<tidX>/data.
/*
......@@ -454,6 +438,10 @@ func (bf *BigFileData) Read(_ nodefs.File, dest []byte, off int64, _ fuse.Contex
// zodbCacheControl implements LiveCacheControl to tune ZODB to never evict
// LOBTree/LOBucket from live cache. We want to keep LOBTree/LOBucket always alive
// becuse it is essentially the index where to find ZBigFile data.
//
......
......@@ -140,7 +140,6 @@ def test_bigfile_empty():
assert exc.value.errno == EINVAL
"""
# path to f under wcfs
fpath = "%s/%s" % (bigpath, f._p_oid.encode('hex'))
......@@ -151,7 +150,6 @@ def test_bigfile_empty():
assert readfile(fpath + "/head/at") == 'txn2'
# XXX head/at = last txn of whole db
"""
wc.close()
......
......@@ -20,6 +20,22 @@
package main
// ZBlk* + ZBigFile loading
// module: "wendelin.bigfile.file_zodb"
//
// ZBigFile
// .blksize xint
// .blktab LOBtree{} blk -> ZBlk*(blkdata)
//
// ZBlk0 (aliased as ZBlk)
// str with trailing '\0' removed.
//
// ZBlk1
// .chunktab IOBtree{} offset -> ZData(chunk)
//
// ZData
// str (chunk)
import (
"context"
......@@ -59,7 +75,7 @@ func (zb *zBlk0State) DropState() {
func (zb *zBlk0State) PySetState(pystate interface{}) error {
blkdata, ok := pystate.(string)
if !ok {
return fmt.Errorf("expect str; got %T", pystate)
return fmt.Errorf("expect str; got %s", typeOf(pystate))
}
zb.blkdata = blkdata
......@@ -96,7 +112,7 @@ func (zd *zDataState) DropState() {
func (zd *zDataState) PySetState(pystate interface{}) error {
data, ok := pystate.(string)
if !ok {
return fmt.Errorf("expect str; got %T", pystate)
return fmt.Errorf("expect str; got %s", typeOf(pystate))
}
zd.data = data
......@@ -119,8 +135,7 @@ func (zb *zBlk1State) DropState() {
func (zb *zBlk1State) PySetState(pystate interface{}) error {
chunktab, ok := pystate.(*btree.IOBTree)
if !ok {
//return fmt.Errorf("expect IOBTree; got %T", pystate) XXX no details for Broken
return fmt.Errorf("expect IOBTree; got %#v", pystate)
return fmt.Errorf("expect IOBTree; got %s", typeOf(pystate))
}
zb.chunktab = chunktab
......@@ -188,7 +203,7 @@ func (zb *ZBlk1) LoadBlkData(ctx context.Context) ([]byte, error) {
for _, e := range b.Entryv() {
zd, ok := e.Value().(*ZData)
if !ok {
return fmt.Errorf("!ZData (%T)", e.Value()) // XXX
return fmt.Errorf("!ZData (%s)", typeOf(e.Value()))
}
offset := e.Key()
......@@ -225,7 +240,7 @@ func (zb *ZBlk1) LoadBlkData(ctx context.Context) ([]byte, error) {
})
default:
panic(fmt.Sprintf("IOBTree has %T child", child))
panic(fmt.Sprintf("IOBTree has %s child", typeOf(child)))
}
}
......@@ -315,7 +330,7 @@ func (bf *zBigFileState) PySetState(pystate interface{}) (err error) {
t, ok := pystate.(pickle.Tuple)
if !ok {
return fmt.Errorf("expect [2](); got %T", pystate)
return fmt.Errorf("expect [2](); got %s", typeOf(pystate))
}
if len(t) != 2 {
return fmt.Errorf("expect [2](); got [%d]()", len(t))
......@@ -323,12 +338,12 @@ func (bf *zBigFileState) PySetState(pystate interface{}) (err error) {
blksize, ok := pycompat.Int64(t[0])
if !ok {
return fmt.Errorf("blksize: expect integer; got %T", t[0])
return fmt.Errorf("blksize: expect integer; got %s", typeOf(t[0]))
}
blktab, ok := t[1].(*btree.LOBTree)
if !ok {
return fmt.Errorf("blktab: expect LOBTree; got %T", t[1])
return fmt.Errorf("blktab: expect LOBTree; got %s", typeOf(t[1]))
}
bf.blksize = blksize
......
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