Commit 7f7e34e0 authored by Kirill Smelkov's avatar Kirill Smelkov

X wcfs/xbtree: Fix update not to add duplicate extra point if rebuild -...

X wcfs/xbtree: Fix update not to add duplicate extra point if rebuild  - called by Update - already added it

It was failing e.g. as

=== RUN   TestΔBTail/rebuild/T4/T1,3-T/T-T-T-T/B0:b-B1:c,2:j-T-B4:d/B3:h→T/T2,3/T-T-T/B1:d-B2:c-B3:i/_T{3};R/_→T2/B1:g-B2:c,3:i
    δbtail_test.go:917: after Update(@at1→@at2): vδT:
        have:
        	@at1: map[0:{b ø} 1:{c d} 2:{j c} 3:{h i} 4:{d ø}]
        	@at2: map[1:{d g}]
        vδb/root:
        	@at1
        	@at2
        	@at2	<-- HERE
parent cf352737
......@@ -607,12 +607,10 @@ func (δBtail *ΔBtail) Update(δZ *zodb.EventCommit) (_ ΔB, err error) {
// XXX rebuild lastRevOf
}
// vδBroots += δB
δroots := setOid{}
// vδBroots += δB (δB.Rev could be already there added by ^^^ rebuild)
for root := range δB.ΔByRoot {
δroots.Add(root)
δBtail.vδBroots_Update1(root, δB.Rev)
}
δBtail.vδBroots = append(δBtail.vδBroots, _ΔBroots{Rev: δB.Rev, ΔRoots: δroots})
return δB, err
}
......@@ -699,22 +697,26 @@ func (δBtail *ΔBtail) _Update1(δZ *zodb.EventCommit) (δB1 _ΔBUpdate1, err e
func (δBtail *ΔBtail) vδBroots_Update(root zodb.Oid, δrevSet setTid) {
// XXX locking
for rev := range δrevSet {
l := len(δBtail.vδBroots)
j := sort.Search(l, func(k int) bool {
return rev <= δBtail.vδBroots[k].Rev
})
if j == l || δBtail.vδBroots[j].Rev != rev {
δBroots := _ΔBroots{Rev: rev, ΔRoots: setOid{}}
// insert(@j, δBroots)
δBtail.vδBroots = append(δBtail.vδBroots[:j],
append([]_ΔBroots{δBroots},
δBtail.vδBroots[j:]...)...)
}
δBroots := δBtail.vδBroots[j]
δBroots.ΔRoots.Add(root)
δBtail.vδBroots_Update1(root, rev)
}
}
func (δBtail *ΔBtail) vδBroots_Update1(root zodb.Oid, rev zodb.Tid) {
l := len(δBtail.vδBroots)
j := sort.Search(l, func(k int) bool {
return rev <= δBtail.vδBroots[k].Rev
})
if j == l || rev != δBtail.vδBroots[j].Rev {
δBroots := _ΔBroots{Rev: rev, ΔRoots: setOid{}}
// insert(@j, δBroots)
δBtail.vδBroots = append(δBtail.vδBroots[:j],
append([]_ΔBroots{δBroots},
δBtail.vδBroots[j:]...)...)
}
δBroots := δBtail.vδBroots[j]
δBroots.ΔRoots.Add(root)
}
// ForgetPast forgets history entries with revision ≤ revCut.
func (δBtail *ΔBtail) ForgetPast(revCut zodb.Tid) {
// XXX locking
......
......@@ -388,7 +388,7 @@ func TestΔBTail(t *testing.T) {
99: K(3,99,oo),
oo: K(3,99,oo)}),
// XXX wrong rebuild
// Update adds extra dup point to vδBroots
"T4/T1,3-T/T-T-T-T/B0:b-B1:c,2:j-T-B4:d/B3:h",
"T/T2,3/T-T-T/B1:d-B2:c-B3:i",
"T2/B1:g-B2:c,3:i",
......
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