Commit 1233d221 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 51fb2628
...@@ -571,7 +571,7 @@ func (prs *rangeSplit) Expand(rnode *nodeInRange) (children rangeSplit) { ...@@ -571,7 +571,7 @@ func (prs *rangeSplit) Expand(rnode *nodeInRange) (children rangeSplit) {
// [len(ev)].Key = +∞ ; should be assumed so // [len(ev)].Key = +∞ ; should be assumed so
tree := rnode.node.(*Tree) tree := rnode.node.(*Tree)
treev := tree.Entryv() treev := tree.Entryv()
fmt.Printf("E treev: %v\n", treev) // fmt.Printf("E treev: %v\n", treev)
children = make(rangeSplit, 0, len(treev)+1) children = make(rangeSplit, 0, len(treev)+1)
for i := range treev { for i := range treev {
lo := rnode.lo lo := rnode.lo
...@@ -586,7 +586,7 @@ func (prs *rangeSplit) Expand(rnode *nodeInRange) (children rangeSplit) { ...@@ -586,7 +586,7 @@ func (prs *rangeSplit) Expand(rnode *nodeInRange) (children rangeSplit) {
children = append(children, &nodeInRange{lo, hi_, treev[i].Child()}) children = append(children, &nodeInRange{lo, hi_, treev[i].Child()})
} }
fmt.Printf("E children: %s\n", children) // fmt.Printf("E children: %s\n", children)
// del[i]; insert(@i, children) // del[i]; insert(@i, children)
*prs = append(rs[:i], append(children, rs[i+1:]...)...) *prs = append(rs[:i], append(children, rs[i+1:]...)...)
...@@ -666,6 +666,7 @@ func treediff(ctx context.Context, root zodb.Oid, δtops SetOid, δZTC SetOid, t ...@@ -666,6 +666,7 @@ func treediff(ctx context.Context, root zodb.Oid, δtops SetOid, δZTC SetOid, t
// FIXME -> merge (VDEL vs add) // FIXME -> merge (VDEL vs add)
// XXX no - not needed here - keys cannot migrate in between two disconnected subtrees // XXX no - not needed here - keys cannot migrate in between two disconnected subtrees
// -> assert that keys from different δtop do not overlap
// DEL k -> Tkextra += k // DEL k -> Tkextra += k
// +k -> Tkextra -= k // +k -> Tkextra -= k
fmt.Printf("-> δtop: %v\n", δtop) fmt.Printf("-> δtop: %v\n", δtop)
...@@ -677,6 +678,7 @@ func treediff(ctx context.Context, root zodb.Oid, δtops SetOid, δZTC SetOid, t ...@@ -677,6 +678,7 @@ func treediff(ctx context.Context, root zodb.Oid, δtops SetOid, δZTC SetOid, t
return δT, nil return δT, nil
} }
// XXX kill (goes away after diffT rework)
// diffX computes difference in between two revisions of a tree's subtree. // diffX computes difference in between two revisions of a tree's subtree.
// //
// a, b point to top of the subtree @old and @new revisions and must be of the // a, b point to top of the subtree @old and @new revisions and must be of the
...@@ -755,7 +757,6 @@ func diffT(ctx context.Context, a, b *Tree, δZTC SetOid, trackIdx map[zodb.Oid] ...@@ -755,7 +757,6 @@ func diffT(ctx context.Context, a, b *Tree, δZTC SetOid, trackIdx map[zodb.Oid]
// initial phase: expand changed nodes in a till buckets; // initial phase: expand changed nodes in a till buckets;
// XXX changed buckets -> δ- // XXX changed buckets -> δ-
if a != nil { // XXX kill (always !nil) ? if a != nil { // XXX kill (always !nil) ?
fmt.Println("ZZZ")
// 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?
atop := &nodeInRange{lo: KeyMin, hi_: KeyMax, node: a} // [-∞, ∞) atop := &nodeInRange{lo: KeyMin, hi_: KeyMax, node: a} // [-∞, ∞)
av = rangeSplit{atop} av = rangeSplit{atop}
...@@ -768,8 +769,8 @@ func diffT(ctx context.Context, a, b *Tree, δZTC SetOid, trackIdx map[zodb.Oid] ...@@ -768,8 +769,8 @@ func diffT(ctx context.Context, a, b *Tree, δZTC SetOid, trackIdx map[zodb.Oid]
defer arn.node.PDeactivate() defer arn.node.PDeactivate()
children := av.Expand(arn) children := av.Expand(arn)
fmt.Printf("Y children: %s\n", children) // fmt.Printf("Y children: %s\n", children)
fmt.Printf("Y av: %s\n", av) // fmt.Printf("Y av: %s\n", av)
for _, rchild := range children { for _, rchild := range children {
coid := rchild.node.POid() coid := rchild.node.POid()
if !( δZTC.Has(coid) || if !( δZTC.Has(coid) ||
...@@ -815,6 +816,7 @@ func diffT(ctx context.Context, a, b *Tree, δZTC SetOid, trackIdx map[zodb.Oid] ...@@ -815,6 +816,7 @@ func diffT(ctx context.Context, a, b *Tree, δZTC SetOid, trackIdx map[zodb.Oid]
fmt.Printf(" av: %s\n", av) fmt.Printf(" av: %s\n", av)
fmt.Printf(" bv: %s\n", bv) fmt.Printf(" bv: %s\n", bv)
fmt.Printf(" bq: %s\n", Bqueue)
// phase 2: iterate through keys queued for A and B, delve into // phase 2: iterate through keys queued for A and B, delve into
// corresponding nodes, and merge diff generated from them into δ. // corresponding nodes, and merge diff generated from them into δ.
...@@ -824,6 +826,10 @@ func diffT(ctx context.Context, a, b *Tree, δZTC SetOid, trackIdx map[zodb.Oid] ...@@ -824,6 +826,10 @@ func diffT(ctx context.Context, a, b *Tree, δZTC SetOid, trackIdx map[zodb.Oid]
// XXX inneficient: we process each key separately, while they can be // XXX inneficient: we process each key separately, while they can be
// processed in sorted batches. // processed in sorted batches.
for len(Aqueue) > 0 || len(Bqueue) > 0 { for len(Aqueue) > 0 || len(Bqueue) > 0 {
fmt.Printf("\n")
fmt.Printf(" aq: %s\n", Aqueue)
fmt.Printf(" bq: %s\n", Bqueue)
// B queue // B queue
// expand keys in new δA -> in B till buckets; // expand keys in new δA -> in B till buckets;
// process B buckets that cover new keys into δ+ // process B buckets that cover new keys into δ+
...@@ -898,6 +904,9 @@ func diffT(ctx context.Context, a, b *Tree, δZTC SetOid, trackIdx map[zodb.Oid] ...@@ -898,6 +904,9 @@ func diffT(ctx context.Context, a, b *Tree, δZTC SetOid, trackIdx map[zodb.Oid]
// δMerge merges changes from δ2 into δ. // δMerge merges changes from δ2 into δ.
// δ is total-building diff, while δ2 is diff from comparing some subnodes. // δ is total-building diff, while δ2 is diff from comparing some subnodes.
func δMerge(δ, δ2 map[Key]ΔValue) error { func δMerge(δ, δ2 map[Key]ΔValue) error {
fmt.Printf(" δmerge %v <- %v\n", δ, δ2)
defer fmt.Printf(" -> %v\n", δ)
// merge δ <- δ2 // merge δ <- δ2
for k, δv2 := range δ2 { for k, δv2 := range δ2 {
δv1, already := δ[k] δv1, already := δ[k]
......
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