Commit 0fa06cbd authored by Kirill Smelkov's avatar Kirill Smelkov

X kadj must be taken into account as kadj^δZ

parent 8a14e5c7
...@@ -495,7 +495,7 @@ func XGetδKV(db *zodb.DB, at1, at2 zodb.Tid, δkvOid map[Key]ΔValue) map[Key] ...@@ -495,7 +495,7 @@ func XGetδKV(db *zodb.DB, at1, at2 zodb.Tid, δkvOid map[Key]ΔValue) map[Key]
// ex δ(T/B1:a, T2/B1:b-B3:c) = {-1:a +1:b +3:c} // ex δ(T/B1:a, T2/B1:b-B3:c) = {-1:a +1:b +3:c}
// //
// Δ(T, Av, Bv) - subset of δ(Av, Bv) corresponding to initial tracking set T // Δ(T, Av, Bv) - subset of δ(Av, Bv) corresponding to initial tracking set T
// ex Δ({1}, T/B1:a, T2/B1:b-B3:c) = {-1:a +1:b} (no +3:c) // ex Δ({1}, T/B1:a, T2/B1:b-B3:c) = {-1:a +1:b} (no +3:c) XXX fix example
// //
// kadj(A,B) {} k -> {k'}: - adjacency matrix // kadj(A,B) {} k -> {k'}: - adjacency matrix
// ∃v1,v2: k'∈ Δ({k}, Av1, Bv2) // ∃v1,v2: k'∈ Δ({k}, Av1, Bv2)
...@@ -508,6 +508,8 @@ func XGetδKV(db *zodb.DB, at1, at2 zodb.Tid, δkvOid map[Key]ΔValue) map[Key] ...@@ -508,6 +508,8 @@ func XGetδKV(db *zodb.DB, at1, at2 zodb.Tid, δkvOid map[Key]ΔValue) map[Key]
// i.e. = δ(Av, Bv) for k: k ∈ U kadj(A,B)[·] // i.e. = δ(Av, Bv) for k: k ∈ U kadj(A,B)[·]
// ·∈T // ·∈T
// //
// XXX fix definition for "and changed"
//
// XXX adjacency matrix is symmetric: XXX KAdj verifies this at runtime // XXX adjacency matrix is symmetric: XXX KAdj verifies this at runtime
// //
// kadj(A,B) == kadj(B,A) // kadj(A,B) == kadj(B,A)
...@@ -633,7 +635,7 @@ func _KAdj(t1, t2 *tTreeCommit, keysv ...SetKey) (kadj KAdjMatrix) { ...@@ -633,7 +635,7 @@ func _KAdj(t1, t2 *tTreeCommit, keysv ...SetKey) (kadj KAdjMatrix) {
}() }()
// kadj = {} k -> adjacent keys. // kadj = {} k -> adjacent keys.
// if k is tracked -> changes to adjacents must be in Update(t1->t2). // if k is tracked and covered by changed leaf -> changes to adjacents must be in Update(t1->t2).
kadj = KAdjMatrix{} kadj = KAdjMatrix{}
for k := range keys { for k := range keys {
adj1 := SetKey{} adj1 := SetKey{}
...@@ -747,8 +749,13 @@ func xverifyΔBTail_Update1(t *testing.T, subj string, db *zodb.DB, treeRoot zod ...@@ -747,8 +749,13 @@ func xverifyΔBTail_Update1(t *testing.T, subj string, db *zodb.DB, treeRoot zod
X := exc.Raiseif X := exc.Raiseif
tracef("\n>>> Track=%s\n", initialTrackedKeys) tracef("\n>>> Track=%s\n", initialTrackedKeys)
var kadjTracked SetKey = nil var TrackedδZ SetKey = nil
var kadjTrackedδZ SetKey = nil
var δT, δTok map[Key]Δstring = nil, nil var δT, δTok map[Key]Δstring = nil, nil
δZset := SetOid{}
for _, oid := range δZ.Changev {
δZset.Add(oid)
}
// badf queues error message to be reported on return. // badf queues error message to be reported on return.
var badv []string var badv []string
...@@ -759,7 +766,10 @@ func xverifyΔBTail_Update1(t *testing.T, subj string, db *zodb.DB, treeRoot zod ...@@ -759,7 +766,10 @@ func xverifyΔBTail_Update1(t *testing.T, subj string, db *zodb.DB, treeRoot zod
if badv != nil { if badv != nil {
emsg := fmt.Sprintf("%s ; tracked=%v :\n\n", subj, initialTrackedKeys) emsg := fmt.Sprintf("%s ; tracked=%v :\n\n", subj, initialTrackedKeys)
emsg += fmt.Sprintf("d12: %v\nδTok: %v\nδT: %v\n\n", d12, δTok, δT) emsg += fmt.Sprintf("d12: %v\nδTok: %v\nδT: %v\n\n", d12, δTok, δT)
emsg += fmt.Sprintf("kadj[Tracked]: %v\nkadj: %v\n\n", kadjTracked, kadj) emsg += fmt.Sprintf("δZ: %v\n", δZset)
emsg += fmt.Sprintf("Tracked^δZ: %v\n", TrackedδZ)
emsg += fmt.Sprintf("kadj[Tracked^δZ]: %v\n", kadjTrackedδZ)
emsg += fmt.Sprintf("kadj: %v\n\n", kadj)
emsg += strings.Join(badv, "\n") emsg += strings.Join(badv, "\n")
emsg += "\n" emsg += "\n"
...@@ -781,7 +791,6 @@ func xverifyΔBTail_Update1(t *testing.T, subj string, db *zodb.DB, treeRoot zod ...@@ -781,7 +791,6 @@ func xverifyΔBTail_Update1(t *testing.T, subj string, db *zodb.DB, treeRoot zod
ztree = xtree.(*Tree) ztree = xtree.(*Tree)
} }
kadjTracked = SetKey{} // kadj[Tracked] (all keys adjacent to tracked keys)
for k := range initialTrackedKeys { for k := range initialTrackedKeys {
if ztree != nil { if ztree != nil {
_, ok, path, err := ZTreeGetBlkData(ctx, ztree, k); X(err) _, ok, path, err := ZTreeGetBlkData(ctx, ztree, k); X(err)
...@@ -798,31 +807,53 @@ func xverifyΔBTail_Update1(t *testing.T, subj string, db *zodb.DB, treeRoot zod ...@@ -798,31 +807,53 @@ func xverifyΔBTail_Update1(t *testing.T, subj string, db *zodb.DB, treeRoot zod
// T1->ø, we test what will happen on ø->T2. // T1->ø, we test what will happen on ø->T2.
err = δbtail.track(k, false, []zodb.Oid{treeRoot}); X(err) err = δbtail.track(k, false, []zodb.Oid{treeRoot}); X(err)
} }
kadjTracked.Update(kadj[k])
} }
// assert Tracked ∈ kadj[Tracked] except ∞ XXX -> initialTrackedKeys.Difference(kadjTracked) TrackedδZ = SetKey{} // Tracked ^ δZ
trackedNotInKadj := SetKey{}
for k := range initialTrackedKeys { for k := range initialTrackedKeys {
if !kadjTracked.Has(k) { leaf1 := xkv1.Get(k)
trackedNotInKadj.Add(k) oid1 := leaf1.oid
if oid1 == zodb.InvalidOid { // embedded bucket
oid1 = leaf1.parent.oid
}
leaf2 := xkv2.Get(k)
oid2 := leaf2.oid
if oid2 == zodb.InvalidOid { // embedded bucket
oid2 = leaf2.parent.oid
}
// fmt.Printf("k%s -> oid1 %s oid2 %s\n", kstr(k), oid1, oid2)
if δZset.Has(oid1) || δZset.Has(oid2) {
TrackedδZ.Add(k)
}
}
kadjTrackedδZ = SetKey{} // kadj[Tracked^δZ] (all keys adjacent to tracked^δZ)
for k := range TrackedδZ {
kadjTrackedδZ.Update(kadj[k])
}
// XXX why "except ∞" ?
// assert TrackedδZ ∈ kadj[TrackedδZ] except ∞ XXX -> initialTrackedKeys.Difference(kadjTrackedδZ)
trackNotInKadj := SetKey{}
for k := range TrackedδZ {
if !kadjTrackedδZ.Has(k) {
trackNotInKadj.Add(k)
} }
} }
// trackedNotInKadj.Del(kInf) trackNotInKadj.Del(KeyMax)
trackedNotInKadj.Del(KeyMax) if len(trackNotInKadj) > 0 {
if len(trackedNotInKadj) > 0 { badf("BUG: Tracked^δZ ∉ kadj[Tracked^δZ] ; extra=%v", trackNotInKadj)
badf("BUG: Tracked ∉ kadj[Tracked] ; extra=%v", trackedNotInKadj)
return return
} }
// k ∈ d12 // k ∈ d12
// k ∈ δT <=> // k ∈ δT <=>
// k ∈ U kadj[·] // k ∈ U kadj[·]
// ·∈tracking // ·∈tracking^δZ
δTok = map[Key]Δstring{} // d12[all keys that should be present in δT] δTok = map[Key]Δstring{} // d12[all keys that should be present in δT]
for k,δv := range d12 { for k,δv := range d12 {
if kadjTracked.Has(k) { if kadjTrackedδZ.Has(k) {
δTok[k] = δv δTok[k] = δv
} }
} }
...@@ -872,7 +903,7 @@ func xverifyΔBTail_Update1(t *testing.T, subj string, db *zodb.DB, treeRoot zod ...@@ -872,7 +903,7 @@ func xverifyΔBTail_Update1(t *testing.T, subj string, db *zodb.DB, treeRoot zod
// verify δbtail.trackSet against @at2 // verify δbtail.trackSet against @at2
// trackSet2 = xkv2[tracked2] ( = xkv2[kadj[tracked1]] // trackSet2 = xkv2[tracked2] ( = xkv2[kadj[tracked1]]
trackSet2 := xkv2.trackSet(kadjTracked) trackSet2 := xkv2.trackSet(initialTrackedKeys.Union(kadjTrackedδZ))
// if !reflect.DeepEqual(trackSet2, δbtail.trackSet) { // if !reflect.DeepEqual(trackSet2, δbtail.trackSet) {
// badf("δbtail.trackSet2 wrong:\n\thave: %v\n\twant: %v", δbtail.trackSet, trackSet2) // badf("δbtail.trackSet2 wrong:\n\thave: %v\n\twant: %v", δbtail.trackSet, trackSet2)
// } // }
......
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