Commit 953f1978 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 970d3243
...@@ -782,9 +782,14 @@ func diffT(ctx context.Context, a, b *Tree, δZTC SetOid, trackIdx map[zodb.Oid] ...@@ -782,9 +782,14 @@ func diffT(ctx context.Context, a, b *Tree, δZTC SetOid, trackIdx map[zodb.Oid]
// corresponding nodes, and merge diff generated from them into δ. // corresponding nodes, and merge diff generated from them into δ.
// Each delve for A or B, potentially adds new keys to process on the // Each delve for A or B, potentially adds new keys to process on the
// other side. // other side.
//
// XXX inneficient: we process each key separately, while they can be
// processed in sorted batches.
for len(Aqueue) > 0 || len(Bqueue) > 0 { for len(Aqueue) > 0 || len(Bqueue) > 0 {
// 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 δ+
Aqueue = SetKey{}
for k := range Bqueue { for k := range Bqueue {
Bdone.Add(k) Bdone.Add(k)
bbucket, ok, err := bv.GetToBucket(ctx, k) bbucket, ok, err := bv.GetToBucket(ctx, k)
...@@ -806,14 +811,42 @@ func diffT(ctx context.Context, a, b *Tree, δZTC SetOid, trackIdx map[zodb.Oid] ...@@ -806,14 +811,42 @@ func diffT(ctx context.Context, a, b *Tree, δZTC SetOid, trackIdx map[zodb.Oid]
} }
// Aqueue <- δB // Aqueue <- δB
for k, δv := range δ { for k := range δB {
if !Adone.Has(k) { if !Adone.Has(k) {
Aqueue.Add(k) Aqueue.Add(k)
} }
}
_ = δv
} }
// A queue
Bqueue = SetKey{}
for k := range Aqueue {
Adone.Add(k)
abucket, ok, err := av.GetToBucket(ctx, k)
if !ok {
continue // key not covered
}
// XXX check bucket for already "done"
δA, err := diffB(ctx, abucket.node.(*Bucket), nil)
if err != nil {
return nil, err
}
// δ <- δA
err = δMerge(δ, δA)
if err != nil {
return nil, err
}
// Bqueue <- δA
for k := range δA {
if !Bdone.Has(k) {
Bqueue.Add(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