forked from TrueCloudLab/frostfs-node
[#211] blobstor: Add a branch for processing objects by size in Put
Implement "big or small" property classifier (only the size of the payload is temporarily considered). Save "big" objects in shallow dir. Save "small" objects in shallow dir until the moment of implementation of blobovnicza. Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
parent
cfc770c3fe
commit
b9054e2ee0
1 changed files with 22 additions and 2 deletions
|
@ -6,6 +6,7 @@ import (
|
|||
"path"
|
||||
|
||||
objectSDK "github.com/nspcc-dev/neofs-api-go/pkg/object"
|
||||
"github.com/nspcc-dev/neofs-node/pkg/core/object"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
|
@ -37,8 +38,16 @@ func (b *BlobStor) Put(prm *PutPrm) (*PutRes, error) {
|
|||
// compress object data
|
||||
data = b.compressor(data)
|
||||
|
||||
// save object in fs tree
|
||||
if b.isBig(prm.obj) {
|
||||
// save object in shallow dir
|
||||
return nil, b.fsTree.put(prm.obj.Address(), data)
|
||||
} else {
|
||||
// save object in blobovnicza
|
||||
|
||||
// FIXME: use Blobovnicza when it becomes implemented.
|
||||
// Temporary save in shallow dir.
|
||||
return nil, b.fsTree.put(prm.obj.Address(), data)
|
||||
}
|
||||
}
|
||||
|
||||
func (t *fsTree) put(addr *objectSDK.Address, data []byte) error {
|
||||
|
@ -50,3 +59,14 @@ func (t *fsTree) put(addr *objectSDK.Address, data []byte) error {
|
|||
|
||||
return ioutil.WriteFile(p, data, t.Permissions)
|
||||
}
|
||||
|
||||
// checks if object is "big".
|
||||
func (b *BlobStor) isBig(obj *object.Object) bool {
|
||||
// FIXME: headers are temporary ignored
|
||||
// due to slight impact in size.
|
||||
// In fact, we have to honestly calculate the size
|
||||
// in binary format, which requires Size() method.
|
||||
sz := obj.PayloadSize()
|
||||
|
||||
return sz > b.smallSizeLimit
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue