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