Commit a22223af authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent fc9b4d85
......@@ -29,13 +29,16 @@ const traceRangeSet = false
const debugRangeSet = false
// Range represents [lo,hi) Key range.
// XXX -> KeyRange?
type Range struct {
lo Key
hi_ Key // NOTE _not_ hi) to avoid overflow at ∞; hi = hi_ + 1
}
// RangeSet is set of Keys with adjacent keys coaleced into Ranges.
// XXX -> RangedSet ?
//
// Zero value represents empty set.
// XXX -> RangedSet ? RangedKeySet ? RangeKeySet?
type RangeSet struct {
// TODO rework to use BTree lo->hi_ instead if in practice in treediff,
// and other usage places, N(ranges) turns out to be not small
......@@ -347,6 +350,11 @@ func (orig *RangeSet) Clone() *RangeSet {
return klon
}
// Empty returns whether the set is empty.
func (S *RangeSet) Empty() bool {
return len(S.rangev) == 0
}
// Equal returns whether A == B.
func (A *RangeSet) Equal(B *RangeSet) bool {
if len(A.rangev) != len(B.rangev) {
......
......@@ -520,25 +520,25 @@ func diffT(ctx context.Context, A, B *Tree, δZTC SetOid, trackSet PPTreeSubSet)
Bv := rangeSplit{btop} // nodes expanded from B
// for phase 2:
Akqueue := SetKey{} // queue for keys in A to be processed for δ- XXX -> KeyRangeSet
Bkqueue := SetKey{} // ----//---- in B for δ+ XXX ----//----
Akdone := SetKey{} // already processed keys in A XXX ----//----
Bkdone := SetKey{} // ----//---- in B XXX ----//----
Akqueue := &RangeSet{} // queue for keys in A to be processed for δ-
Bkqueue := &RangeSet{} // ----//---- in B for δ+
Akdone := &RangeSet{} // already processed keys in A
Bkdone := &RangeSet{} // ----//---- in B
Aktodo := func(k Key) {
if !Akdone.Has(k) {
tracef(" Akq <- %d\n", k)
Akqueue.Add(k)
}
}
Bktodo := func(lo, hi_ Key) { // XXX func(r KeyRange)
panic("TODO")
/* XXX reenable
Bktodo := func(lo, hi_ Key) { // XXX -> func(r Range)
r := Range{lo, hi_}
if !Bkdone.HasRange(r) {
δtodo := r.Difference(Bkdone) // XXX name
δtodo := &RangeSet{}
δtodo.AddRange(r)
δtodo.DifferenceInplace(Bkdone)
tracef(" Bkq <- %s\n", δtodo)
Bkqueue.UnionInplace(δtodo)
}
*/
/* XXX kill
if !Bkdone.Has(k) {
tracef(" Bkq <- %d\n", k)
......@@ -702,7 +702,7 @@ func diffT(ctx context.Context, A, B *Tree, δZTC SetOid, trackSet PPTreeSubSet)
tracef("\n")
tracef(" Bkq: %s\n", Bkqueue)
if len(Bkqueue) == 0 {
if Bkqueue.Empty() {
break
}
......
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