Commit ca596ec5 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 6e63c63d
......@@ -189,7 +189,6 @@ type trackIndex map[zodb.Oid]*nodeTrack
// XXX place
// nodeTrack represents tracking information about a node.
//// XXX kill (parentIdx is just {} oid -> oid)
type nodeTrack struct {
parent zodb.Oid // parent node | InvalidOid for root
nchild int // number of direct children in trackIdx referring to this node
......@@ -199,19 +198,24 @@ type nodeTrack struct {
*/
}
// δtrackIndex represents changes to trackIndex.
// δtrackIndex represents change to trackIndex.
// XXX place
type δtrackIndex struct {
// set of leaf nodes to remove. After leafs are removed, their parents are automatically cleaned up.
// removals are processed before adds (see below).
// set of leaf nodes to remove. After leafs are removed, their parents
// are automatically cleaned down-up. Removals are processed before
// adds (see below).
DelLeaf SetOid
// nodes to add
// nodes to add XXX -> add/modify ?
Add trackIndex
}
// ApplyΔ applies δ to trackIdx. XXX
func (tidx trackIndex) ApplyΔ(δ *δtrackIndex) {
//fmt.Printf("\n\nApplyΔ\n")
//fmt.Printf("\tDelLeaf: %v\n", δ.DelLeaf)
//fmt.Printf("\tAdd: %v\n", δ.Add)
// remove leafs and thier parents
for leaf := range δ.DelLeaf {
t, present := tidx[leaf]
......@@ -237,20 +241,22 @@ func (tidx trackIndex) ApplyΔ(δ *δtrackIndex) {
for oid, δt := range δ.Add {
t, already := tidx[oid]
if already {
// XXX but check if with the same parent
if t.parent != δt.parent {
panic("TODO")
if t.parent != zodb.InvalidOid {
δnchild[t.parent] -= 1
t.parent = δt.parent
}
continue // object already tracked
} else {
t = &nodeTrack{parent: δt.parent, nchild: 0}
tidx[oid] = t
}
tidx[oid] = &nodeTrack{parent: δt.parent, nchild: 0}
if δt.parent != zodb.InvalidOid {
δnchild[δt.parent] += 1 // remeber to nchild++ in parent
if t.parent != zodb.InvalidOid {
δnchild[t.parent] += 1 // remeber to nchild++ in parent
}
}
for parent, δnc := range δnchild {
tidx[parent].nchild += δnc
// XXX .nchild == 0 - remove ?
}
}
......
......@@ -1040,6 +1040,9 @@ func TestΔBTail(t *testing.T) {
"T/T1/B0:a-B1:b",
"T/T1/T-T/B0:c-B1:d",
// "T/T/T/B1:a,2:b",
// "T/T/B1:a",
// found by AllStructs (trackIdx2 wrongly computed due to top
// not being tracked to tree root)
"T2/T1-T/B0:g-B1:b-T/B2:b,3:a",
......
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