Commit 568f054f authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent f3a5dd3c
......@@ -693,8 +693,8 @@ func diffT(ctx context.Context, A, B *Tree, δZTC SetOid, trackIdx map[zodb.Oid]
δ = map[Key]ΔValue{}
defer tracef(" -> δ: %v\n", δ)
// initial split ranges for A and B
// XXX maybe walk till a from root to get more precise initial range?
// XXX precise range as for a ?
atop := &nodeInRange{lo: KeyMin, hi_: KeyMax, node: A} // [-∞, ∞)
btop := &nodeInRange{lo: KeyMin, hi_: KeyMax, node: B} // [-∞, ∞)
Av := rangeSplit{atop} // nodes expanded from A
......@@ -711,9 +711,9 @@ func diffT(ctx context.Context, A, B *Tree, δZTC SetOid, trackIdx map[zodb.Oid]
// a node ac does not contribute to δ- and can be skipped, if:
// - ac is not tracked, or
// - ac ∉ δZTC && ∃ bc from B: ac.oid == bc.oid (ac was not changed and stays in the tree)
Aq := [atop] // queue for A nodes that contribyte to δ-
Aq := []*nodeInRange{atop} // queue for A nodes that contribyte to δ-
for len(Aq) > 0 {
ra := Aq.pop()
ra := pop(&Aq)
err = ra.node.PActivate(ctx); /*X*/if err != nil { return nil, err }
defer ra.node.PDeactivate()
......@@ -735,22 +735,18 @@ func diffT(ctx context.Context, A, B *Tree, δZTC SetOid, trackIdx map[zodb.Oid]
// a is tree - expand it and queue children
// see for each children whether it can be skipped
// XXX if a is ø tree
av := a.Entryv()
for i, ae := range a.Entryv() {
ac := ae.Child()
_, tracked := trackIdx[ac.POid()]
achildren := Av.Expand(ra)
for _, ac := range achildren {
acOid := ac.node.POid()
// XXX len(achildren) == 1 && acOid == Invalid -> embedded bucket
_, tracked := trackIdx[acOid]
if !tracked {
continue
}
if !δZTC.Has(ac.POid()) {
lo := av[i].Key()
hi_ := ra.hi_
if i+1 < len(av) {
hi_ = av[i+1].Key - 1
}
if !δZTC.Has(acOid) {
// XXX also check b's parents, as they could be already expanded?
bc, ok, err := Bv.tryGetToNode(ac.oid, lo, hi_, /*maxdepth*/2)
bc, ok, err := Bv.tryGetToNode(acOid, ac.lo, ac.hi_, /*maxdepth*/2)
if err != nil { return nil, err }
if ok {
// ac can be skipped
......@@ -760,7 +756,7 @@ func diffT(ctx context.Context, A, B *Tree, δZTC SetOid, trackIdx map[zodb.Oid]
}
// ac cannot be skipped
Aq.push(ac)
push(&Aq, ac)
}
}
}
......@@ -814,7 +810,7 @@ func diffT(ctx context.Context, A, B *Tree, δZTC SetOid, trackIdx map[zodb.Oid]
// -bucket if that bucket is reached for the first time
if !a.done {
var δA map[Key]ΔValue
abucket, ok := a.node.(*Bucket_
abucket, ok := a.node.(*Bucket)
if !ok { // !ok means ø tree
δA, err := diffB(ctx, abucket, nil); /*X*/if err != nil { return nil, err }
}
......@@ -837,43 +833,12 @@ func diffT(ctx context.Context, A, B *Tree, δZTC SetOid, trackIdx map[zodb.Oid]
Akqueue = SetKey{}
}
return δ, nil
}
Aq := [atop] // nodes in A that may contribute to δ
Bq := [] // ----//----
for len(Aq) > 0 {
a := Astk.pop()
// XXX activate(a)
baoverlap = []*nodeInRange // of all nodes in Bv that overlaps with a
for _, b := range baoverlap {
}
bn := Bv.Get(an.lo)
// XXX activate(bn)
bn.lo < an.lo // -> expand b if b is not bucket ; if b is bucket - b contributes; check also b followups that fit into a
(an.lo == bn.lo) && (an.hi_ == bn.hi_)
&& an.oid == bn.oid
// -> an/bn can contribute to δ only if an ∈ δZTC
}
func __qqq__diffT(ctx context.Context, A, B *Tree, δZTC SetOid, trackIdx map[zodb.Oid]nodeTrack) (δ map[Key]ΔValue, err error) {
// initial phase: expand changed nodes in a till buckets;
// XXX changed buckets -> δ-
......@@ -1782,6 +1747,11 @@ func (track nodeTrack) String() string {
}
// push pushes element to node stack.
func push(nodeStk *[]*nodeInRange, top *nodeInRange) {
*nodeStk = append(*nodeStk, top)
}
// pop pops top element from node stack.
func pop(nodeStk *[]*nodeInRange) *nodeInRange {
stk := *nodeStk
......
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