[#1463] blobovnicza: Determine db size via os.Stat

Currently we use `(*bbolt.Bucket).Stats().KeyN` for estimating database
size. However, it iterates over all pages in bucket and thus heavily
depends on the bucket size. This commit replaces initial size estimation
with a single `os.Stat` call.

Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
This commit is contained in:
Evgenii Stratonikov 2022-06-01 13:20:51 +03:00 committed by fyrchik
parent 021aa97965
commit d9f0ac8909
2 changed files with 17 additions and 7 deletions

View file

@ -40,7 +40,11 @@ func TestBlobovniczas(t *testing.T) {
c := defaultCfg()
var width, depth, szLim uint64 = 2, 2, 2 << 10
var width, depth uint64 = 2, 2
// sizeLim must be big enough, to hold at least multiple pages.
// 32 KiB is the initial size after all by-size buckets are created.
var szLim uint64 = 32*1024 + 1
for _, opt := range []Option{
WithLogger(l),
@ -77,7 +81,7 @@ func TestBlobovniczas(t *testing.T) {
// save object in blobovnicza
id, err := b.put(addr, d)
require.NoError(t, err)
require.NoError(t, err, i)
// get w/ blobovnicza ID
var prm GetSmallPrm