Commit 8178a687 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 597329f1
...@@ -716,6 +716,11 @@ func diffT(ctx context.Context, A, B *Tree, δZTC SetOid, trackIdx map[zodb.Oid] ...@@ -716,6 +716,11 @@ func diffT(ctx context.Context, A, B *Tree, δZTC SetOid, trackIdx map[zodb.Oid]
Akdone := SetKey{} // already processed keys in A Akdone := SetKey{} // already processed keys in A
Bkdone := SetKey{} // ----//---- in B Bkdone := SetKey{} // ----//---- in B
// {} oid -> parent for all nodes in Bv: current and previously expanded - up till top B
// XXX
// XXX requires A.oid == B.oid
BtrackIdx := map[zodb.Oid]nodeTrack{B.POid(): nodeTrack{parent: trackIdx[B.POid()].parent}}
// phase 1: expand A top->down driven by δZTC. // phase 1: expand A top->down driven by δZTC.
// by default a node contributes to δ- // by default a node contributes to δ-
// a node ac does not contribute to δ- and can be skipped, if: // a node ac does not contribute to δ- and can be skipped, if:
...@@ -743,7 +748,7 @@ func diffT(ctx context.Context, A, B *Tree, δZTC SetOid, trackIdx map[zodb.Oid] ...@@ -743,7 +748,7 @@ func diffT(ctx context.Context, A, B *Tree, δZTC SetOid, trackIdx map[zodb.Oid]
case *Tree: case *Tree:
// a is tree - expand it and queue children // a is tree - expand it and queue children
// see for each children whether it can be skipped // check for each children whether it can be skipped
// XXX if a is ø tree // XXX if a is ø tree
achildren := Av.Expand(ra) achildren := Av.Expand(ra)
for _, ac := range achildren { for _, ac := range achildren {
...@@ -755,9 +760,36 @@ func diffT(ctx context.Context, A, B *Tree, δZTC SetOid, trackIdx map[zodb.Oid] ...@@ -755,9 +760,36 @@ func diffT(ctx context.Context, A, B *Tree, δZTC SetOid, trackIdx map[zodb.Oid]
} }
if !δZTC.Has(acOid) { if !δZTC.Has(acOid) {
// XXX also check b's parents, as they could be already expanded? // check B children for node with ac.oid
bc, ok, err := Bv.tryGetToNode(acOid, ac.lo, ac.hi_, /*maxdepth*/2) // while checking expand Bv till ac.lo and ac.hi_ point to the same node
if err != nil { return nil, err } // ( this does not give exact answer but should be a reasonable heuristic;
// the diff is the same if heuristic does not work and we
// look into and load more nodes to compute δ )
_, ok := BtrackIdx[acOid]
if !ok {
for {
blo := Bv.Get(ac.lo)
bhi_ := Bv.Get(ac.hi_)
if blo != bhi_ {
break
}
err = blo.node.PActivate(ctx); /*X*/if err != nil { return nil, err }
defer blo.node.PDeactivate()
bchildren := Bv.Expand(blo)
found := false
for _, bc := range bchildren {
bcOid := bc.node.POid()
BtrackIdx[bcOid] = nodeTrack{parent: blo.node.POid()}
if acOid == bcOid {
found = true
}
}
if found {
break
}
}
}
if ok { if ok {
// ac can be skipped // ac can be skipped
// XXX Bkqueue <- holes(ac.range \ bc.range) // XXX Bkqueue <- holes(ac.range \ bc.range)
......
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