Commit 3c207b7c authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 3422fba8
......@@ -77,6 +77,7 @@ import (
"fmt"
"math"
"reflect"
"sort"
"lab.nexedi.com/kirr/go123/xerr"
"lab.nexedi.com/kirr/neo/go/transaction"
......@@ -496,6 +497,38 @@ func (δBtail *ΔBtail) δZConnectTracked(δZv *zodb.EventCommit) (δZTC SetOid,
return δZTC, δtopsByRoot
}
// XXX place
// nodeInRange represents a Node coming under [lo, hi_] key range in its tree.
type nodeInRange struct {
lo, hi_ Key // [lo, hi_] NOTE _not_ hi) not to overflow at ∞
node Node
}
// rangeCover represents set of nodes covering a range.
// nodes come with key↑ and not intersection [lo,hi)
type rangeCover []*nodeInRange // key↑
// Get returns node covering key k.
// Get panics if k is outside covered range.
func (rc rangeCover) Get(k Key) *nodeInRange {
i := sort.Search(len(rc), func(i int) bool {
return k <= rc[i].hi_
})
if i == len(rc) {
panicf("key %v not covered", k) // XXX + coverage: ...
}
rn := rc[i]
if !(rn.lo <= k && k <= rn.hi_) {
panicf("BUG: get(%v) -> [%v, %v]", k, rn.lo, rn.hi_)
}
return rn
}
// treediff computes δT for tree specified by root in between old..new.
//
// δtops is set of top nodes for changed subtrees.
......
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