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

.

parent e8d30e1d
...@@ -1001,7 +1001,7 @@ func xverifyΔBTail_rebuild(t *testing.T, db *zodb.DB, treeRoot zodb.Oid, t0, t1 ...@@ -1001,7 +1001,7 @@ func xverifyΔBTail_rebuild(t *testing.T, db *zodb.DB, treeRoot zodb.Oid, t0, t1
// assert trackSet=ø, trackNew=ø, vδB=[] // assert trackSet=ø, trackNew=ø, vδB=[]
δbtail.assertTrack(t, "@at0", ø, ø) // XXX + vδB δbtail.assertTrack(t, "@at0", ø, ø) // XXX + vδB
xverifyΔBTail_rebuild_U(t, δbtail, t0, t1, xat, /*trackSet=*/ø) xverifyΔBTail_rebuild_U(t, δbtail, db, treeRoot, t0, t1, xat, /*trackSet=*/ø)
// XXX ^^^ + vδT=ø // XXX ^^^ + vδT=ø
xverifyΔBTail_rebuild_TR(t, db, δbtail, t1, treeRoot, xat, xverifyΔBTail_rebuild_TR(t, db, δbtail, t1, treeRoot, xat,
// after Track(keys1) // after Track(keys1)
...@@ -1017,7 +1017,7 @@ func xverifyΔBTail_rebuild(t *testing.T, db *zodb.DB, treeRoot zodb.Oid, t0, t1 ...@@ -1017,7 +1017,7 @@ func xverifyΔBTail_rebuild(t *testing.T, db *zodb.DB, treeRoot zodb.Oid, t0, t1
// tracked keys1 becomes tracked keys1_2 after Update(t1->t2) // tracked keys1 becomes tracked keys1_2 after Update(t1->t2)
// keys1_2 := kadj12.Map(keys1) // keys1_2 := kadj12.Map(keys1)
keys1_2 := kadj12.Map(kadj01.Map(keys1_0)) keys1_2 := kadj12.Map(kadj01.Map(keys1_0))
xverifyΔBTail_rebuild_U(t, δbtail, t1, t2, xat, /*trackSet=*/t2.xkv.trackSet(keys1_2)) xverifyΔBTail_rebuild_U(t, δbtail, db, treeRoot, t1, t2, xat, /*trackSet=*/t2.xkv.trackSet(keys1_2))
// XXX +vδT=δkv1_2, δkv2_2 // XXX +vδT=δkv1_2, δkv2_2
// tRestKeys2 = tAllKeys - keys1 // tRestKeys2 = tAllKeys - keys1
...@@ -1093,16 +1093,19 @@ func xverifyΔBTail_rebuild(t *testing.T, db *zodb.DB, treeRoot zodb.Oid, t0, t1 ...@@ -1093,16 +1093,19 @@ func xverifyΔBTail_rebuild(t *testing.T, db *zodb.DB, treeRoot zodb.Oid, t0, t1
} }
// xverifyΔBTail_rebuild_U verifies ΔBTree state after Update(ti->tj). // xverifyΔBTail_rebuild_U verifies ΔBTree state after Update(ti->tj).
func xverifyΔBTail_rebuild_U(t *testing.T, δbtail *ΔBtail, ti, tj *tTreeCommit, xat map[zodb.Tid]string, trackSet PPTreeSubSet, vδTok ...map[Key]Δstring) { func xverifyΔBTail_rebuild_U(t *testing.T, δbtail *ΔBtail, db *zodb.DB, treeRoot zodb.Oid, ti, tj *tTreeCommit, xat map[zodb.Tid]string, trackSet PPTreeSubSet, vδTok ...map[Key]Δstring) {
t.Helper() t.Helper()
X := exc.Raiseif X := exc.Raiseif
ø := PPTreeSubSet{} ø := PPTreeSubSet{}
subj := fmt.Sprintf("after Update(@%s→@%s)", xat[ti.at], xat[tj.at])
// Update ati -> atj // Update ati -> atj
δB, err := δbtail.Update(tj.δZ); X(err) δB, err := δbtail.Update(tj.δZ); X(err)
// XXX assert δB.Rev = tj.at; δB = δ(ti,tj)/initially tracked // XXX assert δB.Rev = tj.at; δB = δ(ti,tj)/initially tracked
δbtail.assertTrack(t, fmt.Sprintf("after Update(@%s→@%s)", xat[ti.at], xat[tj.at]), trackSet, ø) δbtail.assertTrack(t, subj, trackSet, ø)
_ = δB _ = δB
assertΔTtail(t, subj, δbtail, db, tj, treeRoot, xat, vδTok...)
} }
// xverifyΔBTail_rebuild_TR verifies ΔBTree state after Track(keys) + rebuild. // xverifyΔBTail_rebuild_TR verifies ΔBTree state after Track(keys) + rebuild.
...@@ -1122,66 +1125,24 @@ func xverifyΔBTail_rebuild_TR(t *testing.T, db *zodb.DB, δbtail *ΔBtail, tj * ...@@ -1122,66 +1125,24 @@ func xverifyΔBTail_rebuild_TR(t *testing.T, db *zodb.DB, δbtail *ΔBtail, tj *
err = δbtail.Track(k, path); X(err) err = δbtail.Track(k, path); X(err)
} }
δbtail.assertTrack(t, fmt.Sprintf("@%s: after Track%v", xat[tj.at], keys), trackSet, trackNew) subj := fmt.Sprintf("@%s: after Track%v", xat[tj.at], keys)
δbtail.assertTrack(t, subj, trackSet, trackNew)
// XXX vδB=[ø] // XXX vδB=[ø]
δbtail.rebuildAll() δbtail.rebuildAll()
δbtail.assertTrack(t, fmt.Sprintf("@%s: after Track%v + rebuild", xat[tj.at], keys), trackSetAfterRebuild, ø) subj += "+ rebuild"
δbtail.assertTrack(t, subj, trackSetAfterRebuild, ø)
// XXX assert vδB=[δ1/T(keys)] // XXX assert vδB=[δ1/T(keys)]
// XXX verify Get // XXX verify Get
// verify δbtail.vδTbyRoot[treeRoot] // verify δbtail.vδTbyRoot[treeRoot]
xverifyΔTtail(t, fmt.Sprintf("@%s: after Track%v + rebuild", xat[tj.at], keys), db, δbtail, tj, treeRoot, xat, vδTok...) assertΔTtail(t, subj, δbtail, db, tj, treeRoot, xat, vδTok...)
/*
// verify SliceByRootRev XXX -> verify δbtail.byRoot[treeRoot] directly
// XXX +KVAtTail, +lastRevOf
l := len(vδTok)
vatOK := []zodb.Tid{}
vδTok_ := []map[Key]Δstring{}
t0 := tj
for i := 0; i<l; i++ {
// empty vδTok entries means they should be absent in vδT
if δTok := vδTok[l-i-1]; len(δTok) != 0 {
vatOK = append([]zodb.Tid{t0.at}, vatOK...)
vδTok_ = append([]map[Key]Δstring{δTok}, vδTok_...)
}
t0 = t0.prev
}
vδTok = vδTok_
lo := t0.at
hi := tj.at
vδToid := δbtail.SliceByRootRev(treeRoot, lo, hi)
l = len(vδToid)
vat := make([]zodb.Tid, l)
vδT := []map[Key]Δstring{}
atPrev := lo
for i, δToid := range vδToid {
vat[i] = δToid.Rev
δT := XGetδKV(db, atPrev, δToid.Rev, δToid.ΔKV) // {} k -> δ(ZBlk(oid).data)
vδT = append(vδT, δT)
atPrev = δToid.Rev
}
if !(reflect.DeepEqual(vat, vatOK) && reflect.DeepEqual(vδT, vδTok)) {
have := ""
for i := 0; i<len(vδT); i++ {
have += fmt.Sprintf("\n\t@%s: %v", xat[vat[i]], vδT[i])
}
want := ""
for i := 0; i<len(vδTok); i++ {
want += fmt.Sprintf("\n\t@%s: %v", xat[vatOK[i]], vδTok[i])
}
t.Errorf("@%s: after Track%v + rebuild: SliceByRootRev:\nhave: %v\nwant: %v", xat[tj.at], keys, have, want)
}
*/
} }
// xverifyΔTtail verifies state of ΔTtail that corresponds to treeRoot in δbtail. // assertΔTtail verifies state of ΔTtail that corresponds to treeRoot in δbtail.
func xverifyΔTtail(t *testing.T, subj string, db *zodb.DB, δbtail *ΔBtail, tj *tTreeCommit, treeRoot zodb.Oid, xat map[zodb.Tid]string, vδTok ...map[Key]Δstring) { func assertΔTtail(t *testing.T, subj string, δbtail *ΔBtail, db *zodb.DB, tj *tTreeCommit, treeRoot zodb.Oid, xat map[zodb.Tid]string, vδTok ...map[Key]Δstring) {
t.Helper() t.Helper()
// XXX +KVAtTail, +lastRevOf // XXX +KVAtTail, +lastRevOf
......
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