Commit bc8389ed authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 07981138
......@@ -348,38 +348,6 @@ func (δBtail *ΔBtail) Update(δZ *zodb.EventCommit) (_ ΔB, err error) {
fmt.Printf("\nUpdate δZ: %v\n", δZ.Changev)
fmt.Printf("trackIdx: %v\n", δBtail.trackIdx)
/*
// {} root -> {oid} changed under that root in tracked set
// XXX dumb -> rework to toposort and getting root from tops only
rootOf := func(node zodb.Oid) (root zodb.Oid, ok bool) {
track, ok := δBtail.trackIdx[node]
if !ok {
return zodb.InvalidOid, false
}
for track.parent != zodb.InvalidOid {
node = track.parent
track = δBtail.trackIdx[node] // must be present
}
return node, true
}
δZByRoot := map[zodb.Oid]SetOid{}
for _, oid := range δZ.Changev {
root, ok := rootOf(oid)
if !ok {
continue
}
δZT, ok := δZByRoot[root]
if !ok {
δZT = SetOid{}
δZByRoot[root] = δZT
}
δZT.Add(oid)
}
fmt.Println("δZByRoot:", δZByRoot)
*/
δZTC, δtopsByRoot := δBtail.δZConnectTracked(δZ)
δB := ΔB{Rev: δZ.Tid, ByRoot: make(map[zodb.Oid]map[Key]ΔValue)}
......@@ -402,9 +370,7 @@ func (δBtail *ΔBtail) Update(δZ *zodb.EventCommit) (_ ΔB, err error) {
return ΔB{}, err
}
// for root, δZT := range δZByRoot {
for root, δtops := range δtopsByRoot {
// δT, err := treediff(ctx, root, δZT, δBtail.trackIdx, zconnOld, zconnNew)
δT, err := treediff(ctx, root, δtops, δZTC, δBtail.trackIdx, zconnOld, zconnNew)
if err != nil {
return ΔB{}, err
......@@ -416,24 +382,8 @@ func (δBtail *ΔBtail) Update(δZ *zodb.EventCommit) (_ ΔB, err error) {
}
return δB, nil
/* TODO btree-diff:
zconnNew = db.Open(δZ.rev)
defer(zconnNew.close)
for root, δZ in δbZ:
toposort(δZ)
for δ in δZ:
T | B = zconnOld.Get(δ) // XXX .zconnOld must be at .head and active
T' | B' = zconnNew.Get(δ)
diff(T, T')
diff(B, B')
...
.δBtail <- (δZ.rev, [](root, []key))
XXX rebuilf lastRevOf
*/
// XXX .δBtail <- (δZ.rev, [](root, []key))
// XXX rebuilf lastRevOf
}
// δZConnectTracked computes connected closure of δZ/T.
......@@ -504,9 +454,9 @@ func (δBtail *ΔBtail) δZConnectTracked(δZv *zodb.EventCommit) (δZTC SetOid,
// treediff computes δT for tree specified by root in between old..new.
//
// XXX only for tracked
// δZT is δZ/T - subset of δZ(old..new) that touches tracked nodes of T.
//func treediff(ctx context.Context, root zodb.Oid, δZT SetOid, trackIdx map[zodb.Oid]nodeTrack, zconnOld, zconnNew *zodb.Connection) (δT map[Key]ΔValue, err error) {
// δ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.
func treediff(ctx context.Context, root zodb.Oid, δtops SetOid, δZTC SetOid, trackIdx map[zodb.Oid]nodeTrack, zconnOld, zconnNew *zodb.Connection) (δT map[Key]ΔValue, err error) {
defer xerr.Contextf(&err, "treediff %s..%s %s", zconnOld.At(), zconnNew.At(), root)
// XXX zconnX -> a, b ?
......@@ -514,12 +464,6 @@ func treediff(ctx context.Context, root zodb.Oid, δtops SetOid, δZTC SetOid, t
fmt.Printf("treediff %s δtops: %v δZTC: %v\n", root, δtops, δZTC)
defer fmt.Printf("\n")
/*
// XXX δZT -> δZTC (all changed nodes are connected)
// e.g. t₀->t₁->b₂ δZ={t₀ b₂} -> δZC=δZ+{t₁}
δZTC := δZT // FIXME stub
*/
δT = map[Key]ΔValue{}
for top := range δtops { // XXX -> sorted?
......
......@@ -756,7 +756,9 @@ func TestΔBTail(t *testing.T) {
// test known cases going through tree1 -> tree2 -> ...
testv := []interface{} {
"T2/B1:a-B2:c", "T2,3/B1:a-B2:c-B3:c",
//"T2/B1:a-B2:c", "T2,3/B1:a-B2:c-B3:c",
"T2,3/B1:a-B2:b-B3:c", "T/B1:a,2:b",
"T2,3/B1:a-B2:c-B3:c", "T/B1:a,2:b",
///*
"T/B:",
......
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