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
1bbc897a
Commit
1bbc897a
authored
Jul 13, 2018
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
6e858c16
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
25 additions
and
19 deletions
+25
-19
wcfs/btree.go
wcfs/btree.go
+12
-9
wcfs/zblk.go
wcfs/zblk.go
+5
-4
wcfs/zodb.go
wcfs/zodb.go
+8
-6
No files found.
wcfs/btree.go
View file @
1bbc897a
...
@@ -18,7 +18,8 @@ import (
...
@@ -18,7 +18,8 @@ import (
"context"
"context"
"sort"
"sort"
"lab.nexedi.com/kirr/neo/go/zodb"
//"lab.nexedi.com/kirr/neo/go/zodb"
pickle
"github.com/kisielk/og-rek"
)
)
// XXX -> template
// XXX -> template
...
@@ -35,7 +36,7 @@ type KEY int64
...
@@ -35,7 +36,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
{
pyobj
*
zodb
.
PyObject
pyobj
*
PyObject
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
...
@@ -53,7 +54,7 @@ type zBTreeItem struct {
...
@@ -53,7 +54,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
{
pyobj
*
zodb
.
PyObject
pyobj
*
PyObject
// 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
...
@@ -194,7 +195,7 @@ func (b *ZBucket) PActivate(ctx context.Context) error {
...
@@ -194,7 +195,7 @@ func (b *ZBucket) PActivate(ctx context.Context) error {
}
}
t
,
ok
:=
b
.
pyobj
.
pystate
.
(
pickle
.
Tuple
)
t
,
ok
:=
b
.
pyobj
.
pystate
.
(
pickle
.
Tuple
)
if
!
ok
||
!
(
1
<=
len
(
q
)
&&
len
(
q
)
<=
2
)
{
if
!
ok
||
!
(
1
<=
len
(
t
)
&&
len
(
t
)
<=
2
)
{
// XXX complain
// XXX complain
}
}
...
@@ -206,13 +207,13 @@ func (b *ZBucket) PActivate(ctx context.Context) error {
...
@@ -206,13 +207,13 @@ func (b *ZBucket) PActivate(ctx context.Context) error {
}
}
// main part
// main part
t
,
ok
=
t
[
0
]
.
(
pickle
t
.
Tuple
)
t
,
ok
=
t
[
0
]
.
(
pickle
.
Tuple
)
// XXX if !ok || (len(t) % 2 != 0)
// XXX if !ok || (len(t) % 2 != 0)
// reset arrays just in case
// reset arrays just in case
n
:=
len
(
t
)
/
2
n
:=
len
(
t
)
/
2
t
.
keys
=
make
([]
KEY
,
0
,
n
)
b
.
keys
=
make
([]
KEY
,
0
,
n
)
t
.
values
=
make
([]
interface
{},
0
,
n
)
b
.
values
=
make
([]
interface
{},
0
,
n
)
for
i
:=
0
;
i
<
n
;
i
++
{
for
i
:=
0
;
i
<
n
;
i
++
{
xk
:=
t
[
2
*
i
]
xk
:=
t
[
2
*
i
]
...
@@ -221,7 +222,9 @@ func (b *ZBucket) PActivate(ctx context.Context) error {
...
@@ -221,7 +222,9 @@ func (b *ZBucket) PActivate(ctx context.Context) error {
k
,
ok
:=
xk
.
(
int64
)
// XXX use KEY
k
,
ok
:=
xk
.
(
int64
)
// XXX use KEY
// XXX if !ok
// XXX if !ok
t
.
keys
=
append
(
t
.
keys
,
k
)
b
.
keys
=
append
(
b
.
keys
,
KEY
(
k
))
// XXX cast
t
.
values
=
append
(
t
.
values
,
v
)
b
.
values
=
append
(
b
.
values
,
v
)
}
}
return
nil
}
}
wcfs/zblk.go
View file @
1bbc897a
...
@@ -24,7 +24,8 @@ package main
...
@@ -24,7 +24,8 @@ package main
import
(
import
(
"context"
"context"
"lab.nexedi.com/kirr/neo/go/zodb"
//"lab.nexedi.com/kirr/neo/go/zodb"
pickle
"github.com/kisielk/og-rek"
)
)
...
@@ -38,7 +39,7 @@ import (
...
@@ -38,7 +39,7 @@ import (
// ZBigFile mimics ZBigFile from python.
// ZBigFile mimics ZBigFile from python.
type
ZBigFile
struct
{
type
ZBigFile
struct
{
pyobj
*
zodb
.
PyObject
pyobj
*
PyObject
blksize
int64
blksize
int64
blktab
*
ZBTree
// LOBtree{} blk -> ZBlk*(blkdata)
blktab
*
ZBTree
// LOBtree{} blk -> ZBlk*(blkdata)
...
@@ -121,12 +122,12 @@ func (bf *ZBigFile) PActivate(ctx context.Context) (err error) {
...
@@ -121,12 +122,12 @@ func (bf *ZBigFile) PActivate(ctx context.Context) (err error) {
}()
}()
// decode pystate
// decode pystate
t
,
ok
:=
pyobj
.
PyS
tate
.
(
pickle
.
Tuple
)
t
,
ok
:=
bf
.
pyobj
.
pys
tate
.
(
pickle
.
Tuple
)
if
!
ok
||
len
(
t
)
!=
2
{
if
!
ok
||
len
(
t
)
!=
2
{
// XXX expected (.blksize, blktab)
// XXX expected (.blksize, blktab)
}
}
blksize
,
ok
=
pickletools
.
Xint64
(
t
[
0
])
blksize
,
ok
:
=
pickletools
.
Xint64
(
t
[
0
])
// XXX if !ok
// XXX if !ok
blktab
,
ok
:=
t
[
1
]
.
(
*
ZBTree
)
blktab
,
ok
:=
t
[
1
]
.
(
*
ZBTree
)
...
...
wcfs/zodb.go
View file @
1bbc897a
...
@@ -50,12 +50,13 @@ type Connection struct {
...
@@ -50,12 +50,13 @@ type Connection struct {
// XXX this is needed if there are several persistent references to the same object.
// XXX this is needed if there are several persistent references to the same object.
// however wendelin.core does not do this.
// however wendelin.core does not do this.
func
(
conn
*
Connection
)
Get
(
ctx
context
.
Context
,
oid
zodb
.
Oid
)
(
*
PyObject
,
error
)
{
func
(
conn
*
Connection
)
Get
(
ctx
context
.
Context
,
oid
zodb
.
Oid
)
(
*
PyObject
,
error
)
{
buf
,
serial
,
err
:=
stor
.
Load
(
ctx
,
zodb
.
Xid
{
Oid
:
oid
,
At
:
conn
.
at
})
// XXX -> loadpy
buf
,
serial
,
err
:=
conn
.
stor
.
Load
(
ctx
,
zodb
.
Xid
{
Oid
:
oid
,
At
:
conn
.
at
})
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
pyclass
,
pystate
,
err
:=
zodb
.
PyData
(
buf
.
Data
()
)
.
Decode
()
pyclass
,
pystate
,
err
:=
zodb
.
PyData
(
buf
.
Data
)
.
Decode
()
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
// XXX err ctx
return
nil
,
err
// XXX err ctx
}
}
...
@@ -70,14 +71,14 @@ func (conn *Connection) Get(ctx context.Context, oid zodb.Oid) (*PyObject, error
...
@@ -70,14 +71,14 @@ func (conn *Connection) Get(ctx context.Context, oid zodb.Oid) (*PyObject, error
}
}
func
(
conn
*
Connection
)
loadpy
(
ctx
context
.
Context
,
oid
zodb
.
Oid
)
(
pyclass
pickle
.
Class
,
pystate
interface
{},
serial
zodb
.
Tid
,
_
error
)
{
func
(
conn
*
Connection
)
loadpy
(
ctx
context
.
Context
,
oid
zodb
.
Oid
)
(
pyclass
pickle
.
Class
,
pystate
interface
{},
serial
zodb
.
Tid
,
_
error
)
{
buf
,
serial
,
err
:=
stor
.
Load
(
ctx
,
zodb
.
Xid
{
Oid
:
oid
,
At
:
conn
.
at
})
buf
,
serial
,
err
:=
conn
.
stor
.
Load
(
ctx
,
zodb
.
Xid
{
Oid
:
oid
,
At
:
conn
.
at
})
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
pickle
.
Class
{},
nil
,
zodb
.
InvalidTID
,
err
}
}
pyclass
,
pystate
,
err
:=
zodb
.
PyData
(
buf
.
Data
()
)
.
Decode
()
pyclass
,
pystate
,
err
=
zodb
.
PyData
(
buf
.
Data
)
.
Decode
()
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
// XXX err ctx
return
pickle
.
Class
{},
nil
,
zodb
.
InvalidTID
,
err
// XXX err ctx
}
}
buf
.
Release
()
buf
.
Release
()
...
@@ -127,4 +128,5 @@ func (pyobj *PyObject) PActivate(ctx context.Context) error {
...
@@ -127,4 +128,5 @@ func (pyobj *PyObject) PActivate(ctx context.Context) error {
pyobj
.
serial
=
serial
pyobj
.
serial
=
serial
pyobj
.
pystate
=
pystate
pyobj
.
pystate
=
pystate
return
nil
}
}
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