Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
W
wendelin.core
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
Kirill Smelkov
wendelin.core
Commits
ae2044cd
Commit
ae2044cd
authored
Jul 19, 2018
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
db65b87d
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
90 additions
and
102 deletions
+90
-102
wcfs/btree.go
wcfs/btree.go
+4
-9
wcfs/zblk.go
wcfs/zblk.go
+85
-93
wcfs/zodbpy.go
wcfs/zodbpy.go
+1
-0
No files found.
wcfs/btree.go
View file @
ae2044cd
...
...
@@ -75,7 +75,7 @@ type ZBTree struct {
//
// It loads intermediate BTree nodes from database on demand as needed.
func
(
t
*
ZBTree
)
Get
(
ctx
context
.
Context
,
key
KEY
)
(
_
interface
{},
_
bool
,
err
error
)
{
defer
xerr
.
Contextf
(
&
err
,
"btree(%s): get %s"
)
// XXX + url?
defer
xerr
.
Contextf
(
&
err
,
"btree(%s): get %s"
,
t
.
POid
(),
key
)
// XXX + url?
err
=
t
.
PActivate
(
ctx
)
if
err
!=
nil
{
return
nil
,
false
,
err
...
...
@@ -115,7 +115,7 @@ func (t *ZBTree) Get(ctx context.Context, key KEY) (_ interface{}, _ bool, err e
// Get searches Bucket by key.
func
(
b
*
ZBucket
)
Get
(
ctx
context
.
Context
,
key
KEY
)
(
_
interface
{},
_
bool
,
err
error
)
{
defer
xerr
.
Contextf
(
&
err
,
"bucket(%s): get %s"
)
// XXX + url?
defer
xerr
.
Contextf
(
&
err
,
"bucket(%s): get %s"
,
b
.
POid
(),
key
)
// XXX + url?
err
=
b
.
PActivate
(
ctx
)
if
err
!=
nil
{
return
nil
,
false
,
err
...
...
@@ -249,13 +249,8 @@ func (b *ZBucket) PySetState(pystate interface{}) error {
// ---- register classes to ZODB ----
func
bucketNew
(
pyobj
*
pyObject
)
PyObject
{
return
&
ZBucket
{
pyObject
:
pyobj
}
}
func
btreeNew
(
pyobj
*
pyObject
)
PyObject
{
return
&
ZBTree
{
pyObject
:
pyobj
}
}
func
bucketNew
(
pyobj
*
pyObject
)
PyObject
{
return
&
ZBucket
{
pyObject
:
pyobj
}
}
func
btreeNew
(
pyobj
*
pyObject
)
PyObject
{
return
&
ZBTree
{
pyObject
:
pyobj
}
}
func
init
()
{
registerPyClass
(
"zodb.BTree.LOBucket"
,
bucketNew
)
...
...
wcfs/zblk.go
View file @
ae2044cd
...
...
@@ -25,73 +25,89 @@ import (
//"context"
//"lab.nexedi.com/kirr/neo/go/zodb"
//
pickle "github.com/kisielk/og-rek"
pickle
"github.com/kisielk/og-rek"
)
// module of Wendelin ZODB py objects
const
zwendelin
=
"wendelin.bigfile.file_zodb"
// // loadZBlk0 loads data stored in ZBlk0 object
// func loadZBlk0(ctx context.Context, oid zodb.Oid) (data []byte, err error) {
// ...
// }
// ---- ZBlk0 ----
// ZBlk0 mimics ZBlk0 from python.
type
ZBlk0
struct
{
*
pyObject
// XXX start from loading ZBigFile btree
blkdata
string
}
// ZBigFile mimics ZBigFile from python.
type
ZBigFile
struct
{
*
pyObject
func
(
zb
*
ZBlk0
)
DropState
()
{
zb
.
blkdata
=
""
}
blksize
int64
blktab
*
ZBTree
// LOBtree{} blk -> ZBlk*(blkdata)
func
(
zb
*
ZBlk0
)
PySetState
(
pystate
interface
{})
error
{
blkdata
,
ok
:=
pystate
.
(
string
)
if
!
ok
{
// XXX
}
zb
.
blkdata
=
blkdata
return
nil
}
// module of Wendelin ZODB py objects
const
zwendelin
=
"wendelin.bigfile.file_zodb"
// ---- ZBlk1 ---
/*
// loadZBigFile loads ZBigFile object from specified oid.
func (conn *zpyconn) loadZBigFile(ctx context.Context, oid zodb.Oid) (*ZBigFile, error) {
// ZBigFile
// .blksize xint
// .blktab LOBtree{} blk -> ZBlk*(blkdata)
// ZData mimics ZData from python.
type
ZData
struct
{
*
pyObject
pyobj, err := zpyconn.Load(ctx, oid)
if err != nil {
return nil, err // XXX errctx
}
data
string
}
if pyobj.PyClass.Path() != zwendelin + ".ZBigFile"
{
return nil, XXX_class_missmatch // XXX
}
func
(
zd
*
ZData
)
DropState
()
{
zd
.
data
=
""
}
// decode pystate
t, ok := pyobj.PyState.(pickle.Tuple
)
if !ok
|| len(t) != 2
{
// XXX
expected (.blksize, blktab)
func
(
zd
*
ZData
)
PySetState
(
pystate
interface
{})
error
{
data
,
ok
:=
pystate
.
(
string
)
if
!
ok
{
// XXX
}
blksize, ok = pickletools.Xint64(t[0])
// XXX if !ok
zd
.
data
=
data
return
nil
}
tabref, ok := t[1].(pickle.Ref)
// XXX if !ok
// ZBlk1 mimics ZBlk1 from python.
type
ZBlk1
struct
{
*
pyObject
t, ok = tabref.Pid.(pickle.Tuple)
if !ok || len(t) != 2 {
// XXX expected (oid, LOBTree)
}
chunktab
*
ZBTree
// {} offset -> ZData(chunk)
}
taboid, err = decodeOID(t[0])
// XXX err
func
(
zb
*
ZBlk1
)
DropState
()
{
zb
.
chunktab
=
nil
}
lobtreeClass := pickle.Class{Module: "BTrees.LOBTree", Name: "LOBTree"}
if t[1] != lobtreeClass {
// XXX err
func
(
zb
*
ZBlk1
)
PySetState
(
pystate
interface
{})
error
{
chunktab
,
ok
:=
pystate
.
(
*
ZBTree
)
if
!
ok
{
// XXX
}
// XXX ok
zb
.
chunktab
=
chunktab
return
nil
}
// ----------------------------------------
// ZBigFile mimics ZBigFile from python.
type
ZBigFile
struct
{
*
pyObject
blksize
int64
blktab
*
ZBTree
// LOBtree{} blk -> ZBlk*(blkdata)
}
*/
// DropState implements Stateful.
...
...
@@ -100,70 +116,46 @@ func (bf *ZBigFile) DropState() {
bf
.
blktab
=
nil
}
// PySetState implements PyStateful.
func
(
bf
*
ZBigFile
)
PySetState
(
pystate
interface
{})
(
err
error
)
{
panic
(
"TODO"
)
/* XXX reenable (pickletools)
if bf.blktab != nil {
return nil
}
err = bf.pyObject.PActivate(ctx)
if err != nil {
return err
}
defer func() {
if err != nil {
// decoding went wrong
}
}()
// ZBigFile
// .blksize xint
// .blktab LOBtree{} blk -> ZBlk*(blkdata)
//
// state: (.blksize, .blktab)
// decode pystate
t, ok := bf.pyObject.pystate.(pickle.Tuple)
t
,
ok
:=
pystate
.
(
pickle
.
Tuple
)
if
!
ok
||
len
(
t
)
!=
2
{
// XXX
expected (.blksize, blktab)
// XXX
}
blksize, ok := pickletools.Xint64(t[0])
// XXX if !ok
// blksize, ok := pickletools.Xint64(t[0]) // XXX reenable (pickletools)
if
!
ok
{
// XXX
}
blktab
,
ok
:=
t
[
1
]
.
(
*
ZBTree
)
// XXX if !ok
if
!
ok
{
// XXX
}
bf.blksize = blksize
bf
.
blksize
=
0
// XXX
blksize
bf
.
blktab
=
blktab
return
nil
*/
}
// XXX -> newGhost
/*
tabref, ok := t[1].(pickle.Ref)
// XXX if !ok
t, ok = tabref.Pid.(pickle.Tuple)
if !ok || len(t) != 2 {
// XXX expected (oid, LOBTree)
}
taboid, err = decodeOID(t[0])
// XXX err
lobtreeClass := pickle.Class{Module: "BTrees.LOBTree", Name: "LOBTree"}
if t[1] != lobtreeClass {
// XXX err
}
*/
// ----------------------------------------
func
zbigfileNew
(
pyobj
*
pyObject
)
PyObject
{
return
&
ZBigFile
{
pyObject
:
pyobj
}
}
func
zblk0New
(
base
*
pyObject
)
PyObject
{
return
&
ZBlk0
{
pyObject
:
base
}
}
func
zblk1New
(
base
*
pyObject
)
PyObject
{
return
&
ZBlk1
{
pyObject
:
base
}
}
func
zdataNew
(
base
*
pyObject
)
PyObject
{
return
&
ZData
{
pyObject
:
base
}
}
func
zbigfileNew
(
pyobj
*
pyObject
)
PyObject
{
return
&
ZBigFile
{
pyObject
:
pyobj
}
}
func
init
()
{
registerPyClass
(
zwendelin
+
".ZBlk"
,
zblk0New
)
registerPyClass
(
zwendelin
+
".ZBlk0"
,
zblk0New
)
registerPyClass
(
zwendelin
+
".ZBlk1"
,
zblk1New
)
registerPyClass
(
zwendelin
+
".ZData"
,
zdataNew
)
registerPyClass
(
zwendelin
+
".ZBigFile"
,
zbigfileNew
)
}
wcfs/zodbpy.go
View file @
ae2044cd
...
...
@@ -102,6 +102,7 @@ var pyClassTab = make(map[string]pyClassNewFunc)
// must be called from global init().
func
registerPyClass
(
pyClassPath
string
,
classNew
pyClassNewFunc
)
{
pyClassTab
[
pyClassPath
]
=
classNew
// XXX + register so that zodb.PyData decode handles pyClassPath
}
// newGhost creates new ghost object corresponding to pyclass and oid.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment