Commit b34819df authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 74fc8bb8
...@@ -716,28 +716,11 @@ func diffT(ctx context.Context, a, b *Tree, δZTC SetOid, trackIdx map[zodb.Oid] ...@@ -716,28 +716,11 @@ func diffT(ctx context.Context, a, b *Tree, δZTC SetOid, trackIdx map[zodb.Oid]
fmt.Printf(" T %s %s\n", xidOf(a), xidOf(b)) fmt.Printf(" T %s %s\n", xidOf(a), xidOf(b))
defer xerr.Contextf(&err, "diffT %s %s", xidOf(a), xidOf(b)) defer xerr.Contextf(&err, "diffT %s %s", xidOf(a), xidOf(b))
/*
var av []TreeEntry
var bv []TreeEntry
if a != nil {
err = a.PActivate(ctx); if err != nil { return nil, err }
defer a.PDeactivate()
av = a.Entryv() // key↑
}
if b != nil {
err = b.PActivate(ctx); if err != nil { return nil, err }
defer b.PDeactivate()
bv = b.Entryv() // key↑
}
fmt.Printf(" av: %s\n", vtree(av))
fmt.Printf(" bv: %v\n", vtree(bv))
*/
δ = map[Key]ΔValue{} δ = map[Key]ΔValue{}
defer fmt.Printf(" -> δt: %v\n", δ) defer fmt.Printf(" -> δt: %v\n", δ)
var av rangeSplit var av rangeSplit // nodes expanded from a
var bv rangeSplit var bv rangeSplit // nodes expanded from b
// initial phase: expand changed nodes in a till buckets; // initial phase: expand changed nodes in a till buckets;
// XXX changed buckets -> δ- // XXX changed buckets -> δ-
...@@ -768,8 +751,11 @@ func diffT(ctx context.Context, a, b *Tree, δZTC SetOid, trackIdx map[zodb.Oid] ...@@ -768,8 +751,11 @@ func diffT(ctx context.Context, a, b *Tree, δZTC SetOid, trackIdx map[zodb.Oid]
return nil, err return nil, err
} }
// XXX δ <- δA // δ <- δA
δMerge(δ, δA)
// XXX AKeysDone <- δA // XXX AKeysDone <- δA
// XXX Bqueue <- δA
} }
} }
} }
...@@ -792,13 +778,15 @@ func diffT(ctx context.Context, a, b *Tree, δZTC SetOid, trackIdx map[zodb.Oid] ...@@ -792,13 +778,15 @@ func diffT(ctx context.Context, a, b *Tree, δZTC SetOid, trackIdx map[zodb.Oid]
// XXX check bucket for already "done" (i.e. taken into account) // XXX check bucket for already "done" (i.e. taken into account)
bbucket.node.(*Bucket)
δB, err := diffB(ctx, nil, bbucket.node.(*Bucket)) δB, err := diffB(ctx, nil, bbucket.node.(*Bucket))
if err != nil { if err != nil {
return nil, err return nil, err
} }
// XXX δ <- δB // δ <- δB
δMerge(δ, δB)
// XXX Aqueue <- δB
for k, δv := range δ { for k, δv := range δ {
if !AKeysDone.Has(k) { if !AKeysDone.Has(k) {
Akeysq.Add(k) Akeysq.Add(k)
...@@ -881,7 +869,7 @@ func diffT(ctx context.Context, a, b *Tree, δZTC SetOid, trackIdx map[zodb.Oid] ...@@ -881,7 +869,7 @@ func diffT(ctx context.Context, a, b *Tree, δZTC SetOid, trackIdx map[zodb.Oid]
} }
// merge δ <- δc // merge δ <- δc
δmergeInto(δ, δc) δMerge(δ, δc)
// update δc -> tracked keys // update δc -> tracked keys
...@@ -915,9 +903,9 @@ func diffT(ctx context.Context, a, b *Tree, δZTC SetOid, trackIdx map[zodb.Oid] ...@@ -915,9 +903,9 @@ func diffT(ctx context.Context, a, b *Tree, δZTC SetOid, trackIdx map[zodb.Oid]
} }
// δmergeInto merges changes from δ2 into δ. // δMerge merges changes from δ2 into δ.
// Usually δ is total-building δ, while δ2 is diff from comparing some subnodes. // δ is total-building diff, while δ2 is diff from comparing some subnodes.
func δmergeInto(δ, δ2 map[Key]ΔValue) { func δMerge(δ, δ2 map[Key]ΔValue) {
// merge δ <- δ2 // merge δ <- δ2
for k, δv2 := range δ2 { for k, δv2 := range δ2 {
δv1, already := δ[k] δv1, already := δ[k]
...@@ -928,6 +916,7 @@ func δmergeInto(δ, δ2 map[Key]ΔValue) { ...@@ -928,6 +916,7 @@ func δmergeInto(δ, δ2 map[Key]ΔValue) {
// both δ and δ2 has [k] - it can be that key // both δ and δ2 has [k] - it can be that key
// entry migrated from one bucket into another. // entry migrated from one bucket into another.
// XXX also handle ø->ø + ø->c i.e. [k] was hole and become value
if !( (δv1.New == VDEL && δv2.Old == VDEL) || if !( (δv1.New == VDEL && δv2.Old == VDEL) ||
(δv1.Old == VDEL && δv2.New == VDEL) ) { (δv1.Old == VDEL && δv2.New == VDEL) ) {
return nil, fmt.Errorf("BUG or btree corrupt: [%v] has " + return nil, fmt.Errorf("BUG or btree corrupt: [%v] has " +
......
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