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
af686f0f
Commit
af686f0f
authored
Jul 19, 2018
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
3c1df9e8
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
60 additions
and
5 deletions
+60
-5
wcfs/btree.go
wcfs/btree.go
+60
-5
No files found.
wcfs/btree.go
View file @
af686f0f
...
...
@@ -180,8 +180,62 @@ func (t *ZBTree) DropState() {
}
// PySetState implements PyStateful to set btree data from pystate.
func
(
t
*
ZBTree
)
PySetState
(
pystate
interface
{})
error
{
panic
(
"TODO"
)
func
(
bt
*
ZBTree
)
PySetState
(
pystate
interface
{})
error
{
// empty btree
if
_
,
ok
:=
pystate
.
(
pickle
.
None
);
ok
{
bt
.
firstbucket
=
nil
bt
.
data
=
nil
return
nil
}
t
,
ok
:=
pystate
.
(
pickle
.
Tuple
)
if
!
ok
||
!
(
1
<=
len
(
t
)
&&
len
(
t
)
<=
2
)
{
// XXX
}
// btree with 1 child bucket without oid
if
len
(
t
)
==
1
{
// TODO
}
// regular btree
t
,
ok
=
t
[
0
]
.
(
pickle
.
Tuple
)
if
!
(
ok
&&
len
(
t
)
%
2
==
0
)
{
// XXX
}
bt
.
firstbucket
,
ok
=
t
[
1
]
.
(
*
ZBucket
)
if
!
ok
{
// XXX
}
n
:=
len
(
t
)
/
2
bt
.
data
=
make
([]
zBTreeItem
,
0
,
n
)
for
i
,
idx
:=
0
,
0
;
i
<
n
;
i
++
{
key
:=
int64
(
0
)
if
i
>
0
{
// key[0] is unused and not saved
key
,
ok
=
t
[
idx
]
.
(
int64
)
// XXX Xint
if
!
ok
{
// XXX
}
idx
++
}
child
:=
t
[
idx
]
idx
++
switch
child
.
(
type
)
{
default
:
// XXX
case
*
ZBTree
:
// ok
case
*
ZBucket
:
// ok
}
bt
.
data
=
append
(
bt
.
data
,
zBTreeItem
{
key
:
KEY
(
key
),
child
:
child
})
}
return
nil
}
...
...
@@ -234,11 +288,12 @@ func (b *ZBucket) PySetState(pystate interface{}) error {
xk
:=
t
[
2
*
i
]
v
:=
t
[
2
*
i
+
1
]
k
,
ok
:=
xk
.
(
int64
)
// XXX use KEY
k
,
ok
:=
xk
.
(
int64
)
// XXX use KEY
XXX -> Xint64
if
!
ok
{
// XXX
}
// XXX check keys are sorted?
b
.
keys
=
append
(
b
.
keys
,
KEY
(
k
))
// XXX cast
b
.
values
=
append
(
b
.
values
,
v
)
}
...
...
@@ -249,8 +304,8 @@ func (b *ZBucket) PySetState(pystate interface{}) error {
// ---- register classes to ZODB ----
func
bucketNew
(
pyobj
*
PyPersistent
)
IPyPersistent
{
return
&
ZBucket
{
PyPersistent
:
pyobj
}
}
func
btreeNew
(
pyobj
*
PyPersistent
)
IPyPersistent
{
return
&
ZBTree
{
PyPersistent
:
pyobj
}
}
func
bucketNew
(
base
*
PyPersistent
)
IPyPersistent
{
return
&
ZBucket
{
PyPersistent
:
base
}
}
func
btreeNew
(
base
*
PyPersistent
)
IPyPersistent
{
return
&
ZBTree
{
PyPersistent
:
base
}
}
func
init
()
{
registerPyClass
(
"zodb.BTree.LOBucket"
,
bucketNew
)
...
...
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