Commit 3ab0c05c authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 52972b18
......@@ -375,6 +375,11 @@ func (A trackIndex) DifferenceInplace(B trackIndex) {
}
func (A trackIndex) xDifferenceInplace(B trackIndex, δnchild map[zodb.Oid]int) {
fmt.Printf("\n\n xDifferenceInplace:\n")
fmt.Printf(" a: %s\n", A)
fmt.Printf(" b: %s\n", B)
defer fmt.Printf(" ->d: %s\n", A)
// remove B.leafs and thier parents
for oid, t2 := range B {
if t2.nchild != 0 {
......@@ -386,7 +391,14 @@ func (A trackIndex) xDifferenceInplace(B trackIndex, δnchild map[zodb.Oid]int)
continue // already not there
}
// XXX assert t.parent == t2.parent ?
if t2.parent != t.parent {
// XXX or verify this at Track time and require
// that update is passed only entries with the
// same .parent? (then it would be ok to panic here)
// XXX -> error (e.g. due to corrupt data in ZODB)
panicf("node %s is reachable from multiple parents: %s %s",
oid, t.parent, t2.parent)
}
delete(A, oid)
if t.parent != zodb.InvalidOid {
......@@ -396,21 +408,29 @@ func (A trackIndex) xDifferenceInplace(B trackIndex, δnchild map[zodb.Oid]int)
}
func (A trackIndex) xUnionInplace(B trackIndex, δnchild map[zodb.Oid]int) {
// process additions
fmt.Printf("\n\n xUnionInplace:\n")
fmt.Printf(" a: %s\n", A)
fmt.Printf(" b: %s\n", B)
defer fmt.Printf(" ->u: %s\n", A)
for oid, t2 := range B {
t, already := A[oid]
if already {
if !already {
t = &nodeTrack{parent: t2.parent, nchild: 0}
A[oid] = t
// remeber to nchild++ in parent
if t.parent != zodb.InvalidOid {
δnchild[t.parent] -= 1
t.parent = t2.parent
δnchild[t.parent] += 1
}
} else {
t = &nodeTrack{parent: t2.parent, nchild: 0}
A[oid] = t
if t2.parent != t.parent {
// XXX or verify this at Track time and require
// that update is passed only entries with the
// same .parent? (then it would be ok to panic here)
// XXX -> error (e.g. due to corrupt data in ZODB)
panicf("node %s is reachable from multiple parents: %s %s",
oid, t.parent, t2.parent)
}
if t.parent != zodb.InvalidOid {
δnchild[t.parent] += 1 // remeber to nchild++ in parent
}
}
}
......
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