Commit 5a1bdf50 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent c267c969
......@@ -324,9 +324,13 @@ func (rs rangeSplit) String() string {
// treediff computes δT/δtrack/δtkeycov for tree/trackSet specified by root in between old..new.
//
// It is the main entry-point for BTree-diff algorithm. XXX -> overview
//
// δtops is set of top nodes for changed subtrees.
// δZTC is connected(δZ/T) - connected closure for subset of δZ(old..new) that
// touches tracked nodes of T.
//
// Use δZConnectTracked to prepare δtops and δZTC.
func treediff(ctx context.Context, root zodb.Oid, δtops setOid, δZTC setOid, trackSet blib.PPTreeSubSet, zconnOld, zconnNew *zodb.Connection) (δT map[Key]ΔValue, δtrack *blib.ΔPPTreeSubSet, δtkeycov *blib.RangedKeySet, err error) {
defer xerr.Contextf(&err, "treediff %s..%s %s", zconnOld.At(), zconnNew.At(), root)
......@@ -340,7 +344,7 @@ func treediff(ctx context.Context, root zodb.Oid, δtops setOid, δZTC setOid, t
δtrackv := []*blib.ΔPPTreeSubSet{}
for top := range δtops { // XXX -> sorted?
for top := range δtops {
a, err1 := zgetNodeOrNil(ctx, zconnOld, top)
b, err2 := zgetNodeOrNil(ctx, zconnNew, top)
err := xerr.Merge(err1, err2)
......@@ -353,15 +357,15 @@ func treediff(ctx context.Context, root zodb.Oid, δtops setOid, δZTC setOid, t
return nil, nil, nil, err
}
// FIXME -> merge (VDEL vs add)
// 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
// +k -> Tkextra -= k
debugfDiff("-> δtop: %v\n", δtop)
debugfDiff("-> δtrackTop: %v\n", δtrackTop)
debugfDiff("-> δtkeycovTop: %v\n", δtkeycovTop)
for k,δv := range δtop {
// NOTE keys cannot migrate in between two disconnected subtrees
δv_, kdup := δT[k]
if kdup {
panicf("BUG: key %v present in two disconnected subtrees; δv1: %s δv2: %s", k, δv_, δv)
}
δT[k] = δv
}
......@@ -369,7 +373,7 @@ func treediff(ctx context.Context, root zodb.Oid, δtops setOid, δZTC setOid, t
δtkeycov.UnionInplace(δtkeycovTop)
}
// adjust trackSet by merge(δtrackTops)
// trackSet should be adjusted by merge(δtrackTops)
for _, δ := range δtrackv {
δtrack.Update(δ)
}
......
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