Commit ca596ec5 authored by Kirill Smelkov's avatar Kirill Smelkov

.

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