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
61eeb509
Commit
61eeb509
authored
May 22, 2020
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
3913a125
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
3 deletions
+19
-3
wcfs/internal/xbtree.py
wcfs/internal/xbtree.py
+19
-3
No files found.
wcfs/internal/xbtree.py
View file @
61eeb509
...
...
@@ -731,7 +731,7 @@ def __zwalkBFS(ztree): # i[] of [](of _NodeInRange on each level)
# TopoEncode returns topology encoding for internal structure of the tree.
#
# See top-level docstring for description of topology encoding.
def
TopoEncode
(
tree
):
def
TopoEncode
(
tree
,
vencode
=
lambda
v
:
'%d'
%
v
):
# XXX vencode document
assert
isinstance
(
tree
,
Tree
)
topo
=
''
...
...
@@ -742,8 +742,23 @@ def TopoEncode(tree):
tnodev
=
[]
for
node
in
nodev
:
assert
isinstance
(
node
,
(
Tree
,
Bucket
))
tnode
=
(
'T'
if
isinstance
(
node
,
Tree
)
else
'B'
)
+
\
(
','
.
join
([
'%d'
%
_
for
_
in
node
.
keyv
]))
tnode
=
(
'T'
if
isinstance
(
node
,
Tree
)
else
'B'
)
if
isinstance
(
node
,
Bucket
)
and
node
.
valuev
is
not
None
:
# bucket with key and values
assert
len
(
node
.
valuev
)
==
len
(
node
.
keyv
)
vtxtv
=
[]
for
v
in
node
.
valuev
:
vtxt
=
vencode
(
v
)
assert
' '
not
in
vtxt
assert
':'
not
in
vtxt
assert
','
not
in
vtxt
assert
'-'
not
in
vtxt
tnode
+=
','
.
join
([
'%d:%s'
%
(
k
,
vtxt
)
for
(
k
,
vtxt
)
in
zip
(
node
.
keyv
,
vtxtv
)])
else
:
# tree or bucket with keys
tnode
+=
','
.
join
([
'%d'
%
_
for
_
in
node
.
keyv
])
tnodev
.
append
(
tnode
)
topo
+=
'-'
.
join
(
tnodev
)
...
...
@@ -761,6 +776,7 @@ class TopoDecodeError(Exception):
pass
def
TopoDecode
(
text
,
vdecode
=
int
):
# XXX vdecode - document
levelv
=
text
.
split
(
'/'
)
# T3/T-T/B1:a-T5/B-B7,8,9 -> T3 T-T B1:a-T5 B-B7,8,9
# XXX forbid mixing buckets-with-value with buckets-without-value?
# build nodes from bottom-up
currentv
=
[]
# of nodes on current level (that we are building)
...
...
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