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.
- `Tree` represents a tree 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.
- `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)
# 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.
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. Eatch 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
......
......@@ -25,7 +25,7 @@ from wendelin.wcfs.internal import xbtree
from BTrees.LOBTree import LOBTree
from BTrees.tests import testBTrees
def test_topologyOf():
def test_structureOf():
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
......
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