Commit d4805b37 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent ee67e0b9
......@@ -113,3 +113,19 @@ func (s Set) SymmetricDifference(t Set) Set {
}
return d
}
// Equal returns whether a == b.
func (a Set) Equal(b Set) bool {
if len(a) != len(b) {
return false
}
for v := range a {
_, ok := b[v]
if !ok {
return false
}
}
return true
}
......@@ -115,3 +115,19 @@ func (s SetBigFile) SymmetricDifference(t SetBigFile) SetBigFile {
}
return d
}
// Equal returns whether a == b.
func (a SetBigFile) Equal(b SetBigFile) bool {
if len(a) != len(b) {
return false
}
for v := range a {
_, ok := b[v]
if !ok {
return false
}
}
return true
}
......@@ -115,3 +115,19 @@ func (s SetI64) SymmetricDifference(t SetI64) SetI64 {
}
return d
}
// Equal returns whether a == b.
func (a SetI64) Equal(b SetI64) bool {
if len(a) != len(b) {
return false
}
for v := range a {
_, ok := b[v]
if !ok {
return false
}
}
return true
}
......@@ -115,3 +115,19 @@ func (s SetOid) SymmetricDifference(t SetOid) SetOid {
}
return d
}
// Equal returns whether a == b.
func (a SetOid) Equal(b SetOid) bool {
if len(a) != len(b) {
return false
}
for v := range a {
_, ok := b[v]
if !ok {
return false
}
}
return true
}
......@@ -572,7 +572,7 @@ func (kadj KAdjMatrix) Map(keys SetKey) SetKey {
//
// KAdj itself is verified by testΔBTail on entries with .kadjOK set.
func KAdj(t1, t2 *tTreeCommit, keysv ...SetKey) (kadj KAdjMatrix) {
// XXX vvv verifies that KAdj(A,B) == KAdj(B,A)
// assert KAdj(A,B) == KAdj(B,A)
kadj12 := _KAdj(t1,t2, keysv...)
kadj21 := _KAdj(t2,t1, keysv...)
if !reflect.DeepEqual(kadj12, kadj21) {
......@@ -879,6 +879,7 @@ func xverifyΔBTail_rebuild(t *testing.T, db *zodb.DB, treeRoot zodb.Oid, t0, t1
fmt.Printf("@%s: %v\n", xat[t1.at], t1.xkv.Flatten())
fmt.Printf("@%s: %v\n", xat[t2.at], t2.xkv.Flatten())
kadj01 := KAdj(t0,t1, allTestKeys(t0,t1,t2))
kadj10 := KAdj(t1,t0, allTestKeys(t0,t1,t2))
kadj21 := KAdj(t2,t1, allTestKeys(t0,t1,t2))
kadj12 := KAdj(t1,t2, allTestKeys(t0,t1,t2))
......@@ -922,7 +923,8 @@ func xverifyΔBTail_rebuild(t *testing.T, db *zodb.DB, treeRoot zodb.Oid, t0, t1
t.Run((" →" + t2.tree), func(t *testing.T) {
// 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))
xverifyΔBTail_rebuild_U(t, δbtail, t1, t2, xat, /*trackSet=*/t2.xkv.trackSet(keys1_2))
// tRestKeys2 = tAllKeys - keys1
......@@ -934,13 +936,36 @@ func xverifyΔBTail_rebuild(t *testing.T, db *zodb.DB, treeRoot zodb.Oid, t0, t1
keys2.Add(tRestKeyv2[idx2])
}
// find out full set of keys that should become tracked after
// Track(keys2) + rebuild
keys12R := keys1_2.Union(keys2)
for {
keys12R_ := kadj10.Map(kadj21.Map(keys12R))
if keys12R.Equal(keys12R_) {
break
}
keys12R = keys12R_
}
// δkv1_2 = t1.δxkv / kadj10(kadj21(kadj12(keys1) | keys2))
// δkv2_2 = t2.δxkv / kadj10(kadj21(kadj12(keys1) | keys2))
keys12_2 := keys1_2.Union(keys2)
keys12_0 := kadj10.Map(kadj21.Map(keys12_2))
// 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("keys12R=%s\n", keys12R)
fmt.Printf("t0.xkv: %v\n", t0.xkv)
fmt.Printf("t1.xkv: %v\n", t1.xkv)
fmt.Printf("t2.xkv: %v\n", t2.xkv)
fmt.Printf("kadj21: %v\n", kadj21)
fmt.Printf("kadj12: %v\n", kadj12)
fmt.Printf("t2.xkv.trackSet(%s) -> %s", keys12R, t2.xkv.trackSet(keys12R))
fmt.Printf("\n\n\n")
δkv1_2 := map[Key]Δstring{}
δkv2_2 := map[Key]Δstring{}
for k := range keys12_0 {
for k := range keys12R {
δv1, ok := t1.δxkv[k]
if ok {
δkv1_2[k] = δv1
......@@ -957,12 +982,13 @@ func xverifyΔBTail_rebuild(t *testing.T, db *zodb.DB, treeRoot zodb.Oid, t0, t1
xverifyΔBTail_rebuild_TR(t, db, δbtail_, t2, treeRoot, xat,
// after Track(keys2)
keys2,
/*trackSet*/ t2.xkv.trackSet(keys1_0.Union(keys1_2)),
// /*trackSet*/ t2.xkv.trackSet(keys1_0.Union(keys1_2)),
/*trackSet*/ t2.xkv.trackSet(keys1_2),
// FIXME vvv trackNew should not cover ranges that are already in trackSet
/*trackNew*/ t2.xkv.trackSet(keys2),
// after rebuild
/* trackSet=*/ t2.xkv.trackSet(keys12_0),
/* trackSet=*/ t2.xkv.trackSet(keys12R),
/*vδT=*/ δkv1_2, δkv2_2)
// })
}
......
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