Commit 02d9a1bd authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 410bca9c
...@@ -25,18 +25,52 @@ It is primarily used to verify ΔBTail in wcfs. ...@@ -25,18 +25,52 @@ It is primarily used to verify ΔBTail in wcfs.
- `Tree` represents a tree node. - `Tree` represents a tree node.
- `Bucket` represents a bucket node. - `Bucket` represents a bucket node.
- `StrctureOf` returns internal structure of a BTree represented as Tree and - `StructureOf` returns internal structure of a BTree represented as Tree and
Bucket nodes. Bucket nodes.
- `Restructure` XXX - `Restructure` XXX
- GenStructs - `AllStructs` XXX
Topology encoding Topology encoding
----------------- -----------------
XXX Typology: Topology encoding provides way to represent structure of a Tree as path-like string.
- TopoEncode XXX
- TopoDecode 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 from __future__ import print_function, absolute_import
...@@ -140,15 +174,11 @@ def StructureOf(node): ...@@ -140,15 +174,11 @@ def StructureOf(node):
panic("unknown node type %r" % typ) panic("unknown node type %r" % typ)
# TypoEncode returns topology encoding for internal structure of the tree. # TopoEncode returns topology encoding for internal structure of the tree.
# #
# See top-level docstring for what topology is. # See top-level docstring for what topology is.
def TypoEncode(tree): def TopoEncode(tree):
treeStruct = StructureOf(tree) assert isinstance(tree, Tree)
return topoEncode(treeStruct)
def topoEncode(treeStruct):
1/0
# TopoDecode decodes topology-encoded text into Tree structure. # TopoDecode decodes topology-encoded text into Tree structure.
...@@ -166,7 +196,7 @@ def Restructure(tree, newStructure): ...@@ -166,7 +196,7 @@ def Restructure(tree, newStructure):
1/0 1/0
# AllStructs generates subset of all possible BTree structures for BTrees with # AllStructs generates subset of all possible BTree structures for BTrees with
# specified keys and btree depth up-to maxdepth. Eatch tree node is split by # specified keys and btree depth up-to maxdepth. Each tree node is split by
# up-to maxsplit points. # up-to maxsplit points.
def AllStructs(keys, maxdepth, maxsplit): # -> i[] of Tree def AllStructs(keys, maxdepth, maxsplit): # -> i[] of Tree
assert isinstance(maxdepth, int); assert maxdepth >= 0 assert isinstance(maxdepth, int); assert maxdepth >= 0
......
...@@ -25,7 +25,7 @@ from wendelin.wcfs.internal import xbtree ...@@ -25,7 +25,7 @@ from wendelin.wcfs.internal import xbtree
from BTrees.LOBTree import LOBTree from BTrees.LOBTree import LOBTree
from BTrees.tests import testBTrees from BTrees.tests import testBTrees
def test_topologyOf(): def test_structureOf():
T = xbtree.Tree T = xbtree.Tree
B = xbtree.Bucket B = xbtree.Bucket
...@@ -73,6 +73,10 @@ def test_topologyOf(): ...@@ -73,6 +73,10 @@ def test_topologyOf():
(((), ()), (6, 10)), (((), ()), (6, 10)),
""" """
def test_topoEncoding():
1/0
def test_AllStructs(): def test_AllStructs():
T = xbtree.Tree T = xbtree.Tree
B = xbtree.Bucket B = xbtree.Bucket
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment