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
3c1df9e8
Commit
3c1df9e8
authored
Jul 19, 2018
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
f1b89b31
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
24 additions
and
24 deletions
+24
-24
wcfs/btree.go
wcfs/btree.go
+4
-4
wcfs/zblk.go
wcfs/zblk.go
+8
-8
wcfs/zodbpy.go
wcfs/zodbpy.go
+12
-12
No files found.
wcfs/btree.go
View file @
3c1df9e8
...
@@ -37,7 +37,7 @@ type KEY int64
...
@@ -37,7 +37,7 @@ type KEY int64
// are chained together via 'next', so that the entire BTree contents
// are chained together via 'next', so that the entire BTree contents
// can be traversed in sorted order quickly and easily.
// can be traversed in sorted order quickly and easily.
type
ZBucket
struct
{
type
ZBucket
struct
{
*
pyObjec
t
*
PyPersisten
t
next
*
ZBucket
// the bucket with the next-larger keys
next
*
ZBucket
// the bucket with the next-larger keys
keys
[]
KEY
// 'len' keys, in increasing order
keys
[]
KEY
// 'len' keys, in increasing order
...
@@ -55,7 +55,7 @@ type zBTreeItem struct {
...
@@ -55,7 +55,7 @@ type zBTreeItem struct {
// See https://github.com/zopefoundation/BTrees/blob/4.5.0-1-gc8bf24e/BTrees/Development.txt#L198
// See https://github.com/zopefoundation/BTrees/blob/4.5.0-1-gc8bf24e/BTrees/Development.txt#L198
// for details.
// for details.
type
ZBTree
struct
{
type
ZBTree
struct
{
*
pyObjec
t
*
PyPersisten
t
// firstbucket points to the bucket containing the smallest key in
// firstbucket points to the bucket containing the smallest key in
// the BTree. This is found by traversing leftmost child pointers
// the BTree. This is found by traversing leftmost child pointers
...
@@ -249,8 +249,8 @@ func (b *ZBucket) PySetState(pystate interface{}) error {
...
@@ -249,8 +249,8 @@ func (b *ZBucket) PySetState(pystate interface{}) error {
// ---- register classes to ZODB ----
// ---- register classes to ZODB ----
func
bucketNew
(
pyobj
*
pyObject
)
IPyPersistent
{
return
&
ZBucket
{
pyObjec
t
:
pyobj
}
}
func
bucketNew
(
pyobj
*
PyPersistent
)
IPyPersistent
{
return
&
ZBucket
{
PyPersisten
t
:
pyobj
}
}
func
btreeNew
(
pyobj
*
pyObject
)
IPyPersistent
{
return
&
ZBTree
{
pyObjec
t
:
pyobj
}
}
func
btreeNew
(
pyobj
*
PyPersistent
)
IPyPersistent
{
return
&
ZBTree
{
PyPersisten
t
:
pyobj
}
}
func
init
()
{
func
init
()
{
registerPyClass
(
"zodb.BTree.LOBucket"
,
bucketNew
)
registerPyClass
(
"zodb.BTree.LOBucket"
,
bucketNew
)
...
...
wcfs/zblk.go
View file @
3c1df9e8
...
@@ -35,7 +35,7 @@ const zwendelin = "wendelin.bigfile.file_zodb"
...
@@ -35,7 +35,7 @@ const zwendelin = "wendelin.bigfile.file_zodb"
// ZBlk0 mimics ZBlk0 from python.
// ZBlk0 mimics ZBlk0 from python.
type
ZBlk0
struct
{
type
ZBlk0
struct
{
*
pyObjec
t
*
PyPersisten
t
blkdata
string
blkdata
string
}
}
...
@@ -58,7 +58,7 @@ func (zb *ZBlk0) PySetState(pystate interface{}) error {
...
@@ -58,7 +58,7 @@ func (zb *ZBlk0) PySetState(pystate interface{}) error {
// ZData mimics ZData from python.
// ZData mimics ZData from python.
type
ZData
struct
{
type
ZData
struct
{
*
pyObjec
t
*
PyPersisten
t
data
string
data
string
}
}
...
@@ -79,7 +79,7 @@ func (zd *ZData) PySetState(pystate interface{}) error {
...
@@ -79,7 +79,7 @@ func (zd *ZData) PySetState(pystate interface{}) error {
// ZBlk1 mimics ZBlk1 from python.
// ZBlk1 mimics ZBlk1 from python.
type
ZBlk1
struct
{
type
ZBlk1
struct
{
*
pyObjec
t
*
PyPersisten
t
chunktab
*
ZBTree
// {} offset -> ZData(chunk)
chunktab
*
ZBTree
// {} offset -> ZData(chunk)
}
}
...
@@ -103,7 +103,7 @@ func (zb *ZBlk1) PySetState(pystate interface{}) error {
...
@@ -103,7 +103,7 @@ func (zb *ZBlk1) PySetState(pystate interface{}) error {
// ZBigFile mimics ZBigFile from python.
// ZBigFile mimics ZBigFile from python.
type
ZBigFile
struct
{
type
ZBigFile
struct
{
*
pyObjec
t
*
PyPersisten
t
blksize
int64
blksize
int64
blktab
*
ZBTree
// LOBtree{} blk -> ZBlk*(blkdata)
blktab
*
ZBTree
// LOBtree{} blk -> ZBlk*(blkdata)
...
@@ -147,10 +147,10 @@ func (bf *ZBigFile) PySetState(pystate interface{}) (err error) {
...
@@ -147,10 +147,10 @@ func (bf *ZBigFile) PySetState(pystate interface{}) (err error) {
// ----------------------------------------
// ----------------------------------------
func
zblk0New
(
base
*
pyObject
)
IPyPersistent
{
return
&
ZBlk0
{
pyObjec
t
:
base
}
}
func
zblk0New
(
base
*
PyPersistent
)
IPyPersistent
{
return
&
ZBlk0
{
PyPersisten
t
:
base
}
}
func
zblk1New
(
base
*
pyObject
)
IPyPersistent
{
return
&
ZBlk1
{
pyObjec
t
:
base
}
}
func
zblk1New
(
base
*
PyPersistent
)
IPyPersistent
{
return
&
ZBlk1
{
PyPersisten
t
:
base
}
}
func
zdataNew
(
base
*
pyObject
)
IPyPersistent
{
return
&
ZData
{
pyObjec
t
:
base
}
}
func
zdataNew
(
base
*
PyPersistent
)
IPyPersistent
{
return
&
ZData
{
PyPersisten
t
:
base
}
}
func
zbigfileNew
(
pyobj
*
pyObject
)
IPyPersistent
{
return
&
ZBigFile
{
pyObjec
t
:
pyobj
}
}
func
zbigfileNew
(
pyobj
*
PyPersistent
)
IPyPersistent
{
return
&
ZBigFile
{
PyPersisten
t
:
pyobj
}
}
func
init
()
{
func
init
()
{
registerPyClass
(
zwendelin
+
".ZBlk"
,
zblk0New
)
registerPyClass
(
zwendelin
+
".ZBlk"
,
zblk0New
)
...
...
wcfs/zodbpy.go
View file @
3c1df9e8
...
@@ -38,14 +38,14 @@ type IPyPersistent interface {
...
@@ -38,14 +38,14 @@ type IPyPersistent interface {
PyStateful
PyStateful
}
}
//
pyObjec
t is common base implementation for in-RAM representation of ZODB Python objects.
//
PyPersisten
t is common base implementation for in-RAM representation of ZODB Python objects.
type
pyObjec
t
struct
{
type
PyPersisten
t
struct
{
Persistent
Persistent
pyclass
pickle
.
Class
pyclass
pickle
.
Class
}
}
func
(
pyobj
*
pyObjec
t
)
PyClass
()
pickle
.
Class
{
return
pyobj
.
pyclass
}
func
(
pyobj
*
PyPersisten
t
)
PyClass
()
pickle
.
Class
{
return
pyobj
.
pyclass
}
//func (pyobj *
pyObjec
t) PyState() interface{} { return pyobj.pystate }
//func (pyobj *
PyPersisten
t) PyState() interface{} { return pyobj.pystate }
// PyStateful is the interface describing in-RAM object whose data state can be
// PyStateful is the interface describing in-RAM object whose data state can be
// exchanged as Python data.
// exchanged as Python data.
...
@@ -59,17 +59,17 @@ type PyStateful interface {
...
@@ -59,17 +59,17 @@ type PyStateful interface {
//PyGetState() interface{} TODO
//PyGetState() interface{} TODO
}
}
// ----
pyObjec
t <-> Persistent state exchange ----
// ----
PyPersisten
t <-> Persistent state exchange ----
// pyinstance returns .instance upcasted to IPyPersistent.
// pyinstance returns .instance upcasted to IPyPersistent.
//
//
// this should be always safe because we always create pyObjects via
// this should be always safe because we always create pyObjects via
// newGhost which passes IPyPersistent as instance to IPersistent.
// newGhost which passes IPyPersistent as instance to IPersistent.
func
(
pyobj
*
pyObjec
t
)
pyinstance
()
IPyPersistent
{
func
(
pyobj
*
PyPersisten
t
)
pyinstance
()
IPyPersistent
{
return
pyobj
.
instance
.
(
IPyPersistent
)
return
pyobj
.
instance
.
(
IPyPersistent
)
}
}
func
(
pyobj
*
pyObjec
t
)
SetState
(
state
*
mem
.
Buf
)
error
{
func
(
pyobj
*
PyPersisten
t
)
SetState
(
state
*
mem
.
Buf
)
error
{
pyclass
,
pystate
,
err
:=
zodb
.
PyData
(
state
.
Data
)
.
Decode
()
pyclass
,
pystate
,
err
:=
zodb
.
PyData
(
state
.
Data
)
.
Decode
()
if
err
!=
nil
{
if
err
!=
nil
{
return
err
// XXX err ctx
return
err
// XXX err ctx
...
@@ -84,12 +84,12 @@ func (pyobj *pyObject) SetState(state *mem.Buf) error {
...
@@ -84,12 +84,12 @@ func (pyobj *pyObject) SetState(state *mem.Buf) error {
return
pyobj
.
pyinstance
()
.
PySetState
(
pystate
)
// XXX err ctx = ok?
return
pyobj
.
pyinstance
()
.
PySetState
(
pystate
)
// XXX err ctx = ok?
}
}
// TODO
pyObjec
t.GetState
// TODO
PyPersisten
t.GetState
// ---- pyclass -> new ghost ----
// ---- pyclass -> new ghost ----
// function representing new of a class.
// function representing new of a class.
type
pyClassNewFunc
func
(
base
*
pyObjec
t
)
IPyPersistent
type
pyClassNewFunc
func
(
base
*
PyPersisten
t
)
IPyPersistent
// path(pyclass) -> new(pyobj)
// path(pyclass) -> new(pyobj)
var
pyClassTab
=
make
(
map
[
string
]
pyClassNewFunc
)
var
pyClassTab
=
make
(
map
[
string
]
pyClassNewFunc
)
...
@@ -105,7 +105,7 @@ func registerPyClass(pyClassPath string, classNew pyClassNewFunc) {
...
@@ -105,7 +105,7 @@ func registerPyClass(pyClassPath string, classNew pyClassNewFunc) {
// newGhost creates new ghost object corresponding to pyclass and oid.
// newGhost creates new ghost object corresponding to pyclass and oid.
func
(
conn
*
Connection
)
newGhost
(
pyclass
pickle
.
Class
,
oid
zodb
.
Oid
)
IPyPersistent
{
func
(
conn
*
Connection
)
newGhost
(
pyclass
pickle
.
Class
,
oid
zodb
.
Oid
)
IPyPersistent
{
pyobj
:=
&
pyObjec
t
{
pyobj
:=
&
PyPersisten
t
{
Persistent
:
Persistent
{
jar
:
conn
,
oid
:
oid
,
serial
:
0
,
state
:
GHOST
},
Persistent
:
Persistent
{
jar
:
conn
,
oid
:
oid
,
serial
:
0
,
state
:
GHOST
},
pyclass
:
pyclass
,
pyclass
:
pyclass
,
}
}
...
@@ -116,7 +116,7 @@ func (conn *Connection) newGhost(pyclass pickle.Class, oid zodb.Oid) IPyPersiste
...
@@ -116,7 +116,7 @@ func (conn *Connection) newGhost(pyclass pickle.Class, oid zodb.Oid) IPyPersiste
if
classNew
!=
nil
{
if
classNew
!=
nil
{
instance
=
classNew
(
pyobj
)
instance
=
classNew
(
pyobj
)
}
else
{
}
else
{
instance
=
&
dummyPyInstance
{
pyObjec
t
:
pyobj
}
instance
=
&
dummyPyInstance
{
PyPersisten
t
:
pyobj
}
}
}
pyobj
.
instance
=
instance
pyobj
.
instance
=
instance
...
@@ -125,7 +125,7 @@ func (conn *Connection) newGhost(pyclass pickle.Class, oid zodb.Oid) IPyPersiste
...
@@ -125,7 +125,7 @@ func (conn *Connection) newGhost(pyclass pickle.Class, oid zodb.Oid) IPyPersiste
// dummyPyInstance is used for python classes that were not registered.
// dummyPyInstance is used for python classes that were not registered.
type
dummyPyInstance
struct
{
type
dummyPyInstance
struct
{
*
pyObjec
t
*
PyPersisten
t
pystate
interface
{}
pystate
interface
{}
}
}
...
...
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