Commit a17fd280 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 18010d1d
......@@ -513,21 +513,3 @@ func (S PPTreeSubSet) ApplyΔ(δ *ΔPPTreeSubSet) {
S.xUnionInplace(δ.Add)
S.xfixup(+1, δ.δnchildNonLeafs)
}
// XXX kill
// XXX returns PPTreeSubSet that corresponds to nodes that correspond to δtkeycov.
// XXX correct?
func (δ *ΔPPTreeSubSet) XXXδtkeycovSet() (S PPTreeSubSet) {
S = PPTreeSubSet{}
δ.Del.verify()
δ.Add.verify()
defer S.verify()
//S.xfixup(-1, δ.δnchildNonLeafs)
S.xUnionInplace(δ.Add)
S.xDifferenceInplace(δ.Del)
//S.xfixup(+1, δ.δnchildNonLeafs)
return S
}
......@@ -366,13 +366,23 @@ func (δTtail *ΔTtail) rebuild(root zodb.Oid, δZtail *zodb.ΔTail, db *zodb.DB
break
}
widenTrackNew := func() error {
err := widenTrackNew(trackNew, δtkeycov, root, δZtail.Head(), db)
if err != nil {
return nil, err
}
}
return trackNew, nil
}
// widenTrackNew widens trackNew to cover δtkeycov.
func widenTrackNew(trackNew PPTreeSubSet, δtkeycov *RangedKeySet, root zodb.Oid, at zodb.Tid, db *zodb.DB) error {
// XXX errctx, debug
txn, ctx := transaction.New(context.TODO()) // XXX
defer txn.Abort()
zhead, err := db.Open(ctx, &zodb.ConnOptions{At: δZtail.Head()}); /*X*/ if err != nil { return err }
zhead, err := db.Open(ctx, &zodb.ConnOptions{At: at}); /*X*/ if err != nil { return err }
xtree, err := zhead.Get(ctx, root); /*X*/ if err != nil { return err }
tree := xtree.(*Tree) // must succeed XXX better explicit panic?
......@@ -393,17 +403,9 @@ func (δTtail *ΔTtail) rebuild(root zodb.Oid, δZtail *zodb.ΔTail, db *zodb.DB
}
}
return nil
}
err := widenTrackNew()
if err != nil {
return nil, err
}
}
return trackNew, nil
}
// rebuild1 rebuilds δT for single δZ.
//
// δtrackNew/δtkeycov represents how trackNew changes when going through `atPrev <- δZ.Rev` .
......@@ -510,14 +512,18 @@ func (δBtail *ΔBtail) Update(δZ *zodb.EventCommit) (_ ΔB, err error) {
for root, δT1 := range δB1.ByRoot {
δTtail := δBtail.vδTbyRoot[root] // must succeed
// δtkeycov1 != ø -> rebuild δTtail
// δtkeycov1 != ø -> rebuild δTtail with trackNew ~= δtkeycov1
if !δT1.δtkeycov1.Empty() && δBtail.δZtail.Len() > 1 {
//δTtail.trackNew = ... // ~δtkeycov1
//δTtail.trackNew = nil // XXX stub
δTtail.trackNew = δT1.δtrack.XXXδtkeycovSet() // ~δtkeycov1 XXX correct?
trackNew := PPTreeSubSet{}
err := widenTrackNew(trackNew, δT1.δtkeycov1, root, δBtail.Head(), δBtail.db)
if err != nil {
return ΔB{}, err
}
// XXX assert δTtail.trackNew.Empty()
δTtail.trackNew = trackNew
// XXX vvv we can skip computing diff for HEAD~..HEAD (we just
// computed it in _Update1)
// computed it in _Update1)? (or not - trackNew is as of @head ?)
δtrackSet, err := δTtail.rebuild(root, δBtail.δZtail, δBtail.db)
if err != nil {
return ΔB{}, err
......
......@@ -1067,6 +1067,8 @@ func xverifyΔBTail_rebuild(t *testing.T, db *zodb.DB, treeRoot zodb.Oid, t0, t1
// // δkv2_2 = t2.δxkv / kadj10(kadj21(kadj12(keys1) | keys2))
//// keys12_2 := keys1_2.Union(keys2)
//// keys12_0 := kadj10.Map(kadj21.Map(keys12_2))
/*
fmt.Printf("\n\n\nKKK\nkeys1=%s keys2=%s\n", keys1, keys2)
fmt.Printf("keys12R2=%s\n", keys12R2)
......@@ -1077,6 +1079,7 @@ func xverifyΔBTail_rebuild(t *testing.T, db *zodb.DB, treeRoot zodb.Oid, t0, t1
fmt.Printf("kadj12: %v\n", kadj12)
fmt.Printf("t2.xkv.trackSet(%s) -> %s", keys12R2, t2.xkv.trackSet(keys12R2))
fmt.Printf("\n\n\n")
*/
// δkvX_k12R2 = tX.δxkv / keys12R2
......
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