Commit ea98b4ed authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 0a3c7cbe
...@@ -124,11 +124,6 @@ type ( ...@@ -124,11 +124,6 @@ type (
k interface {} /*K*/ k interface {} /*K*/
kset bool // if not set - k not present kset bool // if not set - k not present
} }
//keyrange struct { // key range [kmin, kmax)
// kmin xkey // if not set = -∞
// kmax xkey // if not set = +∞
//}
) )
var ( // R/O zero values var ( // R/O zero values
...@@ -568,7 +563,6 @@ func (t *Tree) overflow(p *x, q *d, pi, i int, k interface{} /*K*/, v interface{ ...@@ -568,7 +563,6 @@ func (t *Tree) overflow(p *x, q *d, pi, i int, k interface{} /*K*/, v interface{
p.x[pi-1].k = q.d[0].k p.x[pi-1].k = q.d[0].k
t.hitKmin.set(q.d[0].k) t.hitKmin.set(q.d[0].k)
t.hitPi = pi // XXX already pre-set this way t.hitPi = pi // XXX already pre-set this way
t.checkHitP(q)
return return
} }
...@@ -579,7 +573,6 @@ func (t *Tree) overflow(p *x, q *d, pi, i int, k interface{} /*K*/, v interface{ ...@@ -579,7 +573,6 @@ func (t *Tree) overflow(p *x, q *d, pi, i int, k interface{} /*K*/, v interface{
p.x[pi].k = r.d[0].k p.x[pi].k = r.d[0].k
t.hitKmax.set(r.d[0].k) t.hitKmax.set(r.d[0].k)
t.hitPi = pi // XXX already pre-set this way t.hitPi = pi // XXX already pre-set this way
t.checkHitP(q)
return return
} }
...@@ -593,7 +586,6 @@ func (t *Tree) overflow(p *x, q *d, pi, i int, k interface{} /*K*/, v interface{ ...@@ -593,7 +586,6 @@ func (t *Tree) overflow(p *x, q *d, pi, i int, k interface{} /*K*/, v interface{
} }
t.hitKmax = kmax t.hitKmax = kmax
t.hitPi = pi + 1 t.hitPi = pi + 1
t.checkHitP(r)
return return
} }
...@@ -653,9 +645,6 @@ func (t *Tree) SeekLast() (e *Enumerator, err error) { ...@@ -653,9 +645,6 @@ func (t *Tree) SeekLast() (e *Enumerator, err error) {
return btEPool.get(nil, true, q.c-1, q.d[q.c-1].k, q, t, t.ver), nil return btEPool.get(nil, true, q.c-1, q.d[q.c-1].k, q, t, t.ver), nil
} }
// verify that t.hit* are computed ok
// XXX -> all_test
// Set sets the value associated with k. // Set sets the value associated with k.
func (t *Tree) Set(k interface{} /*K*/, v interface{} /*V*/) { func (t *Tree) Set(k interface{} /*K*/, v interface{} /*V*/) {
//dbg("--- PRE Set(%v, %v)\t(%v @%d, [%v, %v) PKmax: %v)\n%s", k, v, t.hitD, t.hitDi, t.hitKmin, t.hitKmax, t.hitPKmax, t.dump()) //dbg("--- PRE Set(%v, %v)\t(%v @%d, [%v, %v) PKmax: %v)\n%s", k, v, t.hitD, t.hitDi, t.hitKmin, t.hitKmax, t.hitPKmax, t.dump())
...@@ -683,13 +672,13 @@ func (t *Tree) Set(k interface{} /*K*/, v interface{} /*V*/) { ...@@ -683,13 +672,13 @@ func (t *Tree) Set(k interface{} /*K*/, v interface{} /*V*/) {
t.insert(dd, i, k, v) t.insert(dd, i, k, v)
return return
// here: need to overflow but we have to check: if overflowing // here: need to overflow but we have to check: if overflowing would
// would cause upper level overflow -> we cannot overflow here - // cause upper level overflow (splitX) -> we cannot overflow here -
// - need to do the usual scan from root to split index pages. // - need to do the usual scan from root to split index pages.
default: default:
//break //break
p, pi := t.hitP, t.hitPi p, pi := t.hitP, t.hitPi
if p == nil || p.c <= 2*kx { // XXX < vs <= if p == nil || p.c <= 2*kx {
//dbg("overflow'") //dbg("overflow'")
t.overflow(p, dd, pi, i, k, v) t.overflow(p, dd, pi, i, k, v)
return return
...@@ -749,12 +738,12 @@ func (t *Tree) Set(k interface{} /*K*/, v interface{} /*V*/) { ...@@ -749,12 +738,12 @@ func (t *Tree) Set(k interface{} /*K*/, v interface{} /*V*/) {
q = p.x[pi].ch q = p.x[pi].ch
if pi > 0 { // XXX also check < p.c ? if pi > 0 {
hitKmin.set(p.x[pi-1].k) hitKmin.set(p.x[pi-1].k)
//dbg("hitKmin: %v", hitKmin) //dbg("hitKmin: %v", hitKmin)
} }
if pi < p.c { if pi < p.c { // == p.c means ∞
hitKmax.set(p.x[pi].k) hitKmax.set(p.x[pi].k)
//dbg("hitKmax: %v", hitKmax) //dbg("hitKmax: %v", hitKmax)
} }
...@@ -876,19 +865,6 @@ func (t *Tree) Put(k interface{} /*K*/, upd func(oldV interface{} /*V*/, exists ...@@ -876,19 +865,6 @@ func (t *Tree) Put(k interface{} /*K*/, upd func(oldV interface{} /*V*/, exists
} }
} }
func (t *Tree) checkHitP(q *d) {
p := t.hitP
pi := t.hitPi
if p.x[t.hitPi].ch != q {
println()
dbg("BUG: HITP MISMATCH:")
dbg("hitP: %v @%d", p, pi)
dbg("q: %p", q)
println()
panic(0)
}
}
func (t *Tree) split(p *x, q *d, pi, i int, k interface{} /*K*/, v interface{} /*V*/) { func (t *Tree) split(p *x, q *d, pi, i int, k interface{} /*K*/, v interface{} /*V*/) {
t.ver++ t.ver++
r := btDPool.Get().(*d) r := btDPool.Get().(*d)
...@@ -926,12 +902,10 @@ func (t *Tree) split(p *x, q *d, pi, i int, k interface{} /*K*/, v interface{} / ...@@ -926,12 +902,10 @@ func (t *Tree) split(p *x, q *d, pi, i int, k interface{} /*K*/, v interface{} /
} }
t.hitKmax = kmax t.hitKmax = kmax
t.hitPi = pi + 1 t.hitPi = pi + 1
t.checkHitP(r)
} else { } else {
t.insert(q, i, k, v) t.insert(q, i, k, v)
t.hitKmax.set(r.d[0].k) t.hitKmax.set(r.d[0].k)
t.hitPi = pi // XXX already pre-set so t.hitPi = pi // XXX already pre-set so
t.checkHitP(q)
} }
} }
......
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