Commit 34fda4fd authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent d3f4a457
...@@ -797,7 +797,7 @@ func diffT(ctx context.Context, A, B *Tree, δZTC SetOid, trackSet PPTreeSubSet) ...@@ -797,7 +797,7 @@ func diffT(ctx context.Context, A, B *Tree, δZTC SetOid, trackSet PPTreeSubSet)
/* /*
// continue with next right bucket until r coverage is complete // continue with next right bucket until r coverage is complete
lo = a.hi_ + 1 lo = a.hi_ + 1
if r.hi_ <= lo { if r.hi_ < lo {
break break
} }
*/ */
......
...@@ -616,6 +616,10 @@ func _KAdj(t1, t2 *tTreeCommit, keysv ...SetKey) (kadj KAdjMatrix) { ...@@ -616,6 +616,10 @@ func _KAdj(t1, t2 *tTreeCommit, keysv ...SetKey) (kadj KAdjMatrix) {
panic("multiple key sets on the call") panic("multiple key sets on the call")
} }
tracef("\n\n_KAdj\n")
tracef("t1: %s\n", t1.tree)
tracef("t2: %s\n", t2.tree)
tracef("keys: %s\n", keys)
// 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 -> changes to adjacents must be in Update(t1->t2).
...@@ -629,14 +633,15 @@ func _KAdj(t1, t2 *tTreeCommit, keysv ...SetKey) (kadj KAdjMatrix) { ...@@ -629,14 +633,15 @@ func _KAdj(t1, t2 *tTreeCommit, keysv ...SetKey) (kadj KAdjMatrix) {
done1 := &RangedKeySet{} done1 := &RangedKeySet{}
done2 := &RangedKeySet{} done2 := &RangedKeySet{}
//tracef("\n") tracef("\nk%d\n", k)
for !q1.Empty() || !q2.Empty() { for !q1.Empty() || !q2.Empty() {
//tracef("q1: %v\n", q1) tracef("q1: %s\tdone1: %s\n", q1, done1)
//tracef("q2: %v\n", q2) tracef("q2: %s\tdone2: %s\n", q2, done2)
for _, r1 := range q1.AllRanges() { for _, r1 := range q1.AllRanges() {
lo1 := r1.lo lo1 := r1.lo
for { for {
b1 := t1.xkv.Get(lo1) b1 := t1.xkv.Get(lo1)
tracef(" b1: %s\n", b1)
for k_ := range keys { for k_ := range keys {
if b1.lo <= k_ && k_ <= b1.hi_ { if b1.lo <= k_ && k_ <= b1.hi_ {
adj1.Add(k_) adj1.Add(k_)
...@@ -649,10 +654,11 @@ func _KAdj(t1, t2 *tTreeCommit, keysv ...SetKey) (kadj KAdjMatrix) { ...@@ -649,10 +654,11 @@ func _KAdj(t1, t2 *tTreeCommit, keysv ...SetKey) (kadj KAdjMatrix) {
δq2.AddRange(b1r) δq2.AddRange(b1r)
δq2.DifferenceInplace(done2) δq2.DifferenceInplace(done2)
q2.UnionInplace(δq2) q2.UnionInplace(δq2)
tracef("q2 += %s\t-> %s\n", δq2, q2)
// continue with next right bucket until r1 coverage is complete // continue with next right bucket until r1 coverage is complete
lo1 = b1.hi_ + 1 lo1 = b1.hi_ + 1
if r1.hi_ <= lo1 { if r1.hi_ < lo1 {
break break
} }
} }
...@@ -663,6 +669,7 @@ func _KAdj(t1, t2 *tTreeCommit, keysv ...SetKey) (kadj KAdjMatrix) { ...@@ -663,6 +669,7 @@ func _KAdj(t1, t2 *tTreeCommit, keysv ...SetKey) (kadj KAdjMatrix) {
lo2 := r2.lo lo2 := r2.lo
for { for {
b2 := t2.xkv.Get(lo2) b2 := t2.xkv.Get(lo2)
tracef(" b2: %s\n", b2)
for k_ := range keys { for k_ := range keys {
if b2.lo <= k_ && k_ <= b2.hi_ { if b2.lo <= k_ && k_ <= b2.hi_ {
adj2.Add(k_) adj2.Add(k_)
...@@ -675,10 +682,11 @@ func _KAdj(t1, t2 *tTreeCommit, keysv ...SetKey) (kadj KAdjMatrix) { ...@@ -675,10 +682,11 @@ func _KAdj(t1, t2 *tTreeCommit, keysv ...SetKey) (kadj KAdjMatrix) {
δq1.AddRange(b2r) δq1.AddRange(b2r)
δq1.DifferenceInplace(done1) δq1.DifferenceInplace(done1)
q1.UnionInplace(δq1) q1.UnionInplace(δq1)
tracef("q1 += %s\t-> %s\n", δq1, q1)
// continue with next right bucket until r2 coverage is complete // continue with next right bucket until r2 coverage is complete
lo2 = b2.hi_ + 1 lo2 = b2.hi_ + 1
if r2.hi_ <= lo2 { if r2.hi_ < lo2 {
break break
} }
} }
...@@ -1447,7 +1455,7 @@ func TestΔBTail(t *testing.T) { ...@@ -1447,7 +1455,7 @@ func TestΔBTail(t *testing.T) {
// test known cases going through tree1 -> tree2 -> ... // test known cases going through tree1 -> tree2 -> ...
testv := []interface{} { testv := []interface{} {
///* /*
// start from non-empty tree to verify both ->empty and empty-> transitions // start from non-empty tree to verify both ->empty and empty-> transitions
"T/B1:a,2:b", "T/B1:a,2:b",
...@@ -1470,7 +1478,6 @@ func TestΔBTail(t *testing.T) { ...@@ -1470,7 +1478,6 @@ func TestΔBTail(t *testing.T) {
A{1: K(1,2,oo), A{1: K(1,2,oo),
2: K(1,2,oo), 2: K(1,2,oo),
oo: K(1,2,oo)}), oo: K(1,2,oo)}),
//*/
// 2: b->c // 2: b->c
Δ("T/B2:c", Δ("T/B2:c",
...@@ -1508,7 +1515,7 @@ func TestΔBTail(t *testing.T) { ...@@ -1508,7 +1515,7 @@ func TestΔBTail(t *testing.T) {
4: K(1,2,3,4,5,oo), 4: K(1,2,3,4,5,oo),
5: K(1,2,3,4,5,oo), 5: K(1,2,3,4,5,oo),
oo: K(1,2,3,4,5,oo)}), oo: K(1,2,3,4,5,oo)}),
*/
// reflow of keys: even if tracked={1}, changes to all B nodes need to be rescanned: // reflow of keys: even if tracked={1}, changes to all B nodes need to be rescanned:
// +B12 forces to look in -B23 which adds -3 into δ, which // +B12 forces to look in -B23 which adds -3 into δ, which
// forces to look into +B34 and so on. // forces to look into +B34 and so on.
......
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