Commit d4848186 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 1a0cfd54
...@@ -44,9 +44,7 @@ const debugPPSet = false ...@@ -44,9 +44,7 @@ const debugPPSet = false
// Nodes can be added into the set via AddPath. Path is reverse operation - it // Nodes can be added into the set via AddPath. Path is reverse operation - it
// returns path to tree node given node oid. // returns path to tree node given node oid.
// //
// XXX ΔPPTreeSubSet // Every node in the set comes with .parent pointer.
//
// Every node in the set also has .parent pointer. XXX
type PPTreeSubSet map[zodb.Oid]*nodeInTree type PPTreeSubSet map[zodb.Oid]*nodeInTree
// nodeInTree represents tracking information about a node. // nodeInTree represents tracking information about a node.
...@@ -57,7 +55,7 @@ type nodeInTree struct { ...@@ -57,7 +55,7 @@ type nodeInTree struct {
} }
// Path returns path leading to node specified by oid. // Path returns path leading to the node specified by oid.
// //
// The node must be in the set. // The node must be in the set.
func (S PPTreeSubSet) Path(oid zodb.Oid) (path []zodb.Oid) { func (S PPTreeSubSet) Path(oid zodb.Oid) (path []zodb.Oid) {
...@@ -96,37 +94,29 @@ func (S PPTreeSubSet) AddPath(path []zodb.Oid) { ...@@ -96,37 +94,29 @@ func (S PPTreeSubSet) AddPath(path []zodb.Oid) {
} }
parent := zodb.InvalidOid parent := zodb.InvalidOid
var ptrack *nodeInTree = nil var pt *nodeInTree = nil
var track *nodeInTree // XXX kill here
var oldTrack bool
for _, oid := range path { for _, oid := range path {
if oid == zodb.InvalidOid { if oid == zodb.InvalidOid {
panicf("path has node with invalid oid: %v", path) panicf("path has node with invalid oid: %v", path)
} }
track, oldTrack = S[oid] t, already := S[oid]
if !oldTrack { if !already {
track = &nodeInTree{parent: parent, nchild: 0} // XXX t = &nodeInTree{parent: parent, nchild: 0}
/* S[oid] = t
if i == l-1 { // leaf
track.holes = SetKey{}
}
*/
S[oid] = track
// XXX .trackNew += oid
} }
if track.parent != parent { if t.parent != parent {
// XXX -> error (e.g. due to corrupt data in ZODB) ? // XXX -> error (e.g. due to corrupt data in ZODB) ?
panicf("node %s is reachable from multiple parents: %s %s", panicf("node %s is reachable from multiple parents: %s %s",
oid, track.parent, parent) oid, t.parent, parent)
} }
if ptrack != nil && !oldTrack { if pt != nil && !already {
ptrack.nchild++ pt.nchild++
} }
parent = oid parent = oid
ptrack = track pt = t
} }
} }
......
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