Commit abc32c71 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 41eab70a
...@@ -214,8 +214,42 @@ type δtrackIndex struct { ...@@ -214,8 +214,42 @@ type δtrackIndex struct {
// panic("TODO") // panic("TODO")
//} //}
func (tidx trackIndex) ApplyΔ(δtidx *δtrackIndex) { // ApplyΔ applies δ to trackIdx. XXX
panic("TODO") func (tidx trackIndex) ApplyΔ(δ *δtrackIndex) {
// remove leafs and thier parents
for leaf := range δ.DelLeaf {
t, present := tidx[leaf]
if !present {
continue // leaf already not there
}
delete(tidx, leaf)
parent := t.parent
for parent != zodb.InvalidOid {
t := tidx[parent]
t.nchild--
if t.nchild > 0 {
break
}
delete(tidx, parent)
parent = t.parent
}
}
// process adds
δnchild := map[zodb.Oid]int{}
for oid, δt := range δ.Add {
_, already := tidx[oid]
if already {
continue // object already tracked
}
tidx[oid] = &nodeTrack{parent: δt.parent, nchild: 0}
δnchild[δt.parent] += 1 // remeber to nchild++ in parent
}
for parent, δnc := range δnchild {
tidx[parent].nchild += δnc
}
} }
// treeSetKey represents ordered set of keys. // treeSetKey represents ordered set of keys.
...@@ -803,8 +837,12 @@ func diffX(ctx context.Context, a, b Node, δZTC SetOid, trackIdx trackIndex, ho ...@@ -803,8 +837,12 @@ func diffX(ctx context.Context, a, b Node, δZTC SetOid, trackIdx trackIndex, ho
if isT { if isT {
return diffT(ctx, aT, bT, δZTC, trackIdx, holeIdx) return diffT(ctx, aT, bT, δZTC, trackIdx, holeIdx)
} else { } else {
var δtrack *δtrackIndex
δ, err := diffB(ctx, aB, bB) δ, err := diffB(ctx, aB, bB)
return δ, /*δtrack*/nil, err // XXX ok? if δ != nil {
δtrack = &δtrackIndex{}
}
return δ, δtrack, err
} }
} }
...@@ -823,6 +861,7 @@ func diffT(ctx context.Context, A, B *Tree, δZTC SetOid, trackIdx trackIndex, h ...@@ -823,6 +861,7 @@ func diffT(ctx context.Context, A, B *Tree, δZTC SetOid, trackIdx trackIndex, h
if B == nil { panic("B is nil") } if B == nil { panic("B is nil") }
δ = map[Key]ΔValue{} δ = map[Key]ΔValue{}
δtrack = &δtrackIndex{DelLeaf: SetOid{}, Add: trackIndex{}}
defer tracef(" -> δ: %v\n", δ) defer tracef(" -> δ: %v\n", δ)
// initial split ranges for A and B // initial split ranges for A and B
......
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