Commit 16146b5a authored by Kirill Smelkov's avatar Kirill Smelkov

go/zodb/btree: Bucket.Get: Don't get ctx argument and just require that the...

go/zodb/btree: Bucket.Get: Don't get ctx argument and just require that the bucket must be already activated

It was scheduled to be so as described in removed TODO.
parent d0a62510
......@@ -187,33 +187,17 @@ func (t *BTree) Get(ctx context.Context, key KEY) (_ interface{}, _ bool, err er
t = child
case *Bucket:
v, ok, err := child.Get(ctx, key)
v, ok := child.Get(key)
child.PDeactivate()
return v, ok, err
return v, ok, nil
}
}
}
// Get searches Bucket by key.
//
// TODO Bucket.Get should not get ctx argument and just require that the bucket
// must be already activated. Correspondingly there should be no error returned.
func (b *Bucket) Get(ctx context.Context, key KEY) (_ interface{}, _ bool, err error) {
defer xerr.Contextf(&err, "bucket(%s): get %v", b.POid(), key)
err = b.PActivate(ctx)
if err != nil {
return nil, false, err
}
v, ok := b.get(key)
b.PDeactivate()
return v, ok, nil
}
// get searches Bucket by key.
//
// no loading from database is done. The bucket must be already activated.
func (b *Bucket) get(key KEY) (interface{}, bool) {
func (b *Bucket) Get(key KEY) (interface{}, bool) {
// search i: K(i-1) < k ≤ K(i) ; K(-1) = -∞, K(len) = +∞
i := sort.Search(len(b.keys), func(i int) bool {
return key <= b.keys[i]
......
......@@ -79,7 +79,7 @@ func (b *bucketWrap) withBucket(ctx context.Context, f func()) error {
func (b *bucketWrap) Get(ctx context.Context, key int64) (v interface{}, ok bool, err error) {
err = b.withBucket(ctx, func() {
v, ok = b.bucket().get(key) // TODO -> Get
v, ok = b.bucket().Get(key)
})
return
}
......
......@@ -189,33 +189,17 @@ func (t *IOBTree) Get(ctx context.Context, key int32) (_ interface{}, _ bool, er
t = child
case *IOBucket:
v, ok, err := child.Get(ctx, key)
v, ok := child.Get(key)
child.PDeactivate()
return v, ok, err
return v, ok, nil
}
}
}
// Get searches IOBucket by key.
//
// TODO IOBucket.Get should not get ctx argument and just require that the bucket
// must be already activated. Correspondingly there should be no error returned.
func (b *IOBucket) Get(ctx context.Context, key int32) (_ interface{}, _ bool, err error) {
defer xerr.Contextf(&err, "bucket(%s): get %v", b.POid(), key)
err = b.PActivate(ctx)
if err != nil {
return nil, false, err
}
v, ok := b.get(key)
b.PDeactivate()
return v, ok, nil
}
// get searches IOBucket by key.
//
// no loading from database is done. The bucket must be already activated.
func (b *IOBucket) get(key int32) (interface{}, bool) {
func (b *IOBucket) Get(key int32) (interface{}, bool) {
// search i: K(i-1) < k ≤ K(i) ; K(-1) = -∞, K(len) = +∞
i := sort.Search(len(b.keys), func(i int) bool {
return key <= b.keys[i]
......
......@@ -189,33 +189,17 @@ func (t *LOBTree) Get(ctx context.Context, key int64) (_ interface{}, _ bool, er
t = child
case *LOBucket:
v, ok, err := child.Get(ctx, key)
v, ok := child.Get(key)
child.PDeactivate()
return v, ok, err
return v, ok, nil
}
}
}
// Get searches LOBucket by key.
//
// TODO LOBucket.Get should not get ctx argument and just require that the bucket
// must be already activated. Correspondingly there should be no error returned.
func (b *LOBucket) Get(ctx context.Context, key int64) (_ interface{}, _ bool, err error) {
defer xerr.Contextf(&err, "bucket(%s): get %v", b.POid(), key)
err = b.PActivate(ctx)
if err != nil {
return nil, false, err
}
v, ok := b.get(key)
b.PDeactivate()
return v, ok, nil
}
// get searches LOBucket by key.
//
// no loading from database is done. The bucket must be already activated.
func (b *LOBucket) get(key int64) (interface{}, bool) {
func (b *LOBucket) Get(key int64) (interface{}, bool) {
// search i: K(i-1) < k ≤ K(i) ; K(-1) = -∞, K(len) = +∞
i := sort.Search(len(b.keys), func(i int) bool {
return key <= b.keys[i]
......
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