[#199] Split IsSmall check in metabase

Signed-off-by: Alex Vanin <alexey@nspcc.ru>
This commit is contained in:
Alex Vanin 2020-11-27 20:47:58 +03:00
parent 5bfae833fe
commit b45d523125

View file

@ -12,17 +12,22 @@ import (
// indexed in metabase. // indexed in metabase.
func (db *DB) IsSmall(addr *objectSDK.Address) (id *blobovnicza.ID, err error) { func (db *DB) IsSmall(addr *objectSDK.Address) (id *blobovnicza.ID, err error) {
err = db.boltDB.View(func(tx *bbolt.Tx) error { err = db.boltDB.View(func(tx *bbolt.Tx) error {
// if graveyard is empty, then check if object exists in primary bucket id, err = db.isSmall(tx, addr)
smallBucket := tx.Bucket(smallBucketName(addr.ContainerID()))
if smallBucket == nil {
return nil
}
blobovniczaID := smallBucket.Get(objectKey(addr.ObjectID()))
id = blobovnicza.NewIDFromBytes(blobovniczaID)
return err return err
}) })
return id, err return id, err
} }
func (db *DB) isSmall(tx *bbolt.Tx, addr *objectSDK.Address) (*blobovnicza.ID, error) {
smallBucket := tx.Bucket(smallBucketName(addr.ContainerID()))
if smallBucket == nil {
return nil, nil
}
blobovniczaID := smallBucket.Get(objectKey(addr.ObjectID()))
id := blobovnicza.NewIDFromBytes(blobovniczaID)
return id, nil
}