[#218] blobovnicza: Сreate at least one range bucket

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
Leonard Lyubich 2020-11-30 10:21:28 +03:00 committed by Alex Vanin
parent 1b0d2c67d1
commit 3acbd3011b

View file

@ -26,7 +26,7 @@ func (b *Blobovnicza) iterateBucketKeys(f func(uint64, uint64, []byte) (bool, er
} }
func (b *Blobovnicza) iterateBounds(f func(uint64, uint64) (bool, error)) error { func (b *Blobovnicza) iterateBounds(f func(uint64, uint64) (bool, error)) error {
for upper := firstBucketBound; upper <= b.objSizeLimit; upper *= 2 { for upper := firstBucketBound; upper <= max(b.objSizeLimit, firstBucketBound); upper *= 2 {
var lower uint64 var lower uint64
if upper == firstBucketBound { if upper == firstBucketBound {
@ -44,3 +44,11 @@ func (b *Blobovnicza) iterateBounds(f func(uint64, uint64) (bool, error)) error
return nil return nil
} }
func max(a, b uint64) uint64 {
if a > b {
return a
}
return b
}