Commit 21bd85f5 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 9b023909
......@@ -377,6 +377,12 @@ func (S *RangedKeySet) Clear() {
S.rangev = nil
}
// AllRanges returns slice of all key ranges in the set.
// XXX -> iter?
func (S *RangedKeySet) AllRanges() /*readonly*/[]KeyRange {
return S.rangev
}
func (S RangedKeySet) String() string {
s := "{"
for i, r := range S.rangev {
......
......@@ -129,18 +129,18 @@ func TestRangedKeySet(t *testing.T) {
t.Errorf("Difference:\n A: %s\n B: %s\n ->d: %s\n okD: %s\n", tt.A, tt.B, D, tt.Difference)
}
// HasRange XXX use AllRanges instead of direct .rangev access
assertHasRange(t, A.rangev, A, true)
assertHasRange(t, B.rangev, B, true)
assertHasRange(t, A.rangev, U, true)
assertHasRange(t, B.rangev, U, true)
// HasRange
assertHasRange(t, A.AllRanges(), A, true)
assertHasRange(t, B.AllRanges(), B, true)
assertHasRange(t, A.AllRanges(), U, true)
assertHasRange(t, B.AllRanges(), U, true)
Dab := D
Dba := B.Difference(A)
assertHasRange(t, Dab.rangev, A, true)
assertHasRange(t, Dab.rangev, B, false)
assertHasRange(t, Dba.rangev, B, true)
assertHasRange(t, Dba.rangev, A, false)
assertHasRange(t, Dab.AllRanges(), A, true)
assertHasRange(t, Dab.AllRanges(), B, false)
assertHasRange(t, Dba.AllRanges(), B, true)
assertHasRange(t, Dba.AllRanges(), A, false)
}
}
......
......@@ -714,9 +714,12 @@ func diffT(ctx context.Context, A, B *Tree, δZTC SetOid, trackSet PPTreeSubSet)
break
}
for k := range Bkqueue {
b, err := Bv.GetToLeaf(ctx, k); /*X*/if err != nil { return nil,nil, err }
tracef(" B k%d -> %s\n", k, b)
// for k := range Bkqueue {
for _, r := range Bkqueue.AllRanges() {
lo := r.lo
for {
b, err := Bv.GetToLeaf(ctx, lo); /*X*/if err != nil { return nil,nil, err }
tracef(" B k%d -> %s\n", lo, b)
// +bucket if that bucket is reached for the first time
if !b.done {
var δB map[Key]ΔValue
......@@ -743,15 +746,26 @@ func diffT(ctx context.Context, A, B *Tree, δZTC SetOid, trackSet PPTreeSubSet)
b.done = true
}
// stop if r coverage is complete
if r.hi_ <= b.hi_ {
break
}
// continue with next right bucket
lo = b.hi_ + 1
}
// XXX k is not there -> hole XXX test XXX <- kill?
}
Bkqueue.Clear()
tracef("\n")
tracef(" Akq: %s\n", Akqueue)
for k := range Akqueue {
a, err := Av.GetToLeaf(ctx, k); /*X*/if err != nil { return nil,nil, err }
tracef(" A k%d -> %s\n", k, a)
// for k := range Akqueue {
for _, r := range Akqueue.AllRanges() {
lo := r.lo
for {
a, err := Av.GetToLeaf(ctx, lo); /*X*/if err != nil { return nil,nil, err }
tracef(" A k%d -> %s\n", lo, a)
// -bucket if that bucket is reached for the first time
if !a.done {
var δA map[Key]ΔValue
......@@ -782,6 +796,14 @@ func diffT(ctx context.Context, A, B *Tree, δZTC SetOid, trackSet PPTreeSubSet)
a.done = true
}
// stop if r coverage is complete
if r.hi_ <= a.hi_ {
break
}
// continue with next right bucket
lo = a.hi_ + 1
}
}
Akqueue.Clear()
}
......
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