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
Show 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 {
...
@@ -75,7 +75,7 @@ type ZBTree struct {
//
//
// It loads intermediate BTree nodes from database on demand as needed.
// It loads intermediate BTree nodes from database on demand as needed.
func
(
t
*
ZBTree
)
Get
(
ctx
context
.
Context
,
key
KEY
)
(
_
interface
{},
_
bool
,
err
error
)
{
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
)
err
=
t
.
PActivate
(
ctx
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
false
,
err
return
nil
,
false
,
err
...
@@ -115,7 +115,7 @@ func (t *ZBTree) Get(ctx context.Context, key KEY) (_ interface{}, _ bool, err e
...
@@ -115,7 +115,7 @@ func (t *ZBTree) Get(ctx context.Context, key KEY) (_ interface{}, _ bool, err e
// Get searches Bucket by key.
// Get searches Bucket by key.
func
(
b
*
ZBucket
)
Get
(
ctx
context
.
Context
,
key
KEY
)
(
_
interface
{},
_
bool
,
err
error
)
{
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
)
err
=
b
.
PActivate
(
ctx
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
false
,
err
return
nil
,
false
,
err
...
@@ -249,13 +249,8 @@ func (b *ZBucket) PySetState(pystate interface{}) error {
...
@@ -249,13 +249,8 @@ func (b *ZBucket) PySetState(pystate interface{}) error {
// ---- register classes to ZODB ----
// ---- register classes to ZODB ----
func
bucketNew
(
pyobj
*
pyObject
)
PyObject
{
func
bucketNew
(
pyobj
*
pyObject
)
PyObject
{
return
&
ZBucket
{
pyObject
:
pyobj
}
}
return
&
ZBucket
{
pyObject
:
pyobj
}
func
btreeNew
(
pyobj
*
pyObject
)
PyObject
{
return
&
ZBTree
{
pyObject
:
pyobj
}
}
}
func
btreeNew
(
pyobj
*
pyObject
)
PyObject
{
return
&
ZBTree
{
pyObject
:
pyobj
}
}
func
init
()
{
func
init
()
{
registerPyClass
(
"zodb.BTree.LOBucket"
,
bucketNew
)
registerPyClass
(
"zodb.BTree.LOBucket"
,
bucketNew
)
...
...
wcfs/zblk.go
View file @
ae2044cd
...
@@ -25,73 +25,89 @@ import (
...
@@ -25,73 +25,89 @@ import (
//"context"
//"context"
//"lab.nexedi.com/kirr/neo/go/zodb"
//"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
// ---- ZBlk0 ----
// func loadZBlk0(ctx context.Context, oid zodb.Oid) (data []byte, err error) {
// ...
// }
// ZBlk0 mimics ZBlk0 from python.
type
ZBlk0
struct
{
*
pyObject
// XXX start from loading ZBigFile btree
blkdata
string
}
// ZBigFile mimics ZBigFile from python.
func
(
zb
*
ZBlk0
)
DropState
()
{
type
ZBigFile
struct
{
zb
.
blkdata
=
""
*
pyObject
}
blksize
int64
func
(
zb
*
ZBlk0
)
PySetState
(
pystate
interface
{})
error
{
blktab
*
ZBTree
// LOBtree{} blk -> ZBlk*(blkdata)
blkdata
,
ok
:=
pystate
.
(
string
)
if
!
ok
{
// XXX
}
zb
.
blkdata
=
blkdata
return
nil
}
}
// module of Wendelin ZODB py objects
// ---- ZBlk1 ---
const
zwendelin
=
"wendelin.bigfile.file_zodb"
/*
// ZData mimics ZData from python.
// loadZBigFile loads ZBigFile object from specified oid.
type
ZData
struct
{
func (conn *zpyconn) loadZBigFile(ctx context.Context, oid zodb.Oid) (*ZBigFile, error) {
*
pyObject
// ZBigFile
// .blksize xint
// .blktab LOBtree{} blk -> ZBlk*(blkdata)
pyobj, err := zpyconn.Load(ctx, oid)
data
string
if err != nil {
}
return nil, err // XXX errctx
}
if pyobj.PyClass.Path() != zwendelin + ".ZBigFile"
{
func
(
zd
*
ZData
)
DropState
()
{
return nil, XXX_class_missmatch // XXX
zd
.
data
=
""
}
}
// decode pystate
func
(
zd
*
ZData
)
PySetState
(
pystate
interface
{})
error
{
t, ok := pyobj.PyState.(pickle.Tuple
)
data
,
ok
:=
pystate
.
(
string
)
if !ok
|| len(t) != 2
{
if
!
ok
{
// XXX
expected (.blksize, blktab)
// XXX
}
}
blksize, ok = pickletools.Xint64(t[0])
zd
.
data
=
data
// XXX if !ok
return
nil
}
tabref, ok := t[1].(pickle.Ref)
// ZBlk1 mimics ZBlk1 from python.
// XXX if !ok
type
ZBlk1
struct
{
*
pyObject
t, ok = tabref.Pid.(pickle.Tuple)
chunktab
*
ZBTree
// {} offset -> ZData(chunk)
if !ok || len(t) != 2 {
}
// XXX expected (oid, LOBTree)
}
taboid, err = decodeOID(t[0])
func
(
zb
*
ZBlk1
)
DropState
()
{
// XXX err
zb
.
chunktab
=
nil
}
lobtreeClass := pickle.Class{Module: "BTrees.LOBTree", Name: "LOBTree"}
func
(
zb
*
ZBlk1
)
PySetState
(
pystate
interface
{})
error
{
if t[1] != lobtreeClass {
chunktab
,
ok
:=
pystate
.
(
*
ZBTree
)
// XXX err
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.
// DropState implements Stateful.
...
@@ -100,70 +116,46 @@ func (bf *ZBigFile) DropState() {
...
@@ -100,70 +116,46 @@ func (bf *ZBigFile) DropState() {
bf
.
blktab
=
nil
bf
.
blktab
=
nil
}
}
// PySetState implements PyStateful.
func
(
bf
*
ZBigFile
)
PySetState
(
pystate
interface
{})
(
err
error
)
{
func
(
bf
*
ZBigFile
)
PySetState
(
pystate
interface
{})
(
err
error
)
{
panic
(
"TODO"
)
// ZBigFile
/* XXX reenable (pickletools)
// .blksize xint
if bf.blktab != nil {
// .blktab LOBtree{} blk -> ZBlk*(blkdata)
return nil
//
}
// state: (.blksize, .blktab)
err = bf.pyObject.PActivate(ctx)
if err != nil {
return err
}
defer func() {
if err != nil {
// decoding went wrong
}
}()
// decode pystate
t
,
ok
:=
pystate
.
(
pickle
.
Tuple
)
t, ok := bf.pyObject.pystate.(pickle.Tuple)
if
!
ok
||
len
(
t
)
!=
2
{
if
!
ok
||
len
(
t
)
!=
2
{
// XXX
expected (.blksize, blktab)
// XXX
}
}
blksize, ok := pickletools.Xint64(t[0])
// blksize, ok := pickletools.Xint64(t[0]) // XXX reenable (pickletools)
// XXX if !ok
if
!
ok
{
// XXX
}
blktab
,
ok
:=
t
[
1
]
.
(
*
ZBTree
)
blktab
,
ok
:=
t
[
1
]
.
(
*
ZBTree
)
// XXX if !ok
if
!
ok
{
// XXX
}
bf.blksize = blksize
bf
.
blksize
=
0
// XXX
blksize
bf
.
blktab
=
blktab
bf
.
blktab
=
blktab
return
nil
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
{
func
zblk0New
(
base
*
pyObject
)
PyObject
{
return
&
ZBlk0
{
pyObject
:
base
}
}
return
&
ZBigFile
{
pyObject
:
pyobj
}
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
()
{
func
init
()
{
registerPyClass
(
zwendelin
+
".ZBlk"
,
zblk0New
)
registerPyClass
(
zwendelin
+
".ZBlk0"
,
zblk0New
)
registerPyClass
(
zwendelin
+
".ZBlk1"
,
zblk1New
)
registerPyClass
(
zwendelin
+
".ZData"
,
zdataNew
)
registerPyClass
(
zwendelin
+
".ZBigFile"
,
zbigfileNew
)
registerPyClass
(
zwendelin
+
".ZBigFile"
,
zbigfileNew
)
}
}
wcfs/zodbpy.go
View file @
ae2044cd
...
@@ -102,6 +102,7 @@ var pyClassTab = make(map[string]pyClassNewFunc)
...
@@ -102,6 +102,7 @@ var pyClassTab = make(map[string]pyClassNewFunc)
// must be called from global init().
// must be called from global init().
func
registerPyClass
(
pyClassPath
string
,
classNew
pyClassNewFunc
)
{
func
registerPyClass
(
pyClassPath
string
,
classNew
pyClassNewFunc
)
{
pyClassTab
[
pyClassPath
]
=
classNew
pyClassTab
[
pyClassPath
]
=
classNew
// XXX + register so that zodb.PyData decode handles pyClassPath
}
}
// newGhost creates new ghost object corresponding to pyclass and oid.
// 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