Commit db2d5e41 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 78ca2fad
......@@ -89,6 +89,8 @@ func (S PPTreeSubSet) Path(oid zodb.Oid) (path []zodb.Oid) {
}
// AddPath adds path to a node to the set.
//
// Note: embedded buckets (leaf node with InvalidOid) are removed from the path.
func (S PPTreeSubSet) AddPath(path []zodb.Oid) {
S.verify()
defer S.verify()
......@@ -98,6 +100,8 @@ func (S PPTreeSubSet) AddPath(path []zodb.Oid) {
panic("empty path")
}
path = normPath(path)
/*
// don't keep track of artificial empty tree
if l == 1 && path[0] == zodb.InvalidOid {
return
......@@ -109,6 +113,7 @@ func (S PPTreeSubSet) AddPath(path []zodb.Oid) {
if l == 2 && path[1] == zodb.InvalidOid {
path = path[:1]
}
*/
parent := zodb.InvalidOid
var pt *nodeInTree = nil
......@@ -137,6 +142,28 @@ func (S PPTreeSubSet) AddPath(path []zodb.Oid) {
}
}
// normPath normalizes path.
//
// It removes embedded buckets and artificial empty trees.
// Returned slice is subslice of path and aliases its memory.
func normPath(path []zodb.Oid) []zodb.Oid {
l := len(path)
// don't keep track of artificial empty tree
if l == 1 && path[0] == zodb.InvalidOid {
return nil
}
// don't explicitly keep track of embedded buckets - they all have
// InvalidOid, and thus, if kept in S, e.g. T/B1:a and another
// T/B2:b would lead to InvalidOid having multiple parents.
if l == 2 && path[1] == zodb.InvalidOid {
return path[:1]
}
return path
}
// ---- Union/Difference/Intersetctior ----
// Union returns U = PP(A.leafs | B.leafs)
......
......@@ -249,9 +249,16 @@ func (δBtail *ΔBtail) Track(key Key, nodePath []Node) error { // XXX Tree|Buck
func (δBtail *ΔBtail) track(key Key, path []zodb.Oid) error {
// XXX locking
root := path[0]
// first normalize path: remove embedded bucket and check if it was an
// empty artificial tree. We need to do the normalization becase we
// later check whether leaf path[-1] ∈ trackSet and without
// normalization path[-1] can be InvalidOid.
path = normPath(path)
if len(path) == 0 {
return nil // empty tree
}
// XXX first normalize path
root := path[0]
// nothing to do if key is already tracked
leaf := path[len(path)-1]
......
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