diff --git a/wcfs/internal/xbtree/treediff.go b/wcfs/internal/xbtree/treediff.go index 6e13d78c52a2ddf1a10bd022799c9be63920d5e0..78d39f3597f565baf6b543481ba14cd61a9e2ad1 100644 --- a/wcfs/internal/xbtree/treediff.go +++ b/wcfs/internal/xbtree/treediff.go @@ -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 lo = a.hi_ + 1 - if r.hi_ <= lo { + if r.hi_ < lo { break } */ diff --git "a/wcfs/internal/xbtree/\316\264btail_test.go" "b/wcfs/internal/xbtree/\316\264btail_test.go" index 8c486da3aeaf04da219058c5351f3360ec0590f2..b71248950694ec95a8833bca2f72aa893a047eed 100644 --- "a/wcfs/internal/xbtree/\316\264btail_test.go" +++ "b/wcfs/internal/xbtree/\316\264btail_test.go" @@ -616,6 +616,10 @@ func _KAdj(t1, t2 *tTreeCommit, keysv ...SetKey) (kadj KAdjMatrix) { 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. // 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) { done1 := &RangedKeySet{} done2 := &RangedKeySet{} - //tracef("\n") + tracef("\nk%d\n", k) for !q1.Empty() || !q2.Empty() { - //tracef("q1: %v\n", q1) - //tracef("q2: %v\n", q2) + tracef("q1: %s\tdone1: %s\n", q1, done1) + tracef("q2: %s\tdone2: %s\n", q2, done2) for _, r1 := range q1.AllRanges() { lo1 := r1.lo for { b1 := t1.xkv.Get(lo1) + tracef(" b1: %s\n", b1) for k_ := range keys { if b1.lo <= k_ && k_ <= b1.hi_ { adj1.Add(k_) @@ -649,10 +654,11 @@ func _KAdj(t1, t2 *tTreeCommit, keysv ...SetKey) (kadj KAdjMatrix) { 未q2.AddRange(b1r) 未q2.DifferenceInplace(done2) q2.UnionInplace(未q2) + tracef("q2 += %s\t-> %s\n", 未q2, q2) // continue with next right bucket until r1 coverage is complete lo1 = b1.hi_ + 1 - if r1.hi_ <= lo1 { + if r1.hi_ < lo1 { break } } @@ -663,6 +669,7 @@ func _KAdj(t1, t2 *tTreeCommit, keysv ...SetKey) (kadj KAdjMatrix) { lo2 := r2.lo for { b2 := t2.xkv.Get(lo2) + tracef(" b2: %s\n", b2) for k_ := range keys { if b2.lo <= k_ && k_ <= b2.hi_ { adj2.Add(k_) @@ -675,10 +682,11 @@ func _KAdj(t1, t2 *tTreeCommit, keysv ...SetKey) (kadj KAdjMatrix) { 未q1.AddRange(b2r) 未q1.DifferenceInplace(done1) q1.UnionInplace(未q1) + tracef("q1 += %s\t-> %s\n", 未q1, q1) // continue with next right bucket until r2 coverage is complete lo2 = b2.hi_ + 1 - if r2.hi_ <= lo2 { + if r2.hi_ < lo2 { break } } @@ -1447,7 +1455,7 @@ func Test螖BTail(t *testing.T) { // test known cases going through tree1 -> tree2 -> ... testv := []interface{} { -///* +/* // start from non-empty tree to verify both ->empty and empty-> transitions "T/B1:a,2:b", @@ -1470,7 +1478,6 @@ func Test螖BTail(t *testing.T) { A{1: K(1,2,oo), 2: K(1,2,oo), oo: K(1,2,oo)}), -//*/ // 2: b->c 螖("T/B2:c", @@ -1508,7 +1515,7 @@ func Test螖BTail(t *testing.T) { 4: K(1,2,3,4,5,oo), 5: 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: // +B12 forces to look in -B23 which adds -3 into 未, which // forces to look into +B34 and so on.