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

.

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