[#1214] *: Use single Object type in whole project

Remove `Object` and `RawObject` types from `pkg/core/object` package.
Use `Object` type from NeoFS SDK Go library everywhere. Avoid using the
deprecated elements.

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
Leonard Lyubich 2022-03-03 17:19:05 +03:00 committed by Alex Vanin
parent 19ad349b27
commit 7ccd1625af
100 changed files with 847 additions and 965 deletions

View file

@ -5,11 +5,11 @@ import (
"time"
"github.com/mr-tron/base58"
"github.com/nspcc-dev/neofs-node/pkg/core/object"
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/blobovnicza"
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/blobstor"
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/blobstor/fstree"
meta "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/metabase"
"github.com/nspcc-dev/neofs-sdk-go/object"
addressSDK "github.com/nspcc-dev/neofs-sdk-go/object/address"
"go.etcd.io/bbolt"
"go.uber.org/zap"

View file

@ -2,12 +2,13 @@ package writecache
import (
"github.com/nspcc-dev/neofs-node/pkg/core/object"
objectSDK "github.com/nspcc-dev/neofs-sdk-go/object"
addressSDK "github.com/nspcc-dev/neofs-sdk-go/object/address"
"go.etcd.io/bbolt"
)
// Get returns object from write-cache.
func (c *cache) Get(addr *addressSDK.Address) (*object.Object, error) {
func (c *cache) Get(addr *addressSDK.Address) (*objectSDK.Object, error) {
saddr := addr.String()
c.mtx.RLock()
@ -22,7 +23,7 @@ func (c *cache) Get(addr *addressSDK.Address) (*object.Object, error) {
value, err := Get(c.db, []byte(saddr))
if err == nil {
obj := object.New()
obj := objectSDK.New()
c.flushed.Get(saddr)
return obj, obj.Unmarshal(value)
}
@ -32,7 +33,7 @@ func (c *cache) Get(addr *addressSDK.Address) (*object.Object, error) {
return nil, object.ErrNotFound
}
obj := object.New()
obj := objectSDK.New()
if err := obj.Unmarshal(data); err != nil {
return nil, err
}
@ -42,7 +43,7 @@ func (c *cache) Get(addr *addressSDK.Address) (*object.Object, error) {
}
// Head returns object header from write-cache.
func (c *cache) Head(addr *addressSDK.Address) (*object.Object, error) {
func (c *cache) Head(addr *addressSDK.Address) (*objectSDK.Object, error) {
// TODO: #1149 easiest to implement solution is presented here, consider more efficient way, e.g.:
// - provide header as common object.Object to Put, but marked to prevent correlation with full object
// (all write-cache logic will automatically spread to headers, except flushing)
@ -55,7 +56,7 @@ func (c *cache) Head(addr *addressSDK.Address) (*object.Object, error) {
}
// NOTE: resetting the payload via the setter can lead to data corruption of in-memory objects, but ok for others
return object.NewRawFromObject(obj).CutPayload().Object(), nil
return obj.CutPayload(), nil
}
// Get fetches object from the underlying database.

View file

@ -4,6 +4,7 @@ import (
"sort"
"time"
"github.com/nspcc-dev/neofs-node/pkg/core/object"
storagelog "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/internal/log"
"go.etcd.io/bbolt"
"go.uber.org/zap"
@ -112,7 +113,7 @@ func (c *cache) persistBigObject(objInfo objectInfo) {
cacheSz := c.estimateCacheSize()
metaIndex := 0
if c.incSizeFS(cacheSz) <= c.maxCacheSize {
err := c.fsTree.Put(objInfo.obj.Address(), objInfo.data)
err := c.fsTree.Put(object.AddressOf(objInfo.obj), objInfo.data)
if err == nil {
metaIndex = 1
if c.blobstor.NeedsCompression(objInfo.obj) {

View file

@ -5,13 +5,14 @@ import (
"github.com/nspcc-dev/neofs-node/pkg/core/object"
storagelog "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/internal/log"
objectSDK "github.com/nspcc-dev/neofs-sdk-go/object"
)
// ErrBigObject is returned when object is too big to be placed in cache.
var ErrBigObject = errors.New("too big object")
// Put puts object to write-cache.
func (c *cache) Put(o *object.Object) error {
func (c *cache) Put(o *objectSDK.Object) error {
c.modeMtx.RLock()
defer c.modeMtx.RUnlock()
if c.mode == ModeReadOnly {
@ -29,7 +30,7 @@ func (c *cache) Put(o *object.Object) error {
}
oi := objectInfo{
addr: o.Address().String(),
addr: object.AddressOf(o).String(),
obj: o,
data: data,
}

View file

@ -3,8 +3,8 @@ package writecache
import (
"sync"
"github.com/nspcc-dev/neofs-node/pkg/core/object"
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/blobstor/fstree"
"github.com/nspcc-dev/neofs-sdk-go/object"
addressSDK "github.com/nspcc-dev/neofs-sdk-go/object/address"
"go.uber.org/zap"
)