Commit f428df95 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent c13a7bc0
......@@ -467,7 +467,7 @@ func (t nodeInTree) String() string {
// - δ.Add, and
// - xfixup(+1, δnchildNonLeafs)
//
// produce correctly PP-connected set.
// produces correctly PP-connected set.
type ΔPPTreeSubSet struct {
Del PPTreeSubSet
Add PPTreeSubSet
......@@ -513,3 +513,21 @@ func (S PPTreeSubSet) ApplyΔ(δ *ΔPPTreeSubSet) {
S.xUnionInplace(δ.Add)
S.xfixup(+1, δ.δnchildNonLeafs)
}
// 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
}
......@@ -606,7 +606,7 @@ ABcov:
ra.done = true
case *Tree:
// empty tree - only queue holes covered by it
// empty tree - queue holes covered by it
if len(a.Entryv()) == 0 {
ar := KeyRange{ra.lo, ra.hi_}
δtrack.Del.AddPath(ra.Path())
......
......@@ -504,14 +504,14 @@ func (δTtail *ΔTtail) rebuild1(atPrev zodb.Tid, δZ zodb.ΔRevEntry, trackNew
//
// TODO optionally accept zconnOld/zconnNew from client
func (δBtail *ΔBtail) Update(δZ *zodb.EventCommit) (_ ΔB, err error) {
δTKeyCov1, err := δBtail._Update1(δZ)
δB1, err := δBtail._Update1(δZ)
δB := ΔB{Rev: δZ.Tid, ΔByRoot: make(map[zodb.Oid]map[Key]ΔValue)}
for root, δtkeycov1 := range δTKeyCov1.ByRoot {
for root, δT1 := range δB1.ByRoot {
δTtail := δBtail.vδTbyRoot[root] // must succeed
// δtkeycov1 != ø -> rebuild δTtail
if !δtkeycov1.Empty() && δBtail.δZtail.Len() > 1 {
if !δT1.δtkeycov1.Empty() && δBtail.δZtail.Len() > 1 {
//δTtail.trackNew = ... // ~δtkeycov1
δTtail.trackNew = nil // XXX stub
......@@ -546,10 +546,14 @@ func (δBtail *ΔBtail) Update(δZ *zodb.EventCommit) (_ ΔB, err error) {
// On key coverage growth rebuilding tail of the history is done by Update itself.
//
// _Update1 is also used in tests to verify δtkeycov return from treediff.
type TrackKeyCov1 struct {
ByRoot map[zodb.Oid]*RangedKeySet // {} root -> δtrackedKeys after first treediff (always grow)
type BUpdate1 struct {
ByRoot map[zodb.Oid]*_ΔTUpdate1
}
func (δBtail *ΔBtail) _Update1(δZ *zodb.EventCommit) (δTKeyCov1 _ΔTrackKeyCov1, err error) {
type _ΔTUpdate1 struct {
δtkeycov1 *RangedKeySet // {} root -> δtrackedKeys after first treediff (always grow)
δtrack *ΔPPTreeSubSet
}
func (δBtail *ΔBtail) _Update1(δZ *zodb.EventCommit) (δB1 _ΔBUpdate1, err error) {
headOld := δBtail.Head()
defer xerr.Contextf(&err, "ΔBtail update %s -> %s", headOld, δZ.Tid)
......@@ -560,7 +564,7 @@ func (δBtail *ΔBtail) _Update1(δZ *zodb.EventCommit) (δTKeyCov1 _ΔTrackKeyC
tracefΔBtail("[%s].trackNew: %v\n", root, δTtail.trackNew)
}
δTKeyCov1 = _ΔTrackKeyCov1{ByRoot: make(map[zodb.Oid]*RangedKeySet)}
δB1 = _ΔBUpdate1{ByRoot: make(map[zodb.Oid]*_ΔTUpdate1)}
if XXX_killWhenRebuildWorks {
// XXX hack - until vvv is reenabled
......@@ -575,7 +579,7 @@ if XXX_killWhenRebuildWorks {
// update .trackSet and vδB from .trackNew
err = δBtail.rebuildAll()
if err != nil {
return δTKeyCov1, err
return δB1, err
}
}
......@@ -587,7 +591,7 @@ if XXX_killWhenRebuildWorks {
// skip opening DB connections if there is no change to any tree node
if len(δtopsByRoot) == 0 {
return δTKeyCov1, nil
return δB1, nil
}
// open ZODB connections corresponding to "old" and "new" states
......@@ -596,17 +600,17 @@ if XXX_killWhenRebuildWorks {
defer txn.Abort()
zconnOld, err := δBtail.db.Open(ctx, &zodb.ConnOptions{At: headOld})
if err != nil {
return δTKeyCov1, err
return δB1, err
}
zconnNew, err := δBtail.db.Open(ctx, &zodb.ConnOptions{At: δZ.Tid})
if err != nil {
return δTKeyCov1, err
return δB1, err
}
for root, δtops := range δtopsByRoot {
δT, δtrack, δtkeycov, err := treediff(ctx, root, δtops, δZTC, δBtail.trackSet, zconnOld, zconnNew)
if err != nil {
return δTKeyCov1, err
return δB1, err
}
tracefΔBtail("\n-> root<%s> δkv: %v δtrack: %v δtkeycov: %v\n", root, δT, δtrack, δtkeycov)
......@@ -617,10 +621,10 @@ if XXX_killWhenRebuildWorks {
}
δBtail.trackSet.ApplyΔ(δtrack)
δTKeyCov1.ByRoot[root] = δtkeycov
δB1.ByRoot[root] = &_ΔTUpdate1{δtkeycov1: δtkeycov, δtrack: δtrack}
}
return δTKeyCov1, nil
return δB1, nil
}
......
......@@ -810,11 +810,10 @@ func xverifyΔBTail_Update1(t *testing.T, subj string, db *zodb.DB, treeRoot zod
// also call _Update1 directly to verify δtkeycov return from treediff
// the result of Update and _Update1 should be the same since δbtail is initially empty.
δbtail_ := δbtail.Clone()
δB, err := δbtail.Update(δZ); X(err)
δTKeyCov, err := δbtail_._Update1(δZ); X(err)
δB, err := δbtail.Update(δZ); X(err)
δB1, err := δbtail_._Update1(δZ); X(err)
// XXX assert δB.roots == δTKeyCov roots
// XXX assert δBtail[root].vδT[-1] = δBtail_[root].vδT[-1]
// XXX -> just assert δBtail == δBtail_ ?
// XXX assert δBtail[root].vδT = δBtail_[root].vδT
if δB.Rev != δZ.Tid {
badf("δB: rev != δZ.Tid ; rev=%s δZ.Tid=%s", δB.Rev, δZ.Tid)
......@@ -855,7 +854,7 @@ func xverifyΔBTail_Update1(t *testing.T, subj string, db *zodb.DB, treeRoot zod
// assert δtkeycov == δ(tkeyCov1, tkeyCov2)
δtkeycovOK := tkeyCov2.Difference(tkeyCov1)
δtkeycov := δTKeyCov.ByRoot[treeRoot]
δtkeycov := δB1.ByRoot[treeRoot].δtkeycov1
if !δtkeycov.Equal(δtkeycovOK) {
badf("δtkeycov wrong:\nhave: %s\nwant: %s", δtkeycov, δtkeycovOK)
}
......
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