[#186] object/range: Use new storage engine for work

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
Leonard Lyubich 2020-11-19 11:28:58 +03:00 committed by Alex Vanin
parent 9b32f131c0
commit 14442a0801
2 changed files with 7 additions and 15 deletions

View file

@ -4,7 +4,7 @@ import (
"io" "io"
"github.com/nspcc-dev/neofs-api-go/pkg/object" "github.com/nspcc-dev/neofs-api-go/pkg/object"
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/localstore" "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/engine"
"github.com/pkg/errors" "github.com/pkg/errors"
) )
@ -13,24 +13,16 @@ type localRangeWriter struct {
rng *object.Range rng *object.Range
storage *localstore.Storage storage *engine.StorageEngine
} }
func (l *localRangeWriter) WriteTo(w io.Writer) (int64, error) { func (l *localRangeWriter) WriteTo(w io.Writer) (int64, error) {
obj, err := l.storage.Get(l.addr) rngData, err := engine.GetRange(l.storage, l.addr, l.rng)
if err != nil { if err != nil {
return 0, errors.Wrapf(err, "(%T) could not get object from local storage", l) return 0, errors.Wrapf(err, "(%T) could not get object from local storage", l)
} }
payload := obj.Payload() n, err := w.Write(rngData)
left := l.rng.GetOffset()
right := left + l.rng.GetLength()
if ln := uint64(len(payload)); ln < right {
return 0, errors.Errorf("(%T) object range is out-of-boundaries (size %d, range [%d:%d]", l, ln, left, right)
}
n, err := w.Write(payload[left:right])
return int64(n), err return int64(n), err
} }

View file

@ -8,7 +8,7 @@ import (
"github.com/nspcc-dev/neofs-api-go/pkg/object" "github.com/nspcc-dev/neofs-api-go/pkg/object"
"github.com/nspcc-dev/neofs-node/pkg/core/container" "github.com/nspcc-dev/neofs-node/pkg/core/container"
"github.com/nspcc-dev/neofs-node/pkg/core/netmap" "github.com/nspcc-dev/neofs-node/pkg/core/netmap"
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/localstore" "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/engine"
"github.com/nspcc-dev/neofs-node/pkg/network" "github.com/nspcc-dev/neofs-node/pkg/network"
"github.com/nspcc-dev/neofs-node/pkg/network/cache" "github.com/nspcc-dev/neofs-node/pkg/network/cache"
headsvc "github.com/nspcc-dev/neofs-node/pkg/services/object/head" headsvc "github.com/nspcc-dev/neofs-node/pkg/services/object/head"
@ -28,7 +28,7 @@ type Option func(*cfg)
type cfg struct { type cfg struct {
keyStorage *objutil.KeyStorage keyStorage *objutil.KeyStorage
localStore *localstore.Storage localStore *engine.StorageEngine
cnrSrc container.Source cnrSrc container.Source
@ -140,7 +140,7 @@ func WithKeyStorage(v *objutil.KeyStorage) Option {
} }
} }
func WithLocalStorage(v *localstore.Storage) Option { func WithLocalStorage(v *engine.StorageEngine) Option {
return func(c *cfg) { return func(c *cfg) {
c.localStore = v c.localStore = v
} }