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
8ae42901
Commit
8ae42901
authored
May 12, 2020
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
82a5c353
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
24 deletions
+29
-24
wcfs/internal/xbtree.py
wcfs/internal/xbtree.py
+29
-24
No files found.
wcfs/internal/xbtree.py
View file @
8ae42901
...
...
@@ -292,37 +292,42 @@ def Restructure(ztree, newStructure):
# set znode states according to established tnew->znode association
for
nodev
in
levelv
:
for
node
in
nodev
:
for
rnodev
in
rlevelv
:
for
rn
in
rnodev
:
node
=
rn
.
node
assert
isinstance
(
node
,
Tree
)
# buckets were filtered out to rbucketv
znode
=
node
.
Z
if
isinstance
(
node
,
Bucket
):
# https://github.com/zopefoundation/BTrees/blob/4.5.0-1-gc8bf24e/BTrees/BucketTemplate.c#L1195
zstate
=
()
for
k
in
node
.
keyv
:
zstate
+=
(
k
,
kv
.
pop
(
k
))
# (k1, v1, k2, v2, ..., kN, vN)
zstate
=
(
zstate
,)
# https://github.com/zopefoundation/BTrees/blob/4.5.0-1-gc8bf24e/BTrees/BTreeTemplate.c#L1087
if
len
(
node
.
keyv
)
==
0
:
panic
(
"TODO: empty tree + tree with bucket without oid"
)
if
node
.
next_bucket
is
not
None
:
# next
zstate
+=
(
node
.
next_bucket
.
Z
,)
zstate
=
()
assert
len
(
node
.
children
)
==
len
(
node
.
keyv
)
+
1
zstate
+=
node
.
children
[
0
]
for
(
child
,
k
)
in
zip
(
node
.
children
[
1
:],
node
.
keyv
):
zstate
+=
(
k
,
child
)
# (child0, k0, child1, k1, ..., childN, kN, childN+1)
zstate
=
(
zstate
,)
else
:
assert
isinstance
(
node
,
Tree
)
# https://github.com/zopefoundation/BTrees/blob/4.5.0-1-gc8bf24e/BTrees/BTreeTemplate.c#L1087
if
len
(
node
.
keyv
)
==
0
:
panic
(
"TODO: empty tree + tree with bucket without oid"
)
# firstbucket
zstate
+=
(
None
,)
# XXX
znode
.
__setstate__
(
zstate
)
zstate
=
()
assert
len
(
node
.
children
)
==
len
(
node
.
keyv
)
+
1
zstate
+=
node
.
children
[
0
]
for
(
child
,
k
)
in
zip
(
node
.
children
[
1
:],
node
.
keyv
):
zstate
+=
(
k
,
child
)
# (child0, k0, child1, k1, ..., childN, kN, childN+1)
zstate
=
(
zstate
,)
# ----//---- for buckets
for
rbucket
in
rbucketv
:
node
=
rbucket
.
node
# firstbucket
zstate
+=
(
None
,)
# XXX
# https://github.com/zopefoundation/BTrees/blob/4.5.0-1-gc8bf24e/BTrees/BucketTemplate.c#L1195
zstate
=
()
for
k
in
node
.
keyv
:
zstate
+=
(
k
,
kv
.
pop
(
k
))
# (k1, v1, k2, v2, ..., kN, vN)
zstate
=
(
zstate
,)
znode
.
__setstate__
(
zstate
)
if
node
.
next_bucket
is
not
None
:
# next
zstate
+=
(
node
.
next_bucket
.
Z
,)
node
.
Z
.
__setstate__
(
zstate
)
assert
tnew
.
Z
is
ztree
...
...
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