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
02d9a1bd
Commit
02d9a1bd
authored
May 07, 2020
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
410bca9c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
48 additions
and
14 deletions
+48
-14
wcfs/internal/xbtree.py
wcfs/internal/xbtree.py
+43
-13
wcfs/internal/xbtree_test.py
wcfs/internal/xbtree_test.py
+5
-1
No files found.
wcfs/internal/xbtree.py
View file @
02d9a1bd
...
...
@@ -25,18 +25,52 @@ It is primarily used to verify ΔBTail in wcfs.
- `Tree` represents a tree node.
- `Bucket` represents a bucket node.
- `StrctureOf` returns internal structure of a BTree represented as Tree and
- `Str
u
ctureOf` returns internal structure of a BTree represented as Tree and
Bucket nodes.
- `Restructure` XXX
- GenStructs
- `AllStructs` XXX
Topology encoding
-----------------
XXX Typology:
- TopoEncode XXX
- TopoDecode
Topology encoding provides way to represent structure of a Tree as path-like string.
TopoEncode converts Tree into its topology-encoded representation, while
TopoDecode decodes topology-encoded string back into Tree.
The following example illustrates topology encoding represented by string
"T3/T-T/B1-T5/B-B7,8,9":
[ 3 ] T3/ represents Tree([3])
/
\
[ ] [ ] T-T/ represents two empty Tree([])
↓ ↓
|1|[ 5 ] B1-T5/ represent Bucket(1) and Tree([5])
/
\
|| |7|8|9| B-B7,8,9 represents empty Bucket() and Bucket(7,8,9)
Topology encoding is specified as follows:
A Tree is encoded by depth-order traversal, delimiting layers with "/".
Inside a layer Tree and Bucket nodes are signalled as
"T<keys>" ; Tree
"B<keys>" ; Bucket
Keys are represented as ","-delimited list of integers. For example Tree
with [1,3,5] keys is represented as
"T1,3,5" ; Tree([1,3,5])
Nodes inside one layer are delimited with "-". For example a layer consisting
of an empty Tree, a Tree with [1,3] keys, and Bucket with [4,5] keys is
represented as
"T-T1,3-B4,5" ; layer with Tree([]), Tree([1,3]) and Bucket([4,5])
"""
from
__future__
import
print_function
,
absolute_import
...
...
@@ -140,15 +174,11 @@ def StructureOf(node):
panic
(
"unknown node type %r"
%
typ
)
# T
y
poEncode returns topology encoding for internal structure of the tree.
# T
o
poEncode returns topology encoding for internal structure of the tree.
#
# See top-level docstring for what topology is.
def
TypoEncode
(
tree
):
treeStruct
=
StructureOf
(
tree
)
return
topoEncode
(
treeStruct
)
def
topoEncode
(
treeStruct
):
1
/
0
def
TopoEncode
(
tree
):
assert
isinstance
(
tree
,
Tree
)
# TopoDecode decodes topology-encoded text into Tree structure.
...
...
@@ -166,7 +196,7 @@ def Restructure(tree, newStructure):
1
/
0
# AllStructs generates subset of all possible BTree structures for BTrees with
# specified keys and btree depth up-to maxdepth. Ea
t
ch tree node is split by
# specified keys and btree depth up-to maxdepth. Each tree node is split by
# up-to maxsplit points.
def
AllStructs
(
keys
,
maxdepth
,
maxsplit
):
# -> i[] of Tree
assert
isinstance
(
maxdepth
,
int
);
assert
maxdepth
>=
0
...
...
wcfs/internal/xbtree_test.py
View file @
02d9a1bd
...
...
@@ -25,7 +25,7 @@ from wendelin.wcfs.internal import xbtree
from
BTrees.LOBTree
import
LOBTree
from
BTrees.tests
import
testBTrees
def
test_
topology
Of
():
def
test_
structure
Of
():
T
=
xbtree
.
Tree
B
=
xbtree
.
Bucket
...
...
@@ -73,6 +73,10 @@ def test_topologyOf():
(((), ()), (6, 10)),
"""
def
test_topoEncoding
():
1
/
0
def
test_AllStructs
():
T
=
xbtree
.
Tree
B
=
xbtree
.
Bucket
...
...
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