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
46d7baf4
Commit
46d7baf4
authored
May 13, 2020
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
16059f7a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
2 deletions
+19
-2
wcfs/internal/xbtree.py
wcfs/internal/xbtree.py
+19
-2
No files found.
wcfs/internal/xbtree.py
View file @
46d7baf4
...
...
@@ -385,8 +385,14 @@ def Restructure(ztree, newStructure):
# set znode states according to established tnew->znode association
# bucket.embedded_in_tree will indicate that this bucket's state was
# embedded into containing tree node.
for
rb
in
rbucketv
:
rb
.
node
.
embedded_in_tree
=
False
rlevelv
=
rlevelv_orig
for
rnodev
in
r
levelv
:
for
rnodev
in
r
eversed
(
rlevelv
)
:
for
rn
in
rnodev
:
node
=
rn
.
node
assert
isinstance
(
node
,
(
Tree
,
Bucket
))
...
...
@@ -400,10 +406,12 @@ def Restructure(ztree, newStructure):
# empty bucket noone links to
if
len
(
child
.
keyv
)
==
0
and
child
.
prev_bucket
is
None
:
zstate
=
None
# -> empty tree
child
.
embedded_in_tree
=
True
# tree with single bucket noone links to
elif
child
.
Z
.
_p_oid
is
None
and
child
.
prev_bucket
is
None
:
zstate
=
((
child
.
Z
.
__getstate__
(),),)
# tree with bucket without oid
child
.
embedded_in_tree
=
True
if
zstate
is
unset
:
# normal tree node
...
...
@@ -415,10 +423,15 @@ def Restructure(ztree, newStructure):
zstate
=
(
zstate
,)
# firstbucket
zstate
+=
(
node
.
firstbucket
().
Z
,)
firstbucket
=
node
.
firstbucket
()
print
(
'firstbucket: %s (embedded: %s)'
%
(
firstbucket
,
firstbucket
.
embedded_in_tree
))
if
not
firstbucket
.
embedded_in_tree
:
zstate
+=
(
firstbucket
.
Z
,)
# https://github.com/zopefoundation/BTrees/blob/4.5.0-1-gc8bf24e/BTrees/BucketTemplate.c#L1195
if
isinstance
(
node
,
Bucket
):
# ignore .embedded_in_tree - wrt tree it won't make a
# difference if we change an object not reachable through it.
zstate
=
()
for
k
in
node
.
keyv
:
zstate
+=
(
k
,
kv
.
pop
(
k
))
# (k1, v1, k2, v2, ..., kN, vN)
...
...
@@ -434,6 +447,10 @@ def Restructure(ztree, newStructure):
assert
tnew
.
Z
is
ztree
assert
len
(
kv
)
==
0
# all keys must have been popped
print
()
print
(
'new struct:'
)
print
(
StructureOf
(
ztree
))
print
()
_bcheck
(
ztree
)
# verify ztree after our tweaks
tstruct
=
StructureOf
(
ztree
)
if
tstruct
!=
newStructure
:
...
...
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