Commit 3fe38ee3 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent c4a49a11
......@@ -797,7 +797,7 @@ func diffT(ctx context.Context, a, b *Tree, δZTC SetOid, trackIdx map[zodb.Oid]
tracef(" av: %s\n", av)
tracef(" bv: %s\n", bv)
// phase 2: iterate through keys queued for A and B, delve into
// XXX phase 2: iterate through keys queued for A and B, delve into
// corresponding nodes, and merge diff generated from them into δ.
// Each delve for A or B, potentially adds new keys to process on the
// other side.
......@@ -813,8 +813,91 @@ func diffT(ctx context.Context, a, b *Tree, δZTC SetOid, trackIdx map[zodb.Oid]
// A queue
// Bqueue = SetKey{}
for len(Aqueue) > 0 {
Xa := pop(&Aqueue)
tracef(" A %v\n", Xa)
anode := pop(&Aqueue)
tracef(" A %v\n", anode)
// anode is a node from A.
// it can potentially contribute to -δA if
// - Xa ∈ Tracked ∈ δZTC
// - Xa ∈ Tracked _and_ is no longer referenced
interesting := false
if δZTC.Has(anode.node.POid()) {
interesting = true
}
// XXX "no longer referenced"
if !interesting {
continue
}
// anode can potentially contribute to -δA
// - tree: expand and queue its children
// - bucket: -δA += anode
switch node := anode.node.(type) {
case *Tree:
err = node.PActivate(ctx); if err != nil { return nil, err }
defer node.PDeactivate()
// empty tree - do not expand into bucket - only process tracked holes
if len(node.Entryv()) == 0 {
// XXX dup wrt bucket processing?
δA := map[Key]ΔValue{}
track, ok := trackIdx[node.POid()]
if !ok {
panicf("%s ∈ δZTC, but ∉ trackIdx", vnode(node))
}
for k := range track.holes {
δA[k] = ΔValue{VDEL, VDEL} // ø->ø indicates hole
}
// δ <- δA
err = δMerge(δ, δA)
if err != nil {
return nil, err
}
/*
// Adone <- δA
// Bqueue <- δA
for k := range δA {
Adone.Add(k)
Bqueue.Add(k)
}
*/
anode.done = true
continue
}
av.Expand(anode)
case *Bucket:
δA, err := diffB(ctx, node, nil)
if err != nil {
return nil, err
}
// XXX also extract holes
// δ <- δA
err = δMerge(δ, δA)
if err != nil {
return nil, err
}
/*
// Adone <- δA
// Bqueue <- δA
for k_ := range δA {
Adone.Add(k_)
if !Bdone.Has(k_) {
Bqueue.Add(k_)
}
}
*/
anode.done = true
}
/*
anode, ok, err := av.GetToLeaf(ctx, 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