[#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

@ -430,7 +430,7 @@ func putObject(cmd *cobra.Command, _ []string) {
expAttr.SetValue(strconv.FormatUint(expiresOn, 10))
}
obj := object.NewRaw()
obj := object.New()
obj.SetContainerID(cid)
obj.SetOwnerID(ownerID)
obj.SetAttributes(attrs...)
@ -441,7 +441,7 @@ func putObject(cmd *cobra.Command, _ []string) {
sessionObjectCtxAddress.SetContainerID(cid)
prepareSessionPrmWithOwner(cmd, sessionObjectCtxAddress, key, ownerID, &prm)
prepareObjectPrm(cmd, &prm)
prm.SetHeader(obj.Object())
prm.SetHeader(obj)
prm.SetPayloadReader(f)
res, err := internalclient.PutObject(prm)

View file

@ -7,9 +7,8 @@ import (
"fmt"
internalclient "github.com/nspcc-dev/neofs-node/cmd/neofs-cli/internal/client"
"github.com/nspcc-dev/neofs-node/pkg/core/object"
"github.com/nspcc-dev/neofs-node/pkg/services/object_manager/storagegroup"
objectSDK "github.com/nspcc-dev/neofs-sdk-go/object"
"github.com/nspcc-dev/neofs-sdk-go/object"
addressSDK "github.com/nspcc-dev/neofs-sdk-go/object/address"
oidSDK "github.com/nspcc-dev/neofs-sdk-go/object/id"
"github.com/nspcc-dev/neofs-sdk-go/owner"
@ -149,13 +148,13 @@ func (c sgHeadReceiver) Head(addr *addressSDK.Address) (interface{}, error) {
res, err := internalclient.HeadObject(c.prm)
var errSplitInfo *objectSDK.SplitInfoError
var errSplitInfo *object.SplitInfoError
switch {
default:
return nil, err
case err == nil:
return object.NewFromSDK(res.Header()), nil
return res.Header(), nil
case errors.As(err, &errSplitInfo):
return errSplitInfo.SplitInfo(), nil
}
@ -205,12 +204,12 @@ func putSG(cmd *cobra.Command, _ []string) {
sgContent, err := sg.Marshal()
exitOnErr(cmd, errf("could not marshal storage group: %w", err))
obj := objectSDK.NewRaw()
obj := object.New()
obj.SetContainerID(cid)
obj.SetOwnerID(ownerID)
obj.SetType(objectSDK.TypeStorageGroup)
obj.SetType(object.TypeStorageGroup)
putPrm.SetHeader(obj.Object())
putPrm.SetHeader(obj)
putPrm.SetPayloadReader(bytes.NewReader(sgContent))
res, err := internalclient.PutObject(putPrm)

View file

@ -68,7 +68,7 @@ func NewFormatValidator(opts ...FormatValidatorOption) *FormatValidator {
// Does not validate payload checksum and content.
//
// Returns nil error if object has valid structure.
func (v *FormatValidator) Validate(obj *Object) error {
func (v *FormatValidator) Validate(obj *object.Object) error {
if obj == nil {
return errNilObject
} else if obj.ID() == nil {
@ -93,18 +93,18 @@ func (v *FormatValidator) Validate(obj *Object) error {
return fmt.Errorf("object did not pass expiration check: %w", err)
}
if err := object.CheckHeaderVerificationFields(obj.SDK()); err != nil {
if err := object.CheckHeaderVerificationFields(obj); err != nil {
return fmt.Errorf("(%T) could not validate header fields: %w", v, err)
}
if obj = obj.GetParent(); obj != nil {
if obj = obj.Parent(); obj != nil {
return v.Validate(obj)
}
return nil
}
func (v *FormatValidator) validateSignatureKey(obj *Object) error {
func (v *FormatValidator) validateSignatureKey(obj *object.Object) error {
token := obj.SessionToken()
key := obj.Signature().Key()
@ -133,7 +133,7 @@ func (v *FormatValidator) checkOwnerKey(id *owner.ID, key []byte) error {
}
// ValidateContent validates payload content according to object type.
func (v *FormatValidator) ValidateContent(o *Object) error {
func (v *FormatValidator) ValidateContent(o *object.Object) error {
switch o.Type() {
case object.TypeTombstone:
if len(o.Payload()) == 0 {
@ -174,7 +174,7 @@ func (v *FormatValidator) ValidateContent(o *Object) error {
}
if v.deleteHandler != nil {
v.deleteHandler.DeleteObjects(o.Address(), addrList...)
v.deleteHandler.DeleteObjects(AddressOf(o), addrList...)
}
case object.TypeStorageGroup:
if len(o.Payload()) == 0 {
@ -201,7 +201,7 @@ func (v *FormatValidator) ValidateContent(o *Object) error {
var errExpired = errors.New("object has expired")
func (v *FormatValidator) checkExpiration(obj *Object) error {
func (v *FormatValidator) checkExpiration(obj *object.Object) error {
exp, err := expirationEpochAttribute(obj)
if err != nil {
if errors.Is(err, errNoExpirationEpoch) {
@ -218,7 +218,7 @@ func (v *FormatValidator) checkExpiration(obj *Object) error {
return nil
}
func expirationEpochAttribute(obj *Object) (uint64, error) {
func expirationEpochAttribute(obj *object.Object) (uint64, error) {
for _, a := range obj.Attributes() {
if a.Key() != objectV2.SysAttributeExpEpoch {
continue
@ -235,7 +235,7 @@ var (
errEmptyAttrVal = errors.New("empty attribute value")
)
func (v *FormatValidator) checkAttributes(obj *Object) error {
func (v *FormatValidator) checkAttributes(obj *object.Object) error {
as := obj.Attributes()
mUnique := make(map[string]struct{}, len(as))
@ -259,7 +259,7 @@ func (v *FormatValidator) checkAttributes(obj *Object) error {
var errIncorrectOwner = errors.New("incorrect object owner")
func (v *FormatValidator) checkOwner(obj *Object) error {
func (v *FormatValidator) checkOwner(obj *object.Object) error {
// TODO: use appropriate functionality after neofs-api-go#352
if len(obj.OwnerID().ToV2().GetValue()) != owner.NEO3WalletSize {
return errIncorrectOwner

View file

@ -35,8 +35,8 @@ func testObjectID(t *testing.T) *oidSDK.ID {
return id
}
func blankValidObject(key *ecdsa.PrivateKey) *RawObject {
obj := NewRaw()
func blankValidObject(key *ecdsa.PrivateKey) *object.Object {
obj := object.New()
obj.SetContainerID(cidtest.ID())
obj.SetOwnerID(owner.NewIDFromPublicKey(&key.PublicKey))
@ -68,24 +68,24 @@ func TestFormatValidator_Validate(t *testing.T) {
})
t.Run("nil identifier", func(t *testing.T) {
obj := NewRaw()
obj := object.New()
require.True(t, errors.Is(v.Validate(obj.Object()), errNilID))
require.True(t, errors.Is(v.Validate(obj), errNilID))
})
t.Run("nil container identifier", func(t *testing.T) {
obj := NewRaw()
obj := object.New()
obj.SetID(testObjectID(t))
require.True(t, errors.Is(v.Validate(obj.Object()), errNilCID))
require.True(t, errors.Is(v.Validate(obj), errNilCID))
})
t.Run("unsigned object", func(t *testing.T) {
obj := NewRaw()
obj := object.New()
obj.SetContainerID(cidtest.ID())
obj.SetID(testObjectID(t))
require.Error(t, v.Validate(obj.Object()))
require.Error(t, v.Validate(obj))
})
t.Run("correct w/ session token", func(t *testing.T) {
@ -94,29 +94,29 @@ func TestFormatValidator_Validate(t *testing.T) {
tok := sessiontest.Token()
tok.SetOwnerID(oid)
obj := NewRaw()
obj := object.New()
obj.SetContainerID(cidtest.ID())
obj.SetSessionToken(sessiontest.Token())
obj.SetOwnerID(tok.OwnerID())
require.NoError(t, object.SetIDWithSignature(&ownerKey.PrivateKey, obj.SDK()))
require.NoError(t, object.SetIDWithSignature(&ownerKey.PrivateKey, obj))
require.NoError(t, v.Validate(obj.Object()))
require.NoError(t, v.Validate(obj))
})
t.Run("correct w/o session token", func(t *testing.T) {
obj := blankValidObject(&ownerKey.PrivateKey)
require.NoError(t, object.SetIDWithSignature(&ownerKey.PrivateKey, obj.SDK()))
require.NoError(t, object.SetIDWithSignature(&ownerKey.PrivateKey, obj))
require.NoError(t, v.Validate(obj.Object()))
require.NoError(t, v.Validate(obj))
})
t.Run("tombstone content", func(t *testing.T) {
obj := NewRaw()
obj := object.New()
obj.SetType(object.TypeTombstone)
require.Error(t, v.ValidateContent(obj.Object())) // no tombstone content
require.Error(t, v.ValidateContent(obj)) // no tombstone content
content := object.NewTombstone()
content.SetMembers([]*oidSDK.ID{nil})
@ -126,7 +126,7 @@ func TestFormatValidator_Validate(t *testing.T) {
obj.SetPayload(data)
require.Error(t, v.ValidateContent(obj.Object())) // no members in tombstone
require.Error(t, v.ValidateContent(obj)) // no members in tombstone
content.SetMembers([]*oidSDK.ID{testObjectID(t)})
@ -135,7 +135,7 @@ func TestFormatValidator_Validate(t *testing.T) {
obj.SetPayload(data)
require.Error(t, v.ValidateContent(obj.Object())) // no expiration epoch in tombstone
require.Error(t, v.ValidateContent(obj)) // no expiration epoch in tombstone
expirationAttribute := object.NewAttribute()
expirationAttribute.SetKey(objectV2.SysAttributeExpEpoch)
@ -143,7 +143,7 @@ func TestFormatValidator_Validate(t *testing.T) {
obj.SetAttributes(expirationAttribute)
require.Error(t, v.ValidateContent(obj.Object())) // different expiration values
require.Error(t, v.ValidateContent(obj)) // different expiration values
content.SetExpirationEpoch(10)
data, err = content.Marshal()
@ -151,14 +151,14 @@ func TestFormatValidator_Validate(t *testing.T) {
obj.SetPayload(data)
require.NoError(t, v.ValidateContent(obj.Object())) // all good
require.NoError(t, v.ValidateContent(obj)) // all good
})
t.Run("storage group content", func(t *testing.T) {
obj := NewRaw()
obj := object.New()
obj.SetType(object.TypeStorageGroup)
require.Error(t, v.ValidateContent(obj.Object()))
require.Error(t, v.ValidateContent(obj))
content := storagegroup.New()
content.SetMembers([]*oidSDK.ID{nil})
@ -168,7 +168,7 @@ func TestFormatValidator_Validate(t *testing.T) {
obj.SetPayload(data)
require.Error(t, v.ValidateContent(obj.Object()))
require.Error(t, v.ValidateContent(obj))
content.SetMembers([]*oidSDK.ID{testObjectID(t)})
@ -177,11 +177,11 @@ func TestFormatValidator_Validate(t *testing.T) {
obj.SetPayload(data)
require.NoError(t, v.ValidateContent(obj.Object()))
require.NoError(t, v.ValidateContent(obj))
})
t.Run("expiration", func(t *testing.T) {
fn := func(val string) *Object {
fn := func(val string) *object.Object {
obj := blankValidObject(&ownerKey.PrivateKey)
a := object.NewAttribute()
@ -190,9 +190,9 @@ func TestFormatValidator_Validate(t *testing.T) {
obj.SetAttributes(a)
require.NoError(t, object.SetIDWithSignature(&ownerKey.PrivateKey, obj.SDK()))
require.NoError(t, object.SetIDWithSignature(&ownerKey.PrivateKey, obj))
return obj.Object()
return obj
}
t.Run("invalid attribute value", func(t *testing.T) {
@ -228,12 +228,12 @@ func TestFormatValidator_Validate(t *testing.T) {
obj.SetAttributes(a1, a2)
err := v.checkAttributes(obj.Object())
err := v.checkAttributes(obj)
require.NoError(t, err)
a2.SetKey(a1.Key())
err = v.checkAttributes(obj.Object())
err = v.checkAttributes(obj)
require.Equal(t, errDuplAttr, err)
})
@ -245,7 +245,7 @@ func TestFormatValidator_Validate(t *testing.T) {
obj.SetAttributes(a)
err := v.checkAttributes(obj.Object())
err := v.checkAttributes(obj)
require.Equal(t, errEmptyAttrVal, err)
})
})

View file

@ -1,70 +1,18 @@
package object
import (
objectV2 "github.com/nspcc-dev/neofs-api-go/v2/object"
"github.com/nspcc-dev/neofs-api-go/v2/refs"
"github.com/nspcc-dev/neofs-sdk-go/object"
addressSDK "github.com/nspcc-dev/neofs-sdk-go/object/address"
)
// Object represents the NeoFS object.
//
// Object inherits object type from NeoFS SDK.
// It is used to implement some useful methods and functions
// for convenient processing of an object by a node.
type Object struct {
*object.Object
}
// AddressOf returns address of the object.
func AddressOf(obj *object.Object) *addressSDK.Address {
if obj != nil {
addr := addressSDK.NewAddress()
addr.SetObjectID(obj.ID())
addr.SetContainerID(obj.ContainerID())
// Address returns address of the object.
func (o *Object) Address() *addressSDK.Address {
if o != nil {
aV2 := new(refs.Address)
aV2.SetObjectID(o.ID().ToV2())
aV2.SetContainerID(o.ContainerID().ToV2())
return addressSDK.NewAddressFromV2(aV2)
}
return nil
}
// SDK returns NeoFS SDK object instance.
func (o *Object) SDK() *object.Object {
if o != nil {
return o.Object
}
return nil
}
// NewFromV2 constructs Object instance from v2 Object message.
func NewFromV2(obj *objectV2.Object) *Object {
return &Object{
Object: object.NewFromV2(obj),
}
}
// NewFromSDK constructs Object instance from NeoFS SDK Object.
func NewFromSDK(obj *object.Object) *Object {
return &Object{
Object: obj,
}
}
// New constructs blank Object instance.
func New() *Object {
return NewFromSDK(object.New())
}
// GetParent returns parent object.
func (o *Object) GetParent() *Object {
if o != nil {
if par := o.Object.Parent(); par != nil {
return &Object{
Object: par,
}
}
return addr
}
return nil

View file

@ -1,72 +0,0 @@
package object
import (
objectV2 "github.com/nspcc-dev/neofs-api-go/v2/object"
"github.com/nspcc-dev/neofs-sdk-go/object"
)
// RawObject represents the raw NeoFS object.
//
// RawObject inherits RawObject type from NeoFS SDK.
// It is used to implement some useful methods and functions
// for convenient processing of a raw object by a node.
type RawObject struct {
*object.RawObject
}
// NewRawFromV2 constructs RawObject instance from v2 Object message.
func NewRawFromV2(obj *objectV2.Object) *RawObject {
return &RawObject{
RawObject: object.NewRawFromV2(obj),
}
}
// NewRawFrom constructs RawObject instance from NeoFS SDK RawObject.
func NewRawFrom(obj *object.RawObject) *RawObject {
return &RawObject{
RawObject: obj,
}
}
// NewRawFromObject wraps Object instance to RawObject.
func NewRawFromObject(obj *Object) *RawObject {
return NewRawFrom(object.NewRawFrom(obj.SDK()))
}
// NewRaw constructs blank RawObject instance.
func NewRaw() *RawObject {
return NewRawFrom(object.NewRaw())
}
// SDK converts RawObject to NeoFS SDK RawObject instance.
func (o *RawObject) SDK() *object.RawObject {
if o != nil {
return o.RawObject
}
return nil
}
// Object converts RawObject to read-only Object instance.
func (o *RawObject) Object() *Object {
if o != nil {
return &Object{
Object: o.RawObject.Object(),
}
}
return nil
}
// CutPayload returns RawObject w/ empty payload.
//
// Changes of non-payload fields affect source object.
func (o *RawObject) CutPayload() *RawObject {
if o != nil {
return &RawObject{
RawObject: o.RawObject.CutPayload(),
}
}
return nil
}

View file

@ -160,7 +160,7 @@ func (x Client) GetObject(prm GetObjectPrm) (*GetObjectRes, error) {
return nil, fmt.Errorf("read payload: %w", err)
}
object.NewRawFrom(&obj).SetPayload(buf)
obj.SetPayload(buf)
return &GetObjectRes{
obj: &obj,

View file

@ -13,6 +13,7 @@ import (
"github.com/nspcc-dev/neofs-node/pkg/core/object"
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/blobovnicza"
storagelog "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/internal/log"
objectSDK "github.com/nspcc-dev/neofs-sdk-go/object"
addressSDK "github.com/nspcc-dev/neofs-sdk-go/object/address"
"go.uber.org/zap"
)
@ -572,7 +573,7 @@ func (b *blobovniczas) getObject(blz *blobovnicza.Blobovnicza, prm *blobovnicza.
}
// unmarshal the object
obj := object.New()
obj := objectSDK.New()
if err := obj.Unmarshal(data); err != nil {
return nil, fmt.Errorf("could not unmarshal the object: %w", err)
}
@ -605,7 +606,7 @@ func (b *blobovniczas) getObjectRange(blz *blobovnicza.Blobovnicza, prm *GetRang
}
// unmarshal the object
obj := object.New()
obj := objectSDK.New()
if err := obj.Unmarshal(data); err != nil {
return nil, fmt.Errorf("could not unmarshal the object: %w", err)
}

View file

@ -33,8 +33,8 @@ func testAddress() *addressSDK.Address {
return addr
}
func testObjectRaw(sz uint64) *object.RawObject {
raw := object.NewRaw()
func testObject(sz uint64) *objectSDK.Object {
raw := objectSDK.New()
addr := testAddress()
raw.SetID(addr.ObjectID())
@ -51,10 +51,6 @@ func testObjectRaw(sz uint64) *object.RawObject {
return raw
}
func testObject(sz uint64) *object.Object {
return testObjectRaw(sz).Object()
}
func TestBlobovniczas(t *testing.T) {
rand.Seed(1024)
@ -91,19 +87,21 @@ func TestBlobovniczas(t *testing.T) {
for i := uint64(0); i < minFitObjNum; i++ {
obj := testObject(objSz)
addrList = append(addrList, obj.Address())
addr := object.AddressOf(obj)
addrList = append(addrList, addr)
d, err := obj.Marshal()
require.NoError(t, err)
// save object in blobovnicza
id, err := b.put(obj.Address(), d)
id, err := b.put(addr, d)
require.NoError(t, err)
// get w/ blobovnicza ID
prm := new(GetSmallPrm)
prm.SetBlobovniczaID(id)
prm.SetAddress(obj.Address())
prm.SetAddress(addr)
res, err := b.get(prm)
require.NoError(t, err)
@ -119,7 +117,7 @@ func TestBlobovniczas(t *testing.T) {
// get range w/ blobovnicza ID
rngPrm := new(GetRangeSmallPrm)
rngPrm.SetBlobovniczaID(id)
rngPrm.SetAddress(obj.Address())
rngPrm.SetAddress(addr)
payload := obj.Payload()
pSize := uint64(len(obj.Payload()))

View file

@ -29,19 +29,19 @@ func TestCompression(t *testing.T) {
return bs
}
bigObj := make([]*object.Object, objCount)
smallObj := make([]*object.Object, objCount)
bigObj := make([]*objectSDK.Object, objCount)
smallObj := make([]*objectSDK.Object, objCount)
for i := 0; i < objCount; i++ {
bigObj[i] = testObject(smallSizeLimit * 2)
smallObj[i] = testObject(smallSizeLimit / 2)
}
testGet := func(t *testing.T, b *BlobStor, i int) {
res1, err := b.GetSmall(&GetSmallPrm{address: address{smallObj[i].Address()}})
res1, err := b.GetSmall(&GetSmallPrm{address: address{object.AddressOf(smallObj[i])}})
require.NoError(t, err)
require.Equal(t, smallObj[i], res1.Object())
res2, err := b.GetBig(&GetBigPrm{address: address{bigObj[i].Address()}})
res2, err := b.GetBig(&GetBigPrm{address: address{object.AddressOf(bigObj[i])}})
require.NoError(t, err)
require.Equal(t, bigObj[i], res2.Object())
}
@ -95,15 +95,15 @@ func TestBlobstor_needsCompression(t *testing.T) {
return bs
}
newObjectWithCt := func(contentType string) *object.Object {
obj := testObjectRaw(smallSizeLimit + 1)
newObjectWithCt := func(contentType string) *objectSDK.Object {
obj := testObject(smallSizeLimit + 1)
if contentType != "" {
a := objectSDK.NewAttribute()
a.SetKey(objectSDK.AttributeContentType)
a.SetValue(contentType)
obj.SetAttributes(a)
}
return obj.Object()
return obj
}
t.Run("content-types specified", func(t *testing.T) {

View file

@ -6,6 +6,7 @@ import (
"github.com/nspcc-dev/neofs-node/pkg/core/object"
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/blobstor/fstree"
objectSDK "github.com/nspcc-dev/neofs-sdk-go/object"
)
// GetBigPrm groups the parameters of GetBig operation.
@ -42,7 +43,7 @@ func (b *BlobStor) GetBig(prm *GetBigPrm) (*GetBigRes, error) {
}
// unmarshal the object
obj := object.New()
obj := objectSDK.New()
if err := obj.Unmarshal(data); err != nil {
return nil, fmt.Errorf("could not unmarshal the object: %w", err)
}

View file

@ -6,6 +6,7 @@ import (
"github.com/nspcc-dev/neofs-node/pkg/core/object"
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/blobstor/fstree"
objectSDK "github.com/nspcc-dev/neofs-sdk-go/object"
)
// GetRangeBigPrm groups the parameters of GetRangeBig operation.
@ -42,7 +43,7 @@ func (b *BlobStor) GetRangeBig(prm *GetRangeBigPrm) (*GetRangeBigRes, error) {
}
// unmarshal the object
obj := object.New()
obj := objectSDK.New()
if err := obj.Unmarshal(data); err != nil {
return nil, fmt.Errorf("could not unmarshal the object: %w", err)
}

View file

@ -3,9 +3,9 @@ package blobstor
import (
"fmt"
"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/fstree"
"github.com/nspcc-dev/neofs-sdk-go/object"
addressSDK "github.com/nspcc-dev/neofs-sdk-go/object/address"
)

View file

@ -10,8 +10,8 @@ import (
"testing"
"github.com/klauspost/compress/zstd"
"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-sdk-go/object"
addressSDK "github.com/nspcc-dev/neofs-sdk-go/object/address"
objecttest "github.com/nspcc-dev/neofs-sdk-go/object/address/test"
"github.com/stretchr/testify/require"
@ -117,7 +117,7 @@ func TestIterate_IgnoreErrors(t *testing.T) {
addrs := make([]*addressSDK.Address, objCount)
for i := range addrs {
addrs[i] = objecttest.Address()
obj := object.NewRaw()
obj := object.New()
obj.SetContainerID(addrs[i].ContainerID())
obj.SetID(addrs[i].ObjectID())
obj.SetPayload(make([]byte, smallSize<<(i%2)))

View file

@ -35,14 +35,14 @@ func (b *BlobStor) Put(prm *PutPrm) (*PutRes, error) {
return nil, fmt.Errorf("could not marshal the object: %w", err)
}
return b.PutRaw(prm.obj.Address(), data, b.NeedsCompression(prm.obj))
return b.PutRaw(object.AddressOf(prm.obj), data, b.NeedsCompression(prm.obj))
}
// NeedsCompression returns true if object should be compressed.
// For object to be compressed 2 conditions must hold:
// 1. Compression is enabled in settings.
// 2. Object MIME Content-Type is allowed for compression.
func (b *BlobStor) NeedsCompression(obj *object.Object) bool {
func (b *BlobStor) NeedsCompression(obj *objectSDK.Object) bool {
if !b.compressionEnabled || len(b.uncompressableContentTypes) == 0 {
return b.compressionEnabled
}

View file

@ -1,9 +1,8 @@
package blobstor
import (
"github.com/nspcc-dev/neofs-node/pkg/core/object"
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/blobovnicza"
objectSDK "github.com/nspcc-dev/neofs-sdk-go/object"
"github.com/nspcc-dev/neofs-sdk-go/object"
addressSDK "github.com/nspcc-dev/neofs-sdk-go/object/address"
)
@ -53,11 +52,11 @@ func (v *rwBlobovniczaID) SetBlobovniczaID(id *blobovnicza.ID) {
}
type roRange struct {
rng *objectSDK.Range
rng *object.Range
}
// Range returns range of the object payload.
func (r roRange) Range() *objectSDK.Range {
func (r roRange) Range() *object.Range {
return r.rng
}
@ -66,7 +65,7 @@ type rwRange struct {
}
// SetRange sets range of the object payload.
func (r *rwRange) SetRange(rng *objectSDK.Range) {
func (r *rwRange) SetRange(rng *object.Range) {
r.rng = rng
}

View file

@ -6,6 +6,7 @@ import (
"path/filepath"
"testing"
"github.com/nspcc-dev/neofs-node/pkg/core/object"
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/shard"
cidtest "github.com/nspcc-dev/neofs-sdk-go/container/id/test"
"github.com/stretchr/testify/require"
@ -19,9 +20,9 @@ func TestExecBlocks(t *testing.T) {
})
// put some object
obj := generateRawObjectWithCID(t, cidtest.ID()).Object()
obj := generateObjectWithCID(t, cidtest.ID())
addr := obj.Address()
addr := object.AddressOf(obj)
require.NoError(t, Put(e, obj))

View file

@ -9,7 +9,6 @@ import (
"sync"
"testing"
"github.com/nspcc-dev/neofs-node/pkg/core/object"
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/blobstor"
meta "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/metabase"
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/shard"
@ -18,7 +17,7 @@ import (
"github.com/nspcc-dev/neofs-sdk-go/checksum"
cid "github.com/nspcc-dev/neofs-sdk-go/container/id"
cidtest "github.com/nspcc-dev/neofs-sdk-go/container/id/test"
objectSDK "github.com/nspcc-dev/neofs-sdk-go/object"
"github.com/nspcc-dev/neofs-sdk-go/object"
objecttest "github.com/nspcc-dev/neofs-sdk-go/object/address/test"
oidSDK "github.com/nspcc-dev/neofs-sdk-go/object/id"
"github.com/nspcc-dev/neofs-sdk-go/owner"
@ -57,7 +56,7 @@ func benchmarkExists(b *testing.B, shardNum int) {
addr := objecttest.Address()
for i := 0; i < 100; i++ {
obj := generateRawObjectWithCID(b, cidtest.ID())
obj := generateObjectWithCID(b, cidtest.ID())
err := Put(e, obj.Object())
if err != nil {
b.Fatal(err)
@ -134,7 +133,7 @@ func testOID() *oidSDK.ID {
return id
}
func generateRawObjectWithCID(t testing.TB, cid *cid.ID) *object.RawObject {
func generateObjectWithCID(t testing.TB, cid *cid.ID) *object.RawObject {
version := version.New()
version.SetMajor(2)
version.SetMinor(1)
@ -145,7 +144,7 @@ func generateRawObjectWithCID(t testing.TB, cid *cid.ID) *object.RawObject {
csumTZ := new(checksum.Checksum)
csumTZ.SetTillichZemor(tz.Sum(csum.Sum()))
obj := object.NewRaw()
obj := object.New()
obj.SetID(testOID())
obj.SetOwnerID(ownertest.ID())
obj.SetContainerID(cid)
@ -157,8 +156,8 @@ func generateRawObjectWithCID(t testing.TB, cid *cid.ID) *object.RawObject {
return obj
}
func addAttribute(obj *object.RawObject, key, val string) {
attr := objectSDK.NewAttribute()
func addAttribute(obj *object.Object, key, val string) {
attr := object.NewAttribute()
attr.SetKey(key)
attr.SetValue(val)

View file

@ -13,6 +13,7 @@ import (
meta "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/metabase"
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/shard"
cidtest "github.com/nspcc-dev/neofs-sdk-go/container/id/test"
objectSDK "github.com/nspcc-dev/neofs-sdk-go/object"
"github.com/stretchr/testify/require"
"go.uber.org/zap/zaptest"
)
@ -61,16 +62,16 @@ func TestErrorReporting(t *testing.T) {
t.Run("ignore errors by default", func(t *testing.T) {
e, dir, id := newEngineWithErrorThreshold(t, "", 0)
obj := generateRawObjectWithCID(t, cidtest.ID())
obj := generateObjectWithCID(t, cidtest.ID())
obj.SetPayload(make([]byte, errSmallSize))
prm := new(shard.PutPrm).WithObject(obj.Object())
prm := new(shard.PutPrm).WithObject(obj)
e.mtx.RLock()
_, err := e.shards[id[0].String()].Shard.Put(prm)
e.mtx.RUnlock()
require.NoError(t, err)
_, err = e.Get(&GetPrm{addr: obj.Object().Address()})
_, err = e.Get(&GetPrm{addr: object.AddressOf(obj)})
require.NoError(t, err)
checkShardState(t, e, id[0], 0, shard.ModeReadWrite)
@ -79,7 +80,7 @@ func TestErrorReporting(t *testing.T) {
corruptSubDir(t, filepath.Join(dir, "0"))
for i := uint32(1); i < 3; i++ {
_, err = e.Get(&GetPrm{addr: obj.Object().Address()})
_, err = e.Get(&GetPrm{addr: object.AddressOf(obj)})
require.Error(t, err)
checkShardState(t, e, id[0], i, shard.ModeReadWrite)
checkShardState(t, e, id[1], 0, shard.ModeReadWrite)
@ -90,16 +91,16 @@ func TestErrorReporting(t *testing.T) {
e, dir, id := newEngineWithErrorThreshold(t, "", errThreshold)
obj := generateRawObjectWithCID(t, cidtest.ID())
obj := generateObjectWithCID(t, cidtest.ID())
obj.SetPayload(make([]byte, errSmallSize))
prm := new(shard.PutPrm).WithObject(obj.Object())
prm := new(shard.PutPrm).WithObject(obj)
e.mtx.RLock()
_, err := e.shards[id[0].String()].Put(prm)
e.mtx.RUnlock()
require.NoError(t, err)
_, err = e.Get(&GetPrm{addr: obj.Object().Address()})
_, err = e.Get(&GetPrm{addr: object.AddressOf(obj)})
require.NoError(t, err)
checkShardState(t, e, id[0], 0, shard.ModeReadWrite)
@ -108,14 +109,14 @@ func TestErrorReporting(t *testing.T) {
corruptSubDir(t, filepath.Join(dir, "0"))
for i := uint32(1); i < errThreshold; i++ {
_, err = e.Get(&GetPrm{addr: obj.Object().Address()})
_, err = e.Get(&GetPrm{addr: object.AddressOf(obj)})
require.Error(t, err)
checkShardState(t, e, id[0], i, shard.ModeReadWrite)
checkShardState(t, e, id[1], 0, shard.ModeReadWrite)
}
for i := uint32(0); i < 2; i++ {
_, err = e.Get(&GetPrm{addr: obj.Object().Address()})
_, err = e.Get(&GetPrm{addr: object.AddressOf(obj)})
require.Error(t, err)
checkShardState(t, e, id[0], errThreshold+i, shard.ModeReadOnly)
checkShardState(t, e, id[1], 0, shard.ModeReadWrite)
@ -137,9 +138,9 @@ func TestBlobstorFailback(t *testing.T) {
e, _, id := newEngineWithErrorThreshold(t, dir, 1)
objs := make([]*object.Object, 0, 2)
objs := make([]*objectSDK.Object, 0, 2)
for _, size := range []int{15, errSmallSize + 1} {
obj := generateRawObjectWithCID(t, cidtest.ID())
obj := generateObjectWithCID(t, cidtest.ID())
obj.SetPayload(make([]byte, size))
prm := new(shard.PutPrm).WithObject(obj.Object())
@ -151,9 +152,10 @@ func TestBlobstorFailback(t *testing.T) {
}
for i := range objs {
_, err = e.Get(&GetPrm{addr: objs[i].Address()})
addr := object.AddressOf(objs[i])
_, err = e.Get(&GetPrm{addr: addr})
require.NoError(t, err)
_, err = e.GetRange(&RngPrm{addr: objs[i].Address()})
_, err = e.GetRange(&RngPrm{addr: addr})
require.NoError(t, err)
}
@ -170,15 +172,16 @@ func TestBlobstorFailback(t *testing.T) {
e, _, id = newEngineWithErrorThreshold(t, dir, 1)
for i := range objs {
getRes, err := e.Get(&GetPrm{addr: objs[i].Address()})
addr := object.AddressOf(objs[i])
getRes, err := e.Get(&GetPrm{addr: addr})
require.NoError(t, err)
require.Equal(t, objs[i], getRes.Object())
rngRes, err := e.GetRange(&RngPrm{addr: objs[i].Address(), off: 1, ln: 10})
rngRes, err := e.GetRange(&RngPrm{addr: addr, off: 1, ln: 10})
require.NoError(t, err)
require.Equal(t, objs[i].Payload()[1:11], rngRes.Object().Payload())
_, err = e.GetRange(&RngPrm{addr: objs[i].Address(), off: errSmallSize + 10, ln: 1})
_, err = e.GetRange(&RngPrm{addr: addr, off: errSmallSize + 10, ln: 1})
require.True(t, errors.Is(err, object.ErrRangeOutOfBounds), "got: %v", err)
}

View file

@ -18,7 +18,7 @@ type GetPrm struct {
// GetRes groups resulting values of Get operation.
type GetRes struct {
obj *object.Object
obj *objectSDK.Object
}
// WithAddress is a Get option to set the address of the requested object.
@ -33,7 +33,7 @@ func (p *GetPrm) WithAddress(addr *addressSDK.Address) *GetPrm {
}
// Object returns the requested object.
func (r *GetRes) Object() *object.Object {
func (r *GetRes) Object() *objectSDK.Object {
return r.obj
}
@ -60,7 +60,7 @@ func (e *StorageEngine) get(prm *GetPrm) (*GetRes, error) {
}
var (
obj *object.Object
obj *objectSDK.Object
siErr *objectSDK.SplitInfoError
outSI *objectSDK.SplitInfo
@ -145,7 +145,7 @@ func (e *StorageEngine) get(prm *GetPrm) (*GetRes, error) {
}
// Get reads object from local storage by provided address.
func Get(storage *StorageEngine, addr *addressSDK.Address) (*object.Object, error) {
func Get(storage *StorageEngine, addr *addressSDK.Address) (*objectSDK.Object, error) {
res, err := storage.Get(new(GetPrm).
WithAddress(addr),
)

View file

@ -18,7 +18,7 @@ type HeadPrm struct {
// HeadRes groups resulting values of Head operation.
type HeadRes struct {
head *object.Object
head *objectSDK.Object
}
// WithAddress is a Head option to set the address of the requested object.
@ -46,7 +46,7 @@ func (p *HeadPrm) WithRaw(raw bool) *HeadPrm {
// Header returns the requested object header.
//
// Instance has empty payload.
func (r *HeadRes) Header() *object.Object {
func (r *HeadRes) Header() *objectSDK.Object {
return r.head
}
@ -74,7 +74,7 @@ func (e *StorageEngine) head(prm *HeadPrm) (*HeadRes, error) {
}
var (
head *object.Object
head *objectSDK.Object
siErr *objectSDK.SplitInfoError
outSI *objectSDK.SplitInfo
@ -135,7 +135,7 @@ func (e *StorageEngine) head(prm *HeadPrm) (*HeadRes, error) {
}
// Head reads object header from local storage by provided address.
func Head(storage *StorageEngine, addr *addressSDK.Address) (*object.Object, error) {
func Head(storage *StorageEngine, addr *addressSDK.Address) (*objectSDK.Object, error) {
res, err := storage.Head(new(HeadPrm).
WithAddress(addr),
)
@ -148,7 +148,7 @@ func Head(storage *StorageEngine, addr *addressSDK.Address) (*object.Object, err
// HeadRaw reads object header from local storage by provided address and raw
// flag.
func HeadRaw(storage *StorageEngine, addr *addressSDK.Address, raw bool) (*object.Object, error) {
func HeadRaw(storage *StorageEngine, addr *addressSDK.Address, raw bool) (*objectSDK.Object, error) {
res, err := storage.Head(new(HeadPrm).
WithAddress(addr).
WithRaw(raw),

View file

@ -6,7 +6,7 @@ import (
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/shard"
cidtest "github.com/nspcc-dev/neofs-sdk-go/container/id/test"
objectSDK "github.com/nspcc-dev/neofs-sdk-go/object"
"github.com/nspcc-dev/neofs-sdk-go/object"
addressSDK "github.com/nspcc-dev/neofs-sdk-go/object/address"
"github.com/stretchr/testify/require"
)
@ -15,22 +15,22 @@ func TestHeadRaw(t *testing.T) {
defer os.RemoveAll(t.Name())
cid := cidtest.ID()
splitID := objectSDK.NewSplitID()
splitID := object.NewSplitID()
parent := generateRawObjectWithCID(t, cid)
parent := generateObjectWithCID(t, cid)
addAttribute(parent, "foo", "bar")
parentAddr := addressSDK.NewAddress()
parentAddr.SetContainerID(cid)
parentAddr.SetObjectID(parent.ID())
child := generateRawObjectWithCID(t, cid)
child.SetParent(parent.Object().SDK())
child := generateObjectWithCID(t, cid)
child.SetParent(parent)
child.SetParentID(parent.ID())
child.SetSplitID(splitID)
link := generateRawObjectWithCID(t, cid)
link.SetParent(parent.Object().SDK())
link := generateObjectWithCID(t, cid)
link.SetParent(parent)
link.SetParentID(parent.ID())
link.SetChildren(child.ID())
link.SetSplitID(splitID)
@ -42,8 +42,8 @@ func TestHeadRaw(t *testing.T) {
e := testNewEngineWithShards(s1, s2)
defer e.Close()
putPrmLeft := new(shard.PutPrm).WithObject(child.Object())
putPrmLink := new(shard.PutPrm).WithObject(link.Object())
putPrmLeft := new(shard.PutPrm).WithObject(child)
putPrmLink := new(shard.PutPrm).WithObject(link)
// put most left object in one shard
_, err := s1.Put(putPrmLeft)
@ -58,7 +58,7 @@ func TestHeadRaw(t *testing.T) {
_, err = e.Head(headPrm)
require.Error(t, err)
si, ok := err.(*objectSDK.SplitInfoError)
si, ok := err.(*object.SplitInfoError)
require.True(t, ok)
// SplitInfoError should contain info from both shards

View file

@ -4,6 +4,7 @@ import (
"os"
"testing"
"github.com/nspcc-dev/neofs-node/pkg/core/object"
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/shard"
cidtest "github.com/nspcc-dev/neofs-sdk-go/container/id/test"
objectSDK "github.com/nspcc-dev/neofs-sdk-go/object"
@ -19,16 +20,16 @@ func TestStorageEngine_Inhume(t *testing.T) {
fs := objectSDK.SearchFilters{}
fs.AddRootFilter()
tombstoneID := generateRawObjectWithCID(t, cid).Object().Address()
parent := generateRawObjectWithCID(t, cid)
tombstoneID := object.AddressOf(generateObjectWithCID(t, cid))
parent := generateObjectWithCID(t, cid)
child := generateRawObjectWithCID(t, cid)
child.SetParent(parent.Object().SDK())
child := generateObjectWithCID(t, cid)
child.SetParent(parent)
child.SetParentID(parent.ID())
child.SetSplitID(splitID)
link := generateRawObjectWithCID(t, cid)
link.SetParent(parent.Object().SDK())
link := generateObjectWithCID(t, cid)
link.SetParent(parent)
link.SetParentID(parent.ID())
link.SetChildren(child.ID())
link.SetSplitID(splitID)
@ -37,10 +38,10 @@ func TestStorageEngine_Inhume(t *testing.T) {
e := testNewEngineWithShardNum(t, 1)
defer e.Close()
err := Put(e, parent.Object())
err := Put(e, parent)
require.NoError(t, err)
inhumePrm := new(InhumePrm).WithTarget(tombstoneID, parent.Object().Address())
inhumePrm := new(InhumePrm).WithTarget(tombstoneID, object.AddressOf(parent))
_, err = e.Inhume(inhumePrm)
require.NoError(t, err)
@ -56,15 +57,15 @@ func TestStorageEngine_Inhume(t *testing.T) {
e := testNewEngineWithShards(s1, s2)
defer e.Close()
putChild := new(shard.PutPrm).WithObject(child.Object())
putChild := new(shard.PutPrm).WithObject(child)
_, err := s1.Put(putChild)
require.NoError(t, err)
putLink := new(shard.PutPrm).WithObject(link.Object())
putLink := new(shard.PutPrm).WithObject(link)
_, err = s2.Put(putLink)
require.NoError(t, err)
inhumePrm := new(InhumePrm).WithTarget(tombstoneID, parent.Object().Address())
inhumePrm := new(InhumePrm).WithTarget(tombstoneID, object.AddressOf(parent))
_, err = e.Inhume(inhumePrm)
require.NoError(t, err)

View file

@ -6,6 +6,7 @@ import (
"sort"
"testing"
"github.com/nspcc-dev/neofs-node/pkg/core/object"
cidtest "github.com/nspcc-dev/neofs-sdk-go/container/id/test"
addressSDK "github.com/nspcc-dev/neofs-sdk-go/object/address"
"github.com/stretchr/testify/require"
@ -28,11 +29,11 @@ func TestListWithCursor(t *testing.T) {
for i := 0; i < total; i++ {
containerID := cidtest.ID()
obj := generateRawObjectWithCID(t, containerID)
prm := new(PutPrm).WithObject(obj.Object())
obj := generateObjectWithCID(t, containerID)
prm := new(PutPrm).WithObject(obj)
_, err := e.Put(prm)
require.NoError(t, err)
expected = append(expected, obj.Object().Address())
expected = append(expected, object.AddressOf(obj))
}
expected = sortAddresses(expected)

View file

@ -5,12 +5,13 @@ import (
"github.com/nspcc-dev/neofs-node/pkg/core/object"
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/shard"
objectSDK "github.com/nspcc-dev/neofs-sdk-go/object"
"go.uber.org/zap"
)
// PutPrm groups the parameters of Put operation.
type PutPrm struct {
obj *object.Object
obj *objectSDK.Object
}
// PutRes groups resulting values of Put operation.
@ -21,7 +22,7 @@ var errPutShard = errors.New("could not put object to any shard")
// WithObject is a Put option to set object to save.
//
// Option is required.
func (p *PutPrm) WithObject(obj *object.Object) *PutPrm {
func (p *PutPrm) WithObject(obj *objectSDK.Object) *PutPrm {
if p != nil {
p.obj = obj
}
@ -49,19 +50,21 @@ func (e *StorageEngine) put(prm *PutPrm) (*PutRes, error) {
defer elapsed(e.metrics.AddPutDuration)()
}
addr := object.AddressOf(prm.obj)
// In #1146 this check was parallelized, however, it became
// much slower on fast machines for 4 shards.
_, err := e.exists(prm.obj.Address())
_, err := e.exists(addr)
if err != nil {
return nil, err
}
existPrm := new(shard.ExistsPrm)
existPrm.WithAddress(prm.obj.Address())
existPrm.WithAddress(addr)
finished := false
e.iterateOverSortedShards(prm.obj.Address(), func(ind int, sh hashedShard) (stop bool) {
e.iterateOverSortedShards(addr, func(ind int, sh hashedShard) (stop bool) {
e.mtx.RLock()
pool := e.shardPools[sh.ID().String()]
e.mtx.RUnlock()
@ -79,7 +82,7 @@ func (e *StorageEngine) put(prm *PutPrm) (*PutRes, error) {
if exists.Exists() {
if ind != 0 {
toMoveItPrm := new(shard.ToMoveItPrm)
toMoveItPrm.WithAddress(prm.obj.Address())
toMoveItPrm.WithAddress(addr)
_, err = sh.ToMoveIt(toMoveItPrm)
if err != nil {
@ -126,7 +129,7 @@ func (e *StorageEngine) put(prm *PutPrm) (*PutRes, error) {
}
// Put writes provided object to local storage.
func Put(storage *StorageEngine, obj *object.Object) error {
func Put(storage *StorageEngine, obj *objectSDK.Object) error {
_, err := storage.Put(new(PutPrm).
WithObject(obj),
)

View file

@ -20,7 +20,7 @@ type RngPrm struct {
// RngRes groups resulting values of GetRange operation.
type RngRes struct {
obj *object.Object
obj *objectSDK.Object
}
// WithAddress is a GetRng option to set the address of the requested object.
@ -49,7 +49,7 @@ func (p *RngPrm) WithPayloadRange(rng *objectSDK.Range) *RngPrm {
// Object returns the requested object part.
//
// Instance payload contains the requested range of the original object.
func (r *RngRes) Object() *object.Object {
func (r *RngRes) Object() *objectSDK.Object {
return r.obj
}
@ -78,7 +78,7 @@ func (e *StorageEngine) getRange(prm *RngPrm) (*RngRes, error) {
}
var (
obj *object.Object
obj *objectSDK.Object
siErr *objectSDK.SplitInfoError
outSI *objectSDK.SplitInfo

View file

@ -21,11 +21,11 @@ func TestDB_Containers(t *testing.T) {
cids := make(map[string]int, N)
for i := 0; i < N; i++ {
obj := generateRawObject(t)
obj := generateObject(t)
cids[obj.ContainerID().String()] = 0
err := putBig(db, obj.Object())
err := putBig(db, obj)
require.NoError(t, err)
}
@ -41,7 +41,7 @@ func TestDB_Containers(t *testing.T) {
}
t.Run("Inhume", func(t *testing.T) {
obj := generateRawObject(t).Object()
obj := generateObject(t)
require.NoError(t, putBig(db, obj))
@ -49,7 +49,7 @@ func TestDB_Containers(t *testing.T) {
require.NoError(t, err)
require.Contains(t, cnrs, obj.ContainerID())
require.NoError(t, meta.Inhume(db, obj.Address(), generateAddress()))
require.NoError(t, meta.Inhume(db, object.AddressOf(obj), generateAddress()))
cnrs, err = db.Containers()
require.NoError(t, err)
@ -57,7 +57,7 @@ func TestDB_Containers(t *testing.T) {
})
t.Run("ToMoveIt", func(t *testing.T) {
obj := generateRawObject(t).Object()
obj := generateObject(t)
require.NoError(t, putBig(db, obj))
@ -65,7 +65,7 @@ func TestDB_Containers(t *testing.T) {
require.NoError(t, err)
require.Contains(t, cnrs, obj.ContainerID())
require.NoError(t, meta.ToMoveIt(db, obj.Address()))
require.NoError(t, meta.ToMoveIt(db, object.AddressOf(obj)))
cnrs, err = db.Containers()
require.NoError(t, err)
@ -91,10 +91,10 @@ func TestDB_ContainersCount(t *testing.T) {
for _, upload := range uploadObjects {
for i := 0; i < upload.amount; i++ {
obj := generateRawObject(t)
obj := generateObject(t)
obj.SetType(upload.typ)
err := putBig(db, obj.Object())
err := putBig(db, obj)
require.NoError(t, err)
expected = append(expected, obj.ContainerID())
@ -124,7 +124,7 @@ func TestDB_ContainerSize(t *testing.T) {
)
cids := make(map[*cid.ID]int, C)
objs := make(map[*cid.ID][]*object.RawObject, C*N)
objs := make(map[*cid.ID][]*objectSDK.Object, C*N)
for i := 0; i < C; i++ {
cid := cidtest.ID()
@ -133,18 +133,18 @@ func TestDB_ContainerSize(t *testing.T) {
for j := 0; j < N; j++ {
size := rand.Intn(1024)
parent := generateRawObjectWithCID(t, cid)
parent := generateObjectWithCID(t, cid)
parent.SetPayloadSize(uint64(size / 2))
obj := generateRawObjectWithCID(t, cid)
obj := generateObjectWithCID(t, cid)
obj.SetPayloadSize(uint64(size))
obj.SetParentID(parent.ID())
obj.SetParent(parent.Object().SDK())
obj.SetParent(parent)
cids[cid] += size
objs[cid] = append(objs[cid], obj)
err := putBig(db, obj.Object())
err := putBig(db, obj)
require.NoError(t, err)
}
}
@ -162,7 +162,7 @@ func TestDB_ContainerSize(t *testing.T) {
for _, obj := range list {
require.NoError(t, meta.Inhume(
db,
obj.Object().Address(),
object.AddressOf(obj),
generateAddress(),
))

View file

@ -15,8 +15,8 @@ func TestReset(t *testing.T) {
err := db.Reset()
require.NoError(t, err)
obj := generateRawObject(t).Object()
addr := obj.Address()
obj := generateObject(t)
addr := object.AddressOf(obj)
addrToInhume := generateAddress()

View file

@ -6,13 +6,12 @@ import (
"os"
"testing"
"github.com/nspcc-dev/neofs-node/pkg/core/object"
meta "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/metabase"
"github.com/nspcc-dev/neofs-node/pkg/util/test"
"github.com/nspcc-dev/neofs-sdk-go/checksum"
cid "github.com/nspcc-dev/neofs-sdk-go/container/id"
cidtest "github.com/nspcc-dev/neofs-sdk-go/container/id/test"
objectSDK "github.com/nspcc-dev/neofs-sdk-go/object"
"github.com/nspcc-dev/neofs-sdk-go/object"
addressSDK "github.com/nspcc-dev/neofs-sdk-go/object/address"
oidSDK "github.com/nspcc-dev/neofs-sdk-go/object/id"
"github.com/nspcc-dev/neofs-sdk-go/owner"
@ -27,7 +26,7 @@ func putBig(db *meta.DB, obj *object.Object) error {
return meta.Put(db, obj, nil)
}
func testSelect(t *testing.T, db *meta.DB, cid *cid.ID, fs objectSDK.SearchFilters, exp ...*addressSDK.Address) {
func testSelect(t *testing.T, db *meta.DB, cid *cid.ID, fs object.SearchFilters, exp ...*addressSDK.Address) {
res, err := meta.Select(db, cid, fs)
require.NoError(t, err)
require.Len(t, res, len(exp))
@ -62,11 +61,11 @@ func newDB(t testing.TB) *meta.DB {
return bdb
}
func generateRawObject(t *testing.T) *object.RawObject {
return generateRawObjectWithCID(t, cidtest.ID())
func generateObject(t *testing.T) *object.Object {
return generateObjectWithCID(t, cidtest.ID())
}
func generateRawObjectWithCID(t *testing.T, cid *cid.ID) *object.RawObject {
func generateObjectWithCID(t *testing.T, cid *cid.ID) *object.Object {
version := version.New()
version.SetMajor(2)
version.SetMinor(1)
@ -77,7 +76,7 @@ func generateRawObjectWithCID(t *testing.T, cid *cid.ID) *object.RawObject {
csumTZ := new(checksum.Checksum)
csumTZ.SetTillichZemor(tz.Sum(csum.Sum()))
obj := object.NewRaw()
obj := object.New()
obj.SetID(testOID())
obj.SetOwnerID(ownertest.ID())
obj.SetContainerID(cid)
@ -97,8 +96,8 @@ func generateAddress() *addressSDK.Address {
return addr
}
func addAttribute(obj *object.RawObject, key, val string) {
attr := objectSDK.NewAttribute()
func addAttribute(obj *object.Object, key, val string) {
attr := object.NewAttribute()
attr.SetKey(key)
attr.SetValue(val)

View file

@ -42,7 +42,7 @@ type referenceNumber struct {
addr *addressSDK.Address
obj *object.Object
obj *objectSDK.Object
}
type referenceCounter map[string]*referenceNumber
@ -105,14 +105,14 @@ func (db *DB) delete(tx *bbolt.Tx, addr *addressSDK.Address, refCounter referenc
}
// if object is an only link to a parent, then remove parent
if parent := obj.GetParent(); parent != nil {
parAddr := parent.Address()
if parent := obj.Parent(); parent != nil {
parAddr := object.AddressOf(parent)
sParAddr := parAddr.String()
nRef, ok := refCounter[sParAddr]
if !ok {
nRef = &referenceNumber{
all: parentLength(tx, parent.Address()),
all: parentLength(tx, parAddr),
addr: parAddr,
obj: parent,
}
@ -129,7 +129,7 @@ func (db *DB) delete(tx *bbolt.Tx, addr *addressSDK.Address, refCounter referenc
func (db *DB) deleteObject(
tx *bbolt.Tx,
obj *object.Object,
obj *objectSDK.Object,
isParent bool,
) error {
uniqueIndexes, err := delUniqueIndexes(obj, isParent)
@ -239,8 +239,8 @@ func delListIndexItem(tx *bbolt.Tx, item namedBucketItem) {
_ = bkt.Put(item.key, encodedLst) // ignore error, best effort there
}
func delUniqueIndexes(obj *object.Object, isParent bool) ([]namedBucketItem, error) {
addr := obj.Address()
func delUniqueIndexes(obj *objectSDK.Object, isParent bool) ([]namedBucketItem, error) {
addr := object.AddressOf(obj)
objKey := objectKey(addr.ObjectID())
addrKey := addressKey(addr)

View file

@ -4,6 +4,7 @@ import (
"errors"
"testing"
"github.com/nspcc-dev/neofs-node/pkg/core/object"
meta "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/metabase"
cidtest "github.com/nspcc-dev/neofs-sdk-go/container/id/test"
objectSDK "github.com/nspcc-dev/neofs-sdk-go/object"
@ -14,19 +15,19 @@ func TestDB_Delete(t *testing.T) {
db := newDB(t)
cid := cidtest.ID()
parent := generateRawObjectWithCID(t, cid)
parent := generateObjectWithCID(t, cid)
addAttribute(parent, "foo", "bar")
child := generateRawObjectWithCID(t, cid)
child.SetParent(parent.Object().SDK())
child := generateObjectWithCID(t, cid)
child.SetParent(parent)
child.SetParentID(parent.ID())
// put object with parent
err := putBig(db, child.Object())
err := putBig(db, child)
require.NoError(t, err)
// fill ToMoveIt index
err = meta.ToMoveIt(db, child.Object().Address())
err = meta.ToMoveIt(db, object.AddressOf(child))
require.NoError(t, err)
// check if Movable list is not empty
@ -35,20 +36,20 @@ func TestDB_Delete(t *testing.T) {
require.Len(t, l, 1)
// try to remove parent unsuccessfully
err = meta.Delete(db, parent.Object().Address())
err = meta.Delete(db, object.AddressOf(parent))
require.Error(t, err)
// inhume parent and child so they will be on graveyard
ts := generateRawObjectWithCID(t, cid)
ts := generateObjectWithCID(t, cid)
err = meta.Inhume(db, child.Object().Address(), ts.Object().Address())
err = meta.Inhume(db, object.AddressOf(child), object.AddressOf(ts))
require.NoError(t, err)
err = meta.Inhume(db, child.Object().Address(), ts.Object().Address())
err = meta.Inhume(db, object.AddressOf(child), object.AddressOf(ts))
require.NoError(t, err)
// delete object
err = meta.Delete(db, child.Object().Address())
err = meta.Delete(db, object.AddressOf(child))
require.NoError(t, err)
// check if there is no data in Movable index
@ -57,11 +58,11 @@ func TestDB_Delete(t *testing.T) {
require.Len(t, l, 0)
// check if they removed from graveyard
ok, err := meta.Exists(db, child.Object().Address())
ok, err := meta.Exists(db, object.AddressOf(child))
require.NoError(t, err)
require.False(t, ok)
ok, err = meta.Exists(db, parent.Object().Address())
ok, err = meta.Exists(db, object.AddressOf(parent))
require.NoError(t, err)
require.False(t, ok)
}
@ -72,32 +73,32 @@ func TestDeleteAllChildren(t *testing.T) {
cid := cidtest.ID()
// generate parent object
parent := generateRawObjectWithCID(t, cid)
parent := generateObjectWithCID(t, cid)
// generate 2 children
child1 := generateRawObjectWithCID(t, cid)
child1.SetParent(parent.Object().SDK())
child1 := generateObjectWithCID(t, cid)
child1.SetParent(parent)
child1.SetParentID(parent.ID())
child2 := generateRawObjectWithCID(t, cid)
child2.SetParent(parent.Object().SDK())
child2 := generateObjectWithCID(t, cid)
child2.SetParent(parent)
child2.SetParentID(parent.ID())
// put children
require.NoError(t, putBig(db, child1.Object()))
require.NoError(t, putBig(db, child2.Object()))
require.NoError(t, putBig(db, child1))
require.NoError(t, putBig(db, child2))
// Exists should return split info for parent
_, err := meta.Exists(db, parent.Object().Address())
_, err := meta.Exists(db, object.AddressOf(parent))
siErr := objectSDK.NewSplitInfoError(nil)
require.True(t, errors.As(err, &siErr))
// remove all children in single call
err = meta.Delete(db, child1.Object().Address(), child2.Object().Address())
err = meta.Delete(db, object.AddressOf(child1), object.AddressOf(child2))
require.NoError(t, err)
// parent should not be found now
ex, err := meta.Exists(db, parent.Object().Address())
ex, err := meta.Exists(db, object.AddressOf(parent))
require.NoError(t, err)
require.False(t, ex)
}

View file

@ -4,6 +4,7 @@ import (
"errors"
"testing"
"github.com/nspcc-dev/neofs-node/pkg/core/object"
meta "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/metabase"
cidtest "github.com/nspcc-dev/neofs-sdk-go/container/id/test"
objectSDK "github.com/nspcc-dev/neofs-sdk-go/object"
@ -14,58 +15,58 @@ func TestDB_Exists(t *testing.T) {
db := newDB(t)
t.Run("no object", func(t *testing.T) {
nonExist := generateRawObject(t)
exists, err := meta.Exists(db, nonExist.Object().Address())
nonExist := generateObject(t)
exists, err := meta.Exists(db, object.AddressOf(nonExist))
require.NoError(t, err)
require.False(t, exists)
})
t.Run("regular object", func(t *testing.T) {
regular := generateRawObject(t)
err := putBig(db, regular.Object())
regular := generateObject(t)
err := putBig(db, regular)
require.NoError(t, err)
exists, err := meta.Exists(db, regular.Object().Address())
exists, err := meta.Exists(db, object.AddressOf(regular))
require.NoError(t, err)
require.True(t, exists)
})
t.Run("tombstone object", func(t *testing.T) {
ts := generateRawObject(t)
ts := generateObject(t)
ts.SetType(objectSDK.TypeTombstone)
err := putBig(db, ts.Object())
err := putBig(db, ts)
require.NoError(t, err)
exists, err := meta.Exists(db, ts.Object().Address())
exists, err := meta.Exists(db, object.AddressOf(ts))
require.NoError(t, err)
require.True(t, exists)
})
t.Run("storage group object", func(t *testing.T) {
sg := generateRawObject(t)
sg := generateObject(t)
sg.SetType(objectSDK.TypeStorageGroup)
err := putBig(db, sg.Object())
err := putBig(db, sg)
require.NoError(t, err)
exists, err := meta.Exists(db, sg.Object().Address())
exists, err := meta.Exists(db, object.AddressOf(sg))
require.NoError(t, err)
require.True(t, exists)
})
t.Run("virtual object", func(t *testing.T) {
cid := cidtest.ID()
parent := generateRawObjectWithCID(t, cid)
parent := generateObjectWithCID(t, cid)
child := generateRawObjectWithCID(t, cid)
child.SetParent(parent.Object().SDK())
child := generateObjectWithCID(t, cid)
child.SetParent(parent)
child.SetParentID(parent.ID())
err := putBig(db, child.Object())
err := putBig(db, child)
require.NoError(t, err)
_, err = meta.Exists(db, parent.Object().Address())
_, err = meta.Exists(db, object.AddressOf(parent))
var expectedErr *objectSDK.SplitInfoError
require.True(t, errors.As(err, &expectedErr))
@ -75,28 +76,28 @@ func TestDB_Exists(t *testing.T) {
cid := cidtest.ID()
splitID := objectSDK.NewSplitID()
parent := generateRawObjectWithCID(t, cid)
parent := generateObjectWithCID(t, cid)
addAttribute(parent, "foo", "bar")
child := generateRawObjectWithCID(t, cid)
child.SetParent(parent.Object().SDK())
child := generateObjectWithCID(t, cid)
child.SetParent(parent)
child.SetParentID(parent.ID())
child.SetSplitID(splitID)
link := generateRawObjectWithCID(t, cid)
link.SetParent(parent.Object().SDK())
link := generateObjectWithCID(t, cid)
link.SetParent(parent)
link.SetParentID(parent.ID())
link.SetChildren(child.ID())
link.SetSplitID(splitID)
t.Run("direct order", func(t *testing.T) {
err := putBig(db, child.Object())
err := putBig(db, child)
require.NoError(t, err)
err = putBig(db, link.Object())
err = putBig(db, link)
require.NoError(t, err)
_, err = meta.Exists(db, parent.Object().Address())
_, err = meta.Exists(db, object.AddressOf(parent))
require.Error(t, err)
si, ok := err.(*objectSDK.SplitInfoError)
@ -108,13 +109,13 @@ func TestDB_Exists(t *testing.T) {
})
t.Run("reverse order", func(t *testing.T) {
err := meta.Put(db, link.Object(), nil)
err := meta.Put(db, link, nil)
require.NoError(t, err)
err = putBig(db, child.Object())
err = putBig(db, child)
require.NoError(t, err)
_, err = meta.Exists(db, parent.Object().Address())
_, err = meta.Exists(db, object.AddressOf(parent))
require.Error(t, err)
si, ok := err.(*objectSDK.SplitInfoError)

View file

@ -18,7 +18,7 @@ type GetPrm struct {
// GetRes groups resulting values of Get operation.
type GetRes struct {
hdr *object.Object
hdr *objectSDK.Object
}
// WithAddress is a Get option to set the address of the requested object.
@ -44,12 +44,12 @@ func (p *GetPrm) WithRaw(raw bool) *GetPrm {
}
// Header returns the requested object header.
func (r *GetRes) Header() *object.Object {
func (r *GetRes) Header() *objectSDK.Object {
return r.hdr
}
// Get reads the object from DB.
func Get(db *DB, addr *addressSDK.Address) (*object.Object, error) {
func Get(db *DB, addr *addressSDK.Address) (*objectSDK.Object, error) {
r, err := db.Get(new(GetPrm).WithAddress(addr))
if err != nil {
return nil, err
@ -59,7 +59,7 @@ func Get(db *DB, addr *addressSDK.Address) (*object.Object, error) {
}
// GetRaw reads physically stored object from DB.
func GetRaw(db *DB, addr *addressSDK.Address, raw bool) (*object.Object, error) {
func GetRaw(db *DB, addr *addressSDK.Address, raw bool) (*objectSDK.Object, error) {
r, err := db.Get(new(GetPrm).WithAddress(addr).WithRaw(raw))
if err != nil {
return nil, err
@ -81,8 +81,8 @@ func (db *DB) Get(prm *GetPrm) (res *GetRes, err error) {
return
}
func (db *DB) get(tx *bbolt.Tx, addr *addressSDK.Address, checkGraveyard, raw bool) (*object.Object, error) {
obj := object.New()
func (db *DB) get(tx *bbolt.Tx, addr *addressSDK.Address, checkGraveyard, raw bool) (*objectSDK.Object, error) {
obj := objectSDK.New()
key := objectKey(addr.ObjectID())
cid := addr.ContainerID()
@ -126,7 +126,7 @@ func getFromBucket(tx *bbolt.Tx, name, key []byte) []byte {
return bkt.Get(key)
}
func getVirtualObject(tx *bbolt.Tx, cid *cid.ID, key []byte, raw bool) (*object.Object, error) {
func getVirtualObject(tx *bbolt.Tx, cid *cid.ID, key []byte, raw bool) (*objectSDK.Object, error) {
if raw {
return nil, getSplitInfoError(tx, cid, key)
}
@ -151,18 +151,20 @@ func getVirtualObject(tx *bbolt.Tx, cid *cid.ID, key []byte, raw bool) (*object.
virtualOID := relativeLst[len(relativeLst)-1]
data := getFromBucket(tx, primaryBucketName(cid), virtualOID)
child := object.New()
child := objectSDK.New()
err = child.Unmarshal(data)
if err != nil {
return nil, fmt.Errorf("can't unmarshal child with parent: %w", err)
}
if child.GetParent() == nil { // this should never happen though
par := child.Parent()
if par == nil { // this should never happen though
return nil, object.ErrNotFound
}
return child.GetParent(), nil
return par, nil
}
func getSplitInfoError(tx *bbolt.Tx, cid *cid.ID, key []byte) error {

View file

@ -14,67 +14,67 @@ import (
func TestDB_Get(t *testing.T) {
db := newDB(t)
raw := generateRawObject(t)
raw := generateObject(t)
// equal fails on diff of <nil> attributes and <{}> attributes,
/* so we make non empty attribute slice in parent*/
addAttribute(raw, "foo", "bar")
t.Run("object not found", func(t *testing.T) {
_, err := meta.Get(db, raw.Object().Address())
_, err := meta.Get(db, object.AddressOf(raw))
require.Error(t, err)
})
t.Run("put regular object", func(t *testing.T) {
err := putBig(db, raw.Object())
err := putBig(db, raw)
require.NoError(t, err)
newObj, err := meta.Get(db, raw.Object().Address())
newObj, err := meta.Get(db, object.AddressOf(raw))
require.NoError(t, err)
require.Equal(t, raw.CutPayload().Object(), newObj)
require.Equal(t, raw.CutPayload(), newObj)
})
t.Run("put tombstone object", func(t *testing.T) {
raw.SetType(objectSDK.TypeTombstone)
raw.SetID(testOID())
err := putBig(db, raw.Object())
err := putBig(db, raw)
require.NoError(t, err)
newObj, err := meta.Get(db, raw.Object().Address())
newObj, err := meta.Get(db, object.AddressOf(raw))
require.NoError(t, err)
require.Equal(t, raw.CutPayload().Object(), newObj)
require.Equal(t, raw.CutPayload(), newObj)
})
t.Run("put storage group object", func(t *testing.T) {
raw.SetType(objectSDK.TypeStorageGroup)
raw.SetID(testOID())
err := putBig(db, raw.Object())
err := putBig(db, raw)
require.NoError(t, err)
newObj, err := meta.Get(db, raw.Object().Address())
newObj, err := meta.Get(db, object.AddressOf(raw))
require.NoError(t, err)
require.Equal(t, raw.CutPayload().Object(), newObj)
require.Equal(t, raw.CutPayload(), newObj)
})
t.Run("put virtual object", func(t *testing.T) {
cid := cidtest.ID()
splitID := objectSDK.NewSplitID()
parent := generateRawObjectWithCID(t, cid)
parent := generateObjectWithCID(t, cid)
addAttribute(parent, "foo", "bar")
child := generateRawObjectWithCID(t, cid)
child.SetParent(parent.Object().SDK())
child := generateObjectWithCID(t, cid)
child.SetParent(parent)
child.SetParentID(parent.ID())
child.SetSplitID(splitID)
err := putBig(db, child.Object())
err := putBig(db, child)
require.NoError(t, err)
t.Run("raw is true", func(t *testing.T) {
_, err = meta.GetRaw(db, parent.Object().Address(), true)
_, err = meta.GetRaw(db, object.AddressOf(parent), true)
require.Error(t, err)
siErr, ok := err.(*objectSDK.SplitInfoError)
@ -85,13 +85,13 @@ func TestDB_Get(t *testing.T) {
require.Nil(t, siErr.SplitInfo().Link())
})
newParent, err := meta.GetRaw(db, parent.Object().Address(), false)
newParent, err := meta.GetRaw(db, object.AddressOf(parent), false)
require.NoError(t, err)
require.True(t, binaryEqual(parent.CutPayload().Object(), newParent))
require.True(t, binaryEqual(parent.CutPayload(), newParent))
newChild, err := meta.GetRaw(db, child.Object().Address(), true)
newChild, err := meta.GetRaw(db, object.AddressOf(child), true)
require.NoError(t, err)
require.True(t, binaryEqual(child.CutPayload().Object(), newChild))
require.True(t, binaryEqual(child.CutPayload(), newChild))
})
t.Run("get removed object", func(t *testing.T) {
@ -111,7 +111,7 @@ func TestDB_Get(t *testing.T) {
// binary equal is used when object contains empty lists in the structure and
// requre.Equal fails on comparing <nil> and []{} lists.
func binaryEqual(a, b *object.Object) bool {
func binaryEqual(a, b *objectSDK.Object) bool {
binaryA, err := a.Marshal()
if err != nil {
return false

View file

@ -3,6 +3,7 @@ package meta_test
import (
"testing"
"github.com/nspcc-dev/neofs-node/pkg/core/object"
meta "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/metabase"
addressSDK "github.com/nspcc-dev/neofs-sdk-go/object/address"
"github.com/stretchr/testify/require"
@ -12,15 +13,15 @@ func TestDB_IterateOverGraveyard(t *testing.T) {
db := newDB(t)
// generate and put 2 objects
obj1 := generateRawObject(t)
obj2 := generateRawObject(t)
obj1 := generateObject(t)
obj2 := generateObject(t)
var err error
err = putBig(db, obj1.Object())
err = putBig(db, obj1)
require.NoError(t, err)
err = putBig(db, obj2.Object())
err = putBig(db, obj2)
require.NoError(t, err)
inhumePrm := new(meta.InhumePrm)
@ -29,14 +30,14 @@ func TestDB_IterateOverGraveyard(t *testing.T) {
addrTombstone := generateAddress()
_, err = db.Inhume(inhumePrm.
WithAddresses(obj1.Object().Address()).
WithAddresses(object.AddressOf(obj1)).
WithTombstoneAddress(addrTombstone),
)
require.NoError(t, err)
// inhume with GC mark
_, err = db.Inhume(inhumePrm.
WithAddresses(obj2.Object().Address()).
WithAddresses(object.AddressOf(obj2)).
WithGCMark(),
)
@ -60,6 +61,6 @@ func TestDB_IterateOverGraveyard(t *testing.T) {
require.NoError(t, err)
require.Equal(t, 2, counterAll)
require.Equal(t, []*addressSDK.Address{obj1.Object().Address()}, buriedTS)
require.Equal(t, []*addressSDK.Address{obj2.Object().Address()}, buriedGC)
require.Equal(t, []*addressSDK.Address{object.AddressOf(obj1)}, buriedTS)
require.Equal(t, []*addressSDK.Address{object.AddressOf(obj2)}, buriedGC)
}

View file

@ -5,7 +5,7 @@ import (
"errors"
"fmt"
objectSDK "github.com/nspcc-dev/neofs-sdk-go/object"
"github.com/nspcc-dev/neofs-sdk-go/object"
addressSDK "github.com/nspcc-dev/neofs-sdk-go/object/address"
"go.etcd.io/bbolt"
)
@ -100,7 +100,7 @@ func (db *DB) Inhume(prm *InhumePrm) (res *InhumeRes, err error) {
// if object is stored and it is regular object then update bucket
// with container size estimations
if err == nil && obj.Type() == objectSDK.TypeRegular {
if err == nil && obj.Type() == object.TypeRegular {
err := changeContainerSize(
tx,
obj.ContainerID(),

View file

@ -12,21 +12,21 @@ import (
func TestDB_Inhume(t *testing.T) {
db := newDB(t)
raw := generateRawObject(t)
raw := generateObject(t)
addAttribute(raw, "foo", "bar")
tombstoneID := generateAddress()
err := putBig(db, raw.Object())
err := putBig(db, raw)
require.NoError(t, err)
err = meta.Inhume(db, raw.Object().Address(), tombstoneID)
err = meta.Inhume(db, object.AddressOf(raw), tombstoneID)
require.NoError(t, err)
_, err = meta.Exists(db, raw.Object().Address())
_, err = meta.Exists(db, object.AddressOf(raw))
require.EqualError(t, err, object.ErrAlreadyRemoved.Error())
_, err = meta.Get(db, raw.Object().Address())
_, err = meta.Get(db, object.AddressOf(raw))
require.EqualError(t, err, object.ErrAlreadyRemoved.Error())
}

View file

@ -5,6 +5,7 @@ import (
"testing"
objectV2 "github.com/nspcc-dev/neofs-api-go/v2/object"
object2 "github.com/nspcc-dev/neofs-node/pkg/core/object"
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"
@ -47,14 +48,13 @@ func TestDB_IterateExpired(t *testing.T) {
}
func putWithExpiration(t *testing.T, db *meta.DB, typ object.Type, expiresAt uint64) *addressSDK.Address {
raw := generateRawObject(t)
raw.SetType(typ)
addAttribute(raw, objectV2.SysAttributeExpEpoch, strconv.FormatUint(expiresAt, 10))
obj := generateObject(t)
obj.SetType(typ)
addAttribute(obj, objectV2.SysAttributeExpEpoch, strconv.FormatUint(expiresAt, 10))
obj := raw.Object()
require.NoError(t, putBig(db, obj))
return obj.Address()
return object2.AddressOf(obj)
}
func TestDB_IterateCoveredByTombstones(t *testing.T) {

View file

@ -5,6 +5,7 @@ import (
"sort"
"testing"
"github.com/nspcc-dev/neofs-node/pkg/core/object"
meta "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/metabase"
cidtest "github.com/nspcc-dev/neofs-sdk-go/container/id/test"
objectSDK "github.com/nspcc-dev/neofs-sdk-go/object"
@ -27,46 +28,46 @@ func TestLisObjectsWithCursor(t *testing.T) {
containerID := cidtest.ID()
// add one regular object
obj := generateRawObjectWithCID(t, containerID)
obj := generateObjectWithCID(t, containerID)
obj.SetType(objectSDK.TypeRegular)
err := putBig(db, obj.Object())
err := putBig(db, obj)
require.NoError(t, err)
expected = append(expected, obj.Object().Address())
expected = append(expected, object.AddressOf(obj))
// add one tombstone
obj = generateRawObjectWithCID(t, containerID)
obj = generateObjectWithCID(t, containerID)
obj.SetType(objectSDK.TypeTombstone)
err = putBig(db, obj.Object())
err = putBig(db, obj)
require.NoError(t, err)
expected = append(expected, obj.Object().Address())
expected = append(expected, object.AddressOf(obj))
// add one storage group
obj = generateRawObjectWithCID(t, containerID)
obj = generateObjectWithCID(t, containerID)
obj.SetType(objectSDK.TypeStorageGroup)
err = putBig(db, obj.Object())
err = putBig(db, obj)
require.NoError(t, err)
expected = append(expected, obj.Object().Address())
expected = append(expected, object.AddressOf(obj))
// add one inhumed (do not include into expected)
obj = generateRawObjectWithCID(t, containerID)
obj = generateObjectWithCID(t, containerID)
obj.SetType(objectSDK.TypeRegular)
err = putBig(db, obj.Object())
err = putBig(db, obj)
require.NoError(t, err)
ts := generateRawObjectWithCID(t, containerID)
err = meta.Inhume(db, obj.Object().Address(), ts.Object().Address())
ts := generateObjectWithCID(t, containerID)
err = meta.Inhume(db, object.AddressOf(obj), object.AddressOf(ts))
require.NoError(t, err)
// add one child object (do not include parent into expected)
splitID := objectSDK.NewSplitID()
parent := generateRawObjectWithCID(t, containerID)
parent := generateObjectWithCID(t, containerID)
addAttribute(parent, "foo", "bar")
child := generateRawObjectWithCID(t, containerID)
child.SetParent(parent.Object().SDK())
child := generateObjectWithCID(t, containerID)
child.SetParent(parent)
child.SetParentID(parent.ID())
child.SetSplitID(splitID)
err = putBig(db, child.Object())
err = putBig(db, child)
require.NoError(t, err)
expected = append(expected, child.Object().Address())
expected = append(expected, object.AddressOf(child))
}
expected = sortAddresses(expected)
@ -113,10 +114,10 @@ func TestAddObjectDuringListingWithCursor(t *testing.T) {
// fill metabase with objects
for i := 0; i < total; i++ {
obj := generateRawObject(t)
err := putBig(db, obj.Object())
obj := generateObject(t)
err := putBig(db, obj)
require.NoError(t, err)
expected[obj.Object().Address().String()] = 0
expected[object.AddressOf(obj).String()] = 0
}
// get half of the objects
@ -130,8 +131,8 @@ func TestAddObjectDuringListingWithCursor(t *testing.T) {
// add new objects
for i := 0; i < total; i++ {
obj := generateRawObject(t)
err = putBig(db, obj.Object())
obj := generateObject(t)
err = putBig(db, obj)
require.NoError(t, err)
}

View file

@ -3,6 +3,7 @@ package meta_test
import (
"testing"
"github.com/nspcc-dev/neofs-node/pkg/core/object"
meta "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/metabase"
"github.com/stretchr/testify/require"
)
@ -10,14 +11,14 @@ import (
func TestDB_Movable(t *testing.T) {
db := newDB(t)
raw1 := generateRawObject(t)
raw2 := generateRawObject(t)
raw1 := generateObject(t)
raw2 := generateObject(t)
// put two objects in metabase
err := putBig(db, raw1.Object())
err := putBig(db, raw1)
require.NoError(t, err)
err = putBig(db, raw2.Object())
err = putBig(db, raw2)
require.NoError(t, err)
// check if toMoveIt index empty
@ -26,17 +27,17 @@ func TestDB_Movable(t *testing.T) {
require.Len(t, toMoveList, 0)
// mark to move object2
err = meta.ToMoveIt(db, raw2.Object().Address())
err = meta.ToMoveIt(db, object.AddressOf(raw2))
require.NoError(t, err)
// check if toMoveIt index contains address of object 2
toMoveList, err = meta.Movable(db)
require.NoError(t, err)
require.Len(t, toMoveList, 1)
require.Contains(t, toMoveList, raw2.Object().Address())
require.Contains(t, toMoveList, object.AddressOf(raw2))
// remove from toMoveIt index non existing address
err = meta.DoNotMove(db, raw1.Object().Address())
err = meta.DoNotMove(db, object.AddressOf(raw1))
require.NoError(t, err)
// check if toMoveIt index hasn't changed
@ -45,7 +46,7 @@ func TestDB_Movable(t *testing.T) {
require.Len(t, toMoveList, 1)
// remove from toMoveIt index existing address
err = meta.DoNotMove(db, raw2.Object().Address())
err = meta.DoNotMove(db, object.AddressOf(raw2))
require.NoError(t, err)
// check if toMoveIt index is empty now

View file

@ -22,7 +22,7 @@ type (
// PutPrm groups the parameters of Put operation.
type PutPrm struct {
obj *object.Object
obj *objectSDK.Object
id *blobovnicza.ID
}
@ -31,7 +31,7 @@ type PutPrm struct {
type PutRes struct{}
// WithObject is a Put option to set object to save.
func (p *PutPrm) WithObject(obj *object.Object) *PutPrm {
func (p *PutPrm) WithObject(obj *objectSDK.Object) *PutPrm {
if p != nil {
p.obj = obj
}
@ -55,7 +55,7 @@ var (
)
// Put saves the object in DB.
func Put(db *DB, obj *object.Object, id *blobovnicza.ID) error {
func Put(db *DB, obj *objectSDK.Object, id *blobovnicza.ID) error {
_, err := db.Put(new(PutPrm).
WithObject(obj).
WithBlobovniczaID(id),
@ -72,17 +72,17 @@ func (db *DB) Put(prm *PutPrm) (res *PutRes, err error) {
})
if err == nil {
storagelog.Write(db.log,
storagelog.AddressField(prm.obj.Address()),
storagelog.AddressField(prm.obj),
storagelog.OpField("metabase PUT"))
}
return
}
func (db *DB) put(tx *bbolt.Tx, obj *object.Object, id *blobovnicza.ID, si *objectSDK.SplitInfo) error {
func (db *DB) put(tx *bbolt.Tx, obj *objectSDK.Object, id *blobovnicza.ID, si *objectSDK.SplitInfo) error {
isParent := si != nil
exists, err := db.exists(tx, obj.Address())
exists, err := db.exists(tx, object.AddressOf(obj))
if errors.As(err, &splitInfoError) {
exists = true // object exists, however it is virtual
@ -97,26 +97,26 @@ func (db *DB) put(tx *bbolt.Tx, obj *object.Object, id *blobovnicza.ID, si *obje
// to another, then it calls metabase.Put method with new blobovniczaID
// and this code should be triggered
if !isParent && id != nil {
return updateBlobovniczaID(tx, obj.Address(), id)
return updateBlobovniczaID(tx, object.AddressOf(obj), id)
}
// when storage already has last object in split hierarchy and there is
// a linking object to put (or vice versa), we should update split info
// with object ids of these objects
if isParent {
return updateSplitInfo(tx, obj.Address(), si)
return updateSplitInfo(tx, object.AddressOf(obj), si)
}
return nil
}
if obj.GetParent() != nil && !isParent { // limit depth by two
if par := obj.Parent(); par != nil && !isParent { // limit depth by two
parentSI, err := splitInfoFromObject(obj)
if err != nil {
return err
}
err = db.put(tx, obj.GetParent(), id, parentSI)
err = db.put(tx, par, id, parentSI)
if err != nil {
return err
}
@ -181,9 +181,9 @@ func (db *DB) put(tx *bbolt.Tx, obj *object.Object, id *blobovnicza.ID, si *obje
}
// builds list of <unique> indexes from the object.
func uniqueIndexes(obj *object.Object, si *objectSDK.SplitInfo, id *blobovnicza.ID) ([]namedBucketItem, error) {
func uniqueIndexes(obj *objectSDK.Object, si *objectSDK.SplitInfo, id *blobovnicza.ID) ([]namedBucketItem, error) {
isParent := si != nil
addr := obj.Address()
addr := object.AddressOf(obj)
objKey := objectKey(addr.ObjectID())
result := make([]namedBucketItem, 0, 3)
@ -202,7 +202,7 @@ func uniqueIndexes(obj *object.Object, si *objectSDK.SplitInfo, id *blobovnicza.
return nil, ErrUnknownObjectType
}
rawObject, err := object.NewRawFromObject(obj).CutPayload().Marshal()
rawObject, err := obj.CutPayload().Marshal()
if err != nil {
return nil, fmt.Errorf("can't marshal object header: %w", err)
}
@ -248,9 +248,9 @@ func uniqueIndexes(obj *object.Object, si *objectSDK.SplitInfo, id *blobovnicza.
}
// builds list of <list> indexes from the object.
func listIndexes(obj *object.Object) ([]namedBucketItem, error) {
func listIndexes(obj *objectSDK.Object) ([]namedBucketItem, error) {
result := make([]namedBucketItem, 0, 3)
addr := obj.Address()
addr := object.AddressOf(obj)
objKey := objectKey(addr.ObjectID())
// index payload hashes
@ -282,8 +282,8 @@ func listIndexes(obj *object.Object) ([]namedBucketItem, error) {
}
// builds list of <fake bucket tree> indexes from the object.
func fkbtIndexes(obj *object.Object) ([]namedBucketItem, error) {
addr := obj.Address()
func fkbtIndexes(obj *objectSDK.Object) ([]namedBucketItem, error) {
addr := object.AddressOf(obj)
objKey := []byte(addr.ObjectID().String())
attrs := obj.Attributes()
@ -429,7 +429,7 @@ func updateSplitInfo(tx *bbolt.Tx, addr *addressSDK.Address, from *objectSDK.Spl
// splitInfoFromObject returns split info based on last or linkin object.
// Otherwise returns nil, nil.
func splitInfoFromObject(obj *object.Object) (*objectSDK.SplitInfo, error) {
func splitInfoFromObject(obj *objectSDK.Object) (*objectSDK.SplitInfo, error) {
if obj.Parent() == nil {
return nil, nil
}
@ -451,12 +451,12 @@ func splitInfoFromObject(obj *object.Object) (*objectSDK.SplitInfo, error) {
// isLinkObject returns true if object contains parent header and list
// of children.
func isLinkObject(obj *object.Object) bool {
func isLinkObject(obj *objectSDK.Object) bool {
return len(obj.Children()) > 0 && obj.Parent() != nil
}
// isLastObject returns true if object contains only parent header without list
// of children.
func isLastObject(obj *object.Object) bool {
func isLastObject(obj *objectSDK.Object) bool {
return len(obj.Children()) == 0 && obj.Parent() != nil
}

View file

@ -3,6 +3,7 @@ package meta_test
import (
"testing"
"github.com/nspcc-dev/neofs-node/pkg/core/object"
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/blobovnicza"
meta "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/metabase"
"github.com/stretchr/testify/require"
@ -11,34 +12,34 @@ import (
func TestDB_PutBlobovnicaUpdate(t *testing.T) {
db := newDB(t)
raw1 := generateRawObject(t)
raw1 := generateObject(t)
blobovniczaID := blobovnicza.ID{1, 2, 3, 4}
// put one object with blobovniczaID
err := meta.Put(db, raw1.Object(), &blobovniczaID)
err := meta.Put(db, raw1, &blobovniczaID)
require.NoError(t, err)
fetchedBlobovniczaID, err := meta.IsSmall(db, raw1.Object().Address())
fetchedBlobovniczaID, err := meta.IsSmall(db, object.AddressOf(raw1))
require.NoError(t, err)
require.Equal(t, &blobovniczaID, fetchedBlobovniczaID)
t.Run("update blobovniczaID", func(t *testing.T) {
newID := blobovnicza.ID{5, 6, 7, 8}
err := meta.Put(db, raw1.Object(), &newID)
err := meta.Put(db, raw1, &newID)
require.NoError(t, err)
fetchedBlobovniczaID, err := meta.IsSmall(db, raw1.Object().Address())
fetchedBlobovniczaID, err := meta.IsSmall(db, object.AddressOf(raw1))
require.NoError(t, err)
require.Equal(t, &newID, fetchedBlobovniczaID)
})
t.Run("update blobovniczaID on bad object", func(t *testing.T) {
raw2 := generateRawObject(t)
err := putBig(db, raw2.Object())
raw2 := generateObject(t)
err := putBig(db, raw2)
require.NoError(t, err)
fetchedBlobovniczaID, err := meta.IsSmall(db, raw2.Object().Address())
fetchedBlobovniczaID, err := meta.IsSmall(db, object.AddressOf(raw2))
require.NoError(t, err)
require.Nil(t, fetchedBlobovniczaID)
})

View file

@ -5,6 +5,7 @@ import (
"testing"
v2object "github.com/nspcc-dev/neofs-api-go/v2/object"
"github.com/nspcc-dev/neofs-node/pkg/core/object"
meta "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/metabase"
cidtest "github.com/nspcc-dev/neofs-sdk-go/container/id/test"
objectSDK "github.com/nspcc-dev/neofs-sdk-go/object"
@ -18,62 +19,62 @@ func TestDB_SelectUserAttributes(t *testing.T) {
cid := cidtest.ID()
raw1 := generateRawObjectWithCID(t, cid)
raw1 := generateObjectWithCID(t, cid)
addAttribute(raw1, "foo", "bar")
addAttribute(raw1, "x", "y")
err := putBig(db, raw1.Object())
err := putBig(db, raw1)
require.NoError(t, err)
raw2 := generateRawObjectWithCID(t, cid)
raw2 := generateObjectWithCID(t, cid)
addAttribute(raw2, "foo", "bar")
addAttribute(raw2, "x", "z")
err = putBig(db, raw2.Object())
err = putBig(db, raw2)
require.NoError(t, err)
raw3 := generateRawObjectWithCID(t, cid)
raw3 := generateObjectWithCID(t, cid)
addAttribute(raw3, "a", "b")
err = putBig(db, raw3.Object())
err = putBig(db, raw3)
require.NoError(t, err)
raw4 := generateRawObjectWithCID(t, cid)
raw4 := generateObjectWithCID(t, cid)
addAttribute(raw4, "path", "test/1/2")
err = putBig(db, raw4.Object())
err = putBig(db, raw4)
require.NoError(t, err)
raw5 := generateRawObjectWithCID(t, cid)
raw5 := generateObjectWithCID(t, cid)
addAttribute(raw5, "path", "test/1/3")
err = putBig(db, raw5.Object())
err = putBig(db, raw5)
require.NoError(t, err)
raw6 := generateRawObjectWithCID(t, cid)
raw6 := generateObjectWithCID(t, cid)
addAttribute(raw6, "path", "test/2/3")
err = putBig(db, raw6.Object())
err = putBig(db, raw6)
require.NoError(t, err)
fs := objectSDK.SearchFilters{}
fs.AddFilter("foo", "bar", objectSDK.MatchStringEqual)
testSelect(t, db, cid, fs,
raw1.Object().Address(),
raw2.Object().Address(),
object.AddressOf(raw1),
object.AddressOf(raw2),
)
fs = objectSDK.SearchFilters{}
fs.AddFilter("x", "y", objectSDK.MatchStringEqual)
testSelect(t, db, cid, fs, raw1.Object().Address())
testSelect(t, db, cid, fs, object.AddressOf(raw1))
fs = objectSDK.SearchFilters{}
fs.AddFilter("x", "y", objectSDK.MatchStringNotEqual)
testSelect(t, db, cid, fs, raw2.Object().Address())
testSelect(t, db, cid, fs, object.AddressOf(raw2))
fs = objectSDK.SearchFilters{}
fs.AddFilter("a", "b", objectSDK.MatchStringEqual)
testSelect(t, db, cid, fs, raw3.Object().Address())
testSelect(t, db, cid, fs, object.AddressOf(raw3))
fs = objectSDK.SearchFilters{}
fs.AddFilter("c", "d", objectSDK.MatchStringEqual)
@ -82,56 +83,56 @@ func TestDB_SelectUserAttributes(t *testing.T) {
fs = objectSDK.SearchFilters{}
fs.AddFilter("foo", "", objectSDK.MatchNotPresent)
testSelect(t, db, cid, fs,
raw3.Object().Address(),
raw4.Object().Address(),
raw5.Object().Address(),
raw6.Object().Address(),
object.AddressOf(raw3),
object.AddressOf(raw4),
object.AddressOf(raw5),
object.AddressOf(raw6),
)
fs = objectSDK.SearchFilters{}
fs.AddFilter("a", "", objectSDK.MatchNotPresent)
testSelect(t, db, cid, fs,
raw1.Object().Address(),
raw2.Object().Address(),
raw4.Object().Address(),
raw5.Object().Address(),
raw6.Object().Address(),
object.AddressOf(raw1),
object.AddressOf(raw2),
object.AddressOf(raw4),
object.AddressOf(raw5),
object.AddressOf(raw6),
)
fs = objectSDK.SearchFilters{}
testSelect(t, db, cid, fs,
raw1.Object().Address(),
raw2.Object().Address(),
raw3.Object().Address(),
raw4.Object().Address(),
raw5.Object().Address(),
raw6.Object().Address(),
object.AddressOf(raw1),
object.AddressOf(raw2),
object.AddressOf(raw3),
object.AddressOf(raw4),
object.AddressOf(raw5),
object.AddressOf(raw6),
)
fs = objectSDK.SearchFilters{}
fs.AddFilter("key", "", objectSDK.MatchNotPresent)
testSelect(t, db, cid, fs,
raw1.Object().Address(),
raw2.Object().Address(),
raw3.Object().Address(),
raw4.Object().Address(),
raw5.Object().Address(),
raw6.Object().Address(),
object.AddressOf(raw1),
object.AddressOf(raw2),
object.AddressOf(raw3),
object.AddressOf(raw4),
object.AddressOf(raw5),
object.AddressOf(raw6),
)
fs = objectSDK.SearchFilters{}
fs.AddFilter("path", "test", objectSDK.MatchCommonPrefix)
testSelect(t, db, cid, fs,
raw4.Object().Address(),
raw5.Object().Address(),
raw6.Object().Address(),
object.AddressOf(raw4),
object.AddressOf(raw5),
object.AddressOf(raw6),
)
fs = objectSDK.SearchFilters{}
fs.AddFilter("path", "test/1", objectSDK.MatchCommonPrefix)
testSelect(t, db, cid, fs,
raw4.Object().Address(),
raw5.Object().Address(),
object.AddressOf(raw4),
object.AddressOf(raw5),
)
}
@ -142,47 +143,47 @@ func TestDB_SelectRootPhyParent(t *testing.T) {
// prepare
small := generateRawObjectWithCID(t, cid)
err := putBig(db, small.Object())
small := generateObjectWithCID(t, cid)
err := putBig(db, small)
require.NoError(t, err)
ts := generateRawObjectWithCID(t, cid)
ts := generateObjectWithCID(t, cid)
ts.SetType(objectSDK.TypeTombstone)
err = putBig(db, ts.Object())
err = putBig(db, ts)
require.NoError(t, err)
sg := generateRawObjectWithCID(t, cid)
sg := generateObjectWithCID(t, cid)
sg.SetType(objectSDK.TypeStorageGroup)
err = putBig(db, sg.Object())
err = putBig(db, sg)
require.NoError(t, err)
leftChild := generateRawObjectWithCID(t, cid)
leftChild := generateObjectWithCID(t, cid)
leftChild.InitRelations()
err = putBig(db, leftChild.Object())
err = putBig(db, leftChild)
require.NoError(t, err)
parent := generateRawObjectWithCID(t, cid)
parent := generateObjectWithCID(t, cid)
rightChild := generateRawObjectWithCID(t, cid)
rightChild.SetParent(parent.Object().SDK())
rightChild := generateObjectWithCID(t, cid)
rightChild.SetParent(parent)
rightChild.SetParentID(parent.ID())
err = putBig(db, rightChild.Object())
err = putBig(db, rightChild)
require.NoError(t, err)
link := generateRawObjectWithCID(t, cid)
link.SetParent(parent.Object().SDK())
link := generateObjectWithCID(t, cid)
link.SetParent(parent)
link.SetParentID(parent.ID())
link.SetChildren(leftChild.ID(), rightChild.ID())
err = putBig(db, link.Object())
err = putBig(db, link)
require.NoError(t, err)
t.Run("root objects", func(t *testing.T) {
fs := objectSDK.SearchFilters{}
fs.AddRootFilter()
testSelect(t, db, cid, fs,
small.Object().Address(),
parent.Object().Address(),
object.AddressOf(small),
object.AddressOf(parent),
)
fs = objectSDK.SearchFilters{}
@ -194,12 +195,12 @@ func TestDB_SelectRootPhyParent(t *testing.T) {
fs := objectSDK.SearchFilters{}
fs.AddPhyFilter()
testSelect(t, db, cid, fs,
small.Object().Address(),
ts.Object().Address(),
sg.Object().Address(),
leftChild.Object().Address(),
rightChild.Object().Address(),
link.Object().Address(),
object.AddressOf(small),
object.AddressOf(ts),
object.AddressOf(sg),
object.AddressOf(leftChild),
object.AddressOf(rightChild),
object.AddressOf(link),
)
fs = objectSDK.SearchFilters{}
@ -211,18 +212,18 @@ func TestDB_SelectRootPhyParent(t *testing.T) {
fs := objectSDK.SearchFilters{}
fs.AddFilter(v2object.FilterHeaderObjectType, v2object.TypeRegular.String(), objectSDK.MatchStringEqual)
testSelect(t, db, cid, fs,
small.Object().Address(),
leftChild.Object().Address(),
rightChild.Object().Address(),
link.Object().Address(),
parent.Object().Address(),
object.AddressOf(small),
object.AddressOf(leftChild),
object.AddressOf(rightChild),
object.AddressOf(link),
object.AddressOf(parent),
)
fs = objectSDK.SearchFilters{}
fs.AddFilter(v2object.FilterHeaderObjectType, v2object.TypeRegular.String(), objectSDK.MatchStringNotEqual)
testSelect(t, db, cid, fs,
ts.Object().Address(),
sg.Object().Address(),
object.AddressOf(ts),
object.AddressOf(sg),
)
fs = objectSDK.SearchFilters{}
@ -233,17 +234,17 @@ func TestDB_SelectRootPhyParent(t *testing.T) {
t.Run("tombstone objects", func(t *testing.T) {
fs := objectSDK.SearchFilters{}
fs.AddFilter(v2object.FilterHeaderObjectType, v2object.TypeTombstone.String(), objectSDK.MatchStringEqual)
testSelect(t, db, cid, fs, ts.Object().Address())
testSelect(t, db, cid, fs, object.AddressOf(ts))
fs = objectSDK.SearchFilters{}
fs.AddFilter(v2object.FilterHeaderObjectType, v2object.TypeTombstone.String(), objectSDK.MatchStringNotEqual)
testSelect(t, db, cid, fs,
small.Object().Address(),
leftChild.Object().Address(),
rightChild.Object().Address(),
link.Object().Address(),
parent.Object().Address(),
sg.Object().Address(),
object.AddressOf(small),
object.AddressOf(leftChild),
object.AddressOf(rightChild),
object.AddressOf(link),
object.AddressOf(parent),
object.AddressOf(sg),
)
fs = objectSDK.SearchFilters{}
@ -254,17 +255,17 @@ func TestDB_SelectRootPhyParent(t *testing.T) {
t.Run("storage group objects", func(t *testing.T) {
fs := objectSDK.SearchFilters{}
fs.AddFilter(v2object.FilterHeaderObjectType, v2object.TypeStorageGroup.String(), objectSDK.MatchStringEqual)
testSelect(t, db, cid, fs, sg.Object().Address())
testSelect(t, db, cid, fs, object.AddressOf(sg))
fs = objectSDK.SearchFilters{}
fs.AddFilter(v2object.FilterHeaderObjectType, v2object.TypeStorageGroup.String(), objectSDK.MatchStringNotEqual)
testSelect(t, db, cid, fs,
small.Object().Address(),
leftChild.Object().Address(),
rightChild.Object().Address(),
link.Object().Address(),
parent.Object().Address(),
ts.Object().Address(),
object.AddressOf(small),
object.AddressOf(leftChild),
object.AddressOf(rightChild),
object.AddressOf(link),
object.AddressOf(parent),
object.AddressOf(ts),
)
fs = objectSDK.SearchFilters{}
@ -279,8 +280,8 @@ func TestDB_SelectRootPhyParent(t *testing.T) {
objectSDK.MatchStringEqual)
testSelect(t, db, cid, fs,
rightChild.Object().Address(),
link.Object().Address(),
object.AddressOf(rightChild),
object.AddressOf(link),
)
fs = objectSDK.SearchFilters{}
@ -291,13 +292,13 @@ func TestDB_SelectRootPhyParent(t *testing.T) {
t.Run("all objects", func(t *testing.T) {
fs := objectSDK.SearchFilters{}
testSelect(t, db, cid, fs,
small.Object().Address(),
ts.Object().Address(),
sg.Object().Address(),
leftChild.Object().Address(),
rightChild.Object().Address(),
link.Object().Address(),
parent.Object().Address(),
object.AddressOf(small),
object.AddressOf(ts),
object.AddressOf(sg),
object.AddressOf(leftChild),
object.AddressOf(rightChild),
object.AddressOf(link),
object.AddressOf(parent),
)
})
}
@ -307,30 +308,30 @@ func TestDB_SelectInhume(t *testing.T) {
cid := cidtest.ID()
raw1 := generateRawObjectWithCID(t, cid)
err := putBig(db, raw1.Object())
raw1 := generateObjectWithCID(t, cid)
err := putBig(db, raw1)
require.NoError(t, err)
raw2 := generateRawObjectWithCID(t, cid)
err = putBig(db, raw2.Object())
raw2 := generateObjectWithCID(t, cid)
err = putBig(db, raw2)
require.NoError(t, err)
fs := objectSDK.SearchFilters{}
testSelect(t, db, cid, fs,
raw1.Object().Address(),
raw2.Object().Address(),
object.AddressOf(raw1),
object.AddressOf(raw2),
)
tombstone := addressSDK.NewAddress()
tombstone.SetContainerID(cid)
tombstone.SetObjectID(testOID())
err = meta.Inhume(db, raw2.Object().Address(), tombstone)
err = meta.Inhume(db, object.AddressOf(raw2), tombstone)
require.NoError(t, err)
fs = objectSDK.SearchFilters{}
testSelect(t, db, cid, fs,
raw1.Object().Address(),
object.AddressOf(raw1),
)
}
@ -339,12 +340,12 @@ func TestDB_SelectPayloadHash(t *testing.T) {
cid := cidtest.ID()
raw1 := generateRawObjectWithCID(t, cid)
err := putBig(db, raw1.Object())
raw1 := generateObjectWithCID(t, cid)
err := putBig(db, raw1)
require.NoError(t, err)
raw2 := generateRawObjectWithCID(t, cid)
err = putBig(db, raw2.Object())
raw2 := generateObjectWithCID(t, cid)
err = putBig(db, raw2)
require.NoError(t, err)
fs := objectSDK.SearchFilters{}
@ -352,14 +353,14 @@ func TestDB_SelectPayloadHash(t *testing.T) {
hex.EncodeToString(raw1.PayloadChecksum().Sum()),
objectSDK.MatchStringEqual)
testSelect(t, db, cid, fs, raw1.Object().Address())
testSelect(t, db, cid, fs, object.AddressOf(raw1))
fs = objectSDK.SearchFilters{}
fs.AddFilter(v2object.FilterHeaderPayloadHash,
hex.EncodeToString(raw1.PayloadChecksum().Sum()),
objectSDK.MatchStringNotEqual)
testSelect(t, db, cid, fs, raw2.Object().Address())
testSelect(t, db, cid, fs, object.AddressOf(raw2))
fs = objectSDK.SearchFilters{}
fs.AddFilter(v2object.FilterHeaderPayloadHash,
@ -381,18 +382,18 @@ func TestDB_SelectWithSlowFilters(t *testing.T) {
v21.SetMajor(2)
v21.SetMinor(1)
raw1 := generateRawObjectWithCID(t, cid)
raw1 := generateObjectWithCID(t, cid)
raw1.SetPayloadSize(10)
raw1.SetCreationEpoch(11)
raw1.SetVersion(v20)
err := putBig(db, raw1.Object())
err := putBig(db, raw1)
require.NoError(t, err)
raw2 := generateRawObjectWithCID(t, cid)
raw2 := generateObjectWithCID(t, cid)
raw2.SetPayloadSize(20)
raw2.SetCreationEpoch(21)
raw2.SetVersion(v21)
err = putBig(db, raw2.Object())
err = putBig(db, raw2)
require.NoError(t, err)
t.Run("object with TZHash", func(t *testing.T) {
@ -401,14 +402,14 @@ func TestDB_SelectWithSlowFilters(t *testing.T) {
hex.EncodeToString(raw1.PayloadHomomorphicHash().Sum()),
objectSDK.MatchStringEqual)
testSelect(t, db, cid, fs, raw1.Object().Address())
testSelect(t, db, cid, fs, object.AddressOf(raw1))
fs = objectSDK.SearchFilters{}
fs.AddFilter(v2object.FilterHeaderHomomorphicHash,
hex.EncodeToString(raw1.PayloadHomomorphicHash().Sum()),
objectSDK.MatchStringNotEqual)
testSelect(t, db, cid, fs, raw2.Object().Address())
testSelect(t, db, cid, fs, object.AddressOf(raw2))
fs = objectSDK.SearchFilters{}
fs.AddFilter(v2object.FilterHeaderHomomorphicHash,
@ -422,12 +423,12 @@ func TestDB_SelectWithSlowFilters(t *testing.T) {
fs := objectSDK.SearchFilters{}
fs.AddFilter(v2object.FilterHeaderPayloadLength, "20", objectSDK.MatchStringEqual)
testSelect(t, db, cid, fs, raw2.Object().Address())
testSelect(t, db, cid, fs, object.AddressOf(raw2))
fs = objectSDK.SearchFilters{}
fs.AddFilter(v2object.FilterHeaderPayloadLength, "20", objectSDK.MatchStringNotEqual)
testSelect(t, db, cid, fs, raw1.Object().Address())
testSelect(t, db, cid, fs, object.AddressOf(raw1))
fs = objectSDK.SearchFilters{}
fs.AddFilter(v2object.FilterHeaderPayloadLength, "", objectSDK.MatchNotPresent)
@ -439,12 +440,12 @@ func TestDB_SelectWithSlowFilters(t *testing.T) {
fs := objectSDK.SearchFilters{}
fs.AddFilter(v2object.FilterHeaderCreationEpoch, "11", objectSDK.MatchStringEqual)
testSelect(t, db, cid, fs, raw1.Object().Address())
testSelect(t, db, cid, fs, object.AddressOf(raw1))
fs = objectSDK.SearchFilters{}
fs.AddFilter(v2object.FilterHeaderCreationEpoch, "11", objectSDK.MatchStringNotEqual)
testSelect(t, db, cid, fs, raw2.Object().Address())
testSelect(t, db, cid, fs, object.AddressOf(raw2))
fs = objectSDK.SearchFilters{}
fs.AddFilter(v2object.FilterHeaderCreationEpoch, "", objectSDK.MatchNotPresent)
@ -455,11 +456,11 @@ func TestDB_SelectWithSlowFilters(t *testing.T) {
t.Run("object with version", func(t *testing.T) {
fs := objectSDK.SearchFilters{}
fs.AddObjectVersionFilter(objectSDK.MatchStringEqual, v21)
testSelect(t, db, cid, fs, raw2.Object().Address())
testSelect(t, db, cid, fs, object.AddressOf(raw2))
fs = objectSDK.SearchFilters{}
fs.AddObjectVersionFilter(objectSDK.MatchStringNotEqual, v21)
testSelect(t, db, cid, fs, raw1.Object().Address())
testSelect(t, db, cid, fs, object.AddressOf(raw1))
fs = objectSDK.SearchFilters{}
fs.AddObjectVersionFilter(objectSDK.MatchNotPresent, nil)
@ -474,23 +475,23 @@ func TestDB_SelectObjectID(t *testing.T) {
// prepare
parent := generateRawObjectWithCID(t, cid)
parent := generateObjectWithCID(t, cid)
regular := generateRawObjectWithCID(t, cid)
regular := generateObjectWithCID(t, cid)
regular.SetParentID(parent.ID())
regular.SetParent(parent.Object().SDK())
regular.SetParent(parent)
err := putBig(db, regular.Object())
err := putBig(db, regular)
require.NoError(t, err)
ts := generateRawObjectWithCID(t, cid)
ts := generateObjectWithCID(t, cid)
ts.SetType(objectSDK.TypeTombstone)
err = putBig(db, ts.Object())
err = putBig(db, ts)
require.NoError(t, err)
sg := generateRawObjectWithCID(t, cid)
sg := generateObjectWithCID(t, cid)
sg.SetType(objectSDK.TypeStorageGroup)
err = putBig(db, sg.Object())
err = putBig(db, sg)
require.NoError(t, err)
t.Run("not present", func(t *testing.T) {
@ -500,7 +501,7 @@ func TestDB_SelectObjectID(t *testing.T) {
})
t.Run("not found objects", func(t *testing.T) {
raw := generateRawObjectWithCID(t, cid)
raw := generateObjectWithCID(t, cid)
fs := objectSDK.SearchFilters{}
fs.AddObjectIDFilter(objectSDK.MatchStringEqual, raw.ID())
@ -511,66 +512,66 @@ func TestDB_SelectObjectID(t *testing.T) {
fs.AddObjectIDFilter(objectSDK.MatchStringNotEqual, raw.ID())
testSelect(t, db, cid, fs,
regular.Object().Address(),
parent.Object().Address(),
sg.Object().Address(),
ts.Object().Address(),
object.AddressOf(regular),
object.AddressOf(parent),
object.AddressOf(sg),
object.AddressOf(ts),
)
})
t.Run("regular objects", func(t *testing.T) {
fs := objectSDK.SearchFilters{}
fs.AddObjectIDFilter(objectSDK.MatchStringEqual, regular.ID())
testSelect(t, db, cid, fs, regular.Object().Address())
testSelect(t, db, cid, fs, object.AddressOf(regular))
fs = objectSDK.SearchFilters{}
fs.AddObjectIDFilter(objectSDK.MatchStringNotEqual, regular.ID())
testSelect(t, db, cid, fs,
parent.Object().Address(),
sg.Object().Address(),
ts.Object().Address(),
object.AddressOf(parent),
object.AddressOf(sg),
object.AddressOf(ts),
)
})
t.Run("tombstone objects", func(t *testing.T) {
fs := objectSDK.SearchFilters{}
fs.AddObjectIDFilter(objectSDK.MatchStringEqual, ts.ID())
testSelect(t, db, cid, fs, ts.Object().Address())
testSelect(t, db, cid, fs, object.AddressOf(ts))
fs = objectSDK.SearchFilters{}
fs.AddObjectIDFilter(objectSDK.MatchStringNotEqual, ts.ID())
testSelect(t, db, cid, fs,
regular.Object().Address(),
parent.Object().Address(),
sg.Object().Address(),
object.AddressOf(regular),
object.AddressOf(parent),
object.AddressOf(sg),
)
})
t.Run("storage group objects", func(t *testing.T) {
fs := objectSDK.SearchFilters{}
fs.AddObjectIDFilter(objectSDK.MatchStringEqual, sg.ID())
testSelect(t, db, cid, fs, sg.Object().Address())
testSelect(t, db, cid, fs, object.AddressOf(sg))
fs = objectSDK.SearchFilters{}
fs.AddObjectIDFilter(objectSDK.MatchStringNotEqual, sg.ID())
testSelect(t, db, cid, fs,
regular.Object().Address(),
parent.Object().Address(),
ts.Object().Address(),
object.AddressOf(regular),
object.AddressOf(parent),
object.AddressOf(ts),
)
})
t.Run("parent objects", func(t *testing.T) {
fs := objectSDK.SearchFilters{}
fs.AddObjectIDFilter(objectSDK.MatchStringEqual, parent.ID())
testSelect(t, db, cid, fs, parent.Object().Address())
testSelect(t, db, cid, fs, object.AddressOf(parent))
fs = objectSDK.SearchFilters{}
fs.AddObjectIDFilter(objectSDK.MatchStringNotEqual, parent.ID())
testSelect(t, db, cid, fs,
regular.Object().Address(),
sg.Object().Address(),
ts.Object().Address(),
object.AddressOf(regular),
object.AddressOf(sg),
object.AddressOf(ts),
)
})
}
@ -580,9 +581,9 @@ func TestDB_SelectSplitID(t *testing.T) {
cid := cidtest.ID()
child1 := generateRawObjectWithCID(t, cid)
child2 := generateRawObjectWithCID(t, cid)
child3 := generateRawObjectWithCID(t, cid)
child1 := generateObjectWithCID(t, cid)
child2 := generateObjectWithCID(t, cid)
child3 := generateObjectWithCID(t, cid)
split1 := objectSDK.NewSplitID()
split2 := objectSDK.NewSplitID()
@ -591,9 +592,9 @@ func TestDB_SelectSplitID(t *testing.T) {
child2.SetSplitID(split1)
child3.SetSplitID(split2)
require.NoError(t, putBig(db, child1.Object()))
require.NoError(t, putBig(db, child2.Object()))
require.NoError(t, putBig(db, child3.Object()))
require.NoError(t, putBig(db, child1))
require.NoError(t, putBig(db, child2))
require.NoError(t, putBig(db, child3))
t.Run("not present", func(t *testing.T) {
fs := objectSDK.SearchFilters{}
@ -605,13 +606,13 @@ func TestDB_SelectSplitID(t *testing.T) {
fs := objectSDK.SearchFilters{}
fs.AddFilter(v2object.FilterHeaderSplitID, split1.String(), objectSDK.MatchStringEqual)
testSelect(t, db, cid, fs,
child1.Object().Address(),
child2.Object().Address(),
object.AddressOf(child1),
object.AddressOf(child2),
)
fs = objectSDK.SearchFilters{}
fs.AddFilter(v2object.FilterHeaderSplitID, split2.String(), objectSDK.MatchStringEqual)
testSelect(t, db, cid, fs, child3.Object().Address())
testSelect(t, db, cid, fs, object.AddressOf(child3))
})
t.Run("empty split", func(t *testing.T) {
@ -634,12 +635,12 @@ func TestDB_SelectContainerID(t *testing.T) {
cid := cidtest.ID()
obj1 := generateRawObjectWithCID(t, cid)
err := putBig(db, obj1.Object())
obj1 := generateObjectWithCID(t, cid)
err := putBig(db, obj1)
require.NoError(t, err)
obj2 := generateRawObjectWithCID(t, cid)
err = putBig(db, obj2.Object())
obj2 := generateObjectWithCID(t, cid)
err = putBig(db, obj2)
require.NoError(t, err)
t.Run("same cid", func(t *testing.T) {
@ -647,16 +648,16 @@ func TestDB_SelectContainerID(t *testing.T) {
fs.AddObjectContainerIDFilter(objectSDK.MatchStringEqual, cid)
testSelect(t, db, cid, fs,
obj1.Object().Address(),
obj2.Object().Address(),
object.AddressOf(obj1),
object.AddressOf(obj2),
)
fs = objectSDK.SearchFilters{}
fs.AddObjectContainerIDFilter(objectSDK.MatchStringNotEqual, cid)
testSelect(t, db, cid, fs,
obj1.Object().Address(),
obj2.Object().Address(),
object.AddressOf(obj1),
object.AddressOf(obj2),
)
fs = objectSDK.SearchFilters{}

View file

@ -3,6 +3,7 @@ package meta_test
import (
"testing"
"github.com/nspcc-dev/neofs-node/pkg/core/object"
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/blobovnicza"
meta "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/metabase"
"github.com/stretchr/testify/require"
@ -11,31 +12,31 @@ import (
func TestDB_IsSmall(t *testing.T) {
db := newDB(t)
raw1 := generateRawObject(t)
raw2 := generateRawObject(t)
raw1 := generateObject(t)
raw2 := generateObject(t)
blobovniczaID := blobovnicza.ID{1, 2, 3, 4}
// check IsSmall from empty database
fetchedBlobovniczaID, err := meta.IsSmall(db, raw1.Object().Address())
fetchedBlobovniczaID, err := meta.IsSmall(db, object.AddressOf(raw1))
require.NoError(t, err)
require.Nil(t, fetchedBlobovniczaID)
// put one object with blobovniczaID
err = meta.Put(db, raw1.Object(), &blobovniczaID)
err = meta.Put(db, raw1, &blobovniczaID)
require.NoError(t, err)
// put one object without blobovniczaID
err = putBig(db, raw2.Object())
err = putBig(db, raw2)
require.NoError(t, err)
// check IsSmall for object without blobovniczaID
fetchedBlobovniczaID, err = meta.IsSmall(db, raw2.Object().Address())
fetchedBlobovniczaID, err = meta.IsSmall(db, object.AddressOf(raw2))
require.NoError(t, err)
require.Nil(t, fetchedBlobovniczaID)
// check IsSmall for object with blobovniczaID
fetchedBlobovniczaID, err = meta.IsSmall(db, raw1.Object().Address())
fetchedBlobovniczaID, err = meta.IsSmall(db, object.AddressOf(raw1))
require.NoError(t, err)
require.Equal(t, &blobovniczaID, fetchedBlobovniczaID)
}

View file

@ -80,7 +80,7 @@ func (s *Shard) refillMetabase() error {
return fmt.Errorf("could not reset metabase: %w", err)
}
return blobstor.IterateObjects(s.blobStor, func(obj *object.Object, blzID *blobovnicza.ID) error {
return blobstor.IterateObjects(s.blobStor, func(obj *objectSDK.Object, blzID *blobovnicza.ID) error {
if obj.Type() == objectSDK.TypeTombstone {
tombstone := objectSDK.NewTombstone()
@ -88,7 +88,7 @@ func (s *Shard) refillMetabase() error {
return fmt.Errorf("could not unmarshal tombstone content: %w", err)
}
tombAddr := obj.Address()
tombAddr := object.AddressOf(obj)
cid := tombAddr.ContainerID()
memberIDs := tombstone.Members()
tombMembers := make([]*addressSDK.Address, 0, len(memberIDs))

View file

@ -41,19 +41,17 @@ func TestRefillMetabase(t *testing.T) {
const objNum = 5
type objAddr struct {
obj *object.Object
obj *objectSDK.Object
addr *addressSDK.Address
}
mObjs := make(map[string]objAddr)
for i := uint64(0); i < objNum; i++ {
rawObj := objecttest.Raw()
rawObj.SetType(objectSDK.TypeRegular)
obj := objecttest.Object()
obj.SetType(objectSDK.TypeRegular)
obj := object.NewFromSDK(rawObj.Object())
addr := obj.Address()
addr := object.AddressOf(obj)
mObjs[addr.String()] = objAddr{
obj: obj,
@ -61,17 +59,15 @@ func TestRefillMetabase(t *testing.T) {
}
}
tombObjRaw := object.NewRawFrom(objecttest.Raw())
tombObjRaw.SetType(objectSDK.TypeTombstone)
tombObj := objecttest.Object()
tombObj.SetType(objectSDK.TypeTombstone)
tombstone := objecttest.Tombstone()
tombData, err := tombstone.Marshal()
require.NoError(t, err)
tombObjRaw.SetPayload(tombData)
tombObj := tombObjRaw.Object()
tombObj.SetPayload(tombData)
tombMembers := make([]*addressSDK.Address, 0, len(tombstone.Members()))
@ -93,12 +89,12 @@ func TestRefillMetabase(t *testing.T) {
_, err = sh.Put(putPrm.WithObject(tombObj))
require.NoError(t, err)
_, err = sh.Inhume(new(InhumePrm).WithTarget(tombObj.Address(), tombMembers...))
_, err = sh.Inhume(new(InhumePrm).WithTarget(object.AddressOf(tombObj), tombMembers...))
require.NoError(t, err)
var headPrm HeadPrm
checkObj := func(addr *addressSDK.Address, expObj *object.Object) {
checkObj := func(addr *addressSDK.Address, expObj *objectSDK.Object) {
res, err := sh.Head(headPrm.WithAddress(addr))
if expObj == nil {
@ -107,7 +103,7 @@ func TestRefillMetabase(t *testing.T) {
}
require.NoError(t, err)
require.Equal(t, object.NewRawFromObject(expObj).CutPayload().Object(), res.Object())
require.Equal(t, expObj.CutPayload(), res.Object())
}
checkAllObjs := func(exists bool) {
@ -133,7 +129,7 @@ func TestRefillMetabase(t *testing.T) {
}
checkAllObjs(true)
checkObj(tombObj.Address(), tombObj)
checkObj(object.AddressOf(tombObj), tombObj)
checkTombMembers(true)
err = sh.Close()
@ -155,13 +151,13 @@ func TestRefillMetabase(t *testing.T) {
defer sh.Close()
checkAllObjs(false)
checkObj(tombObj.Address(), nil)
checkObj(object.AddressOf(tombObj), nil)
checkTombMembers(false)
err = sh.refillMetabase()
require.NoError(t, err)
checkAllObjs(true)
checkObj(tombObj.Address(), tombObj)
checkObj(object.AddressOf(tombObj), tombObj)
checkTombMembers(true)
}

View file

@ -25,7 +25,7 @@ func testShardDelete(t *testing.T, hasWriteCache bool) {
cid := cidtest.ID()
obj := generateRawObjectWithCID(t, cid)
obj := generateObjectWithCID(t, cid)
addAttribute(obj, "foo", "bar")
putPrm := new(shard.PutPrm)
@ -34,11 +34,11 @@ func testShardDelete(t *testing.T, hasWriteCache bool) {
t.Run("big object", func(t *testing.T) {
addPayload(obj, 1<<20)
putPrm.WithObject(obj.Object())
getPrm.WithAddress(obj.Object().Address())
putPrm.WithObject(obj)
getPrm.WithAddress(object.AddressOf(obj))
delPrm := new(shard.DeletePrm)
delPrm.WithAddresses(obj.Object().Address())
delPrm.WithAddresses(object.AddressOf(obj))
_, err := sh.Put(putPrm)
require.NoError(t, err)
@ -57,11 +57,11 @@ func testShardDelete(t *testing.T, hasWriteCache bool) {
obj.SetID(generateOID())
addPayload(obj, 1<<5)
putPrm.WithObject(obj.Object())
getPrm.WithAddress(obj.Object().Address())
putPrm.WithObject(obj)
getPrm.WithAddress(object.AddressOf(obj))
delPrm := new(shard.DeletePrm)
delPrm.WithAddresses(obj.Object().Address())
delPrm.WithAddresses(object.AddressOf(obj))
_, err := sh.Put(putPrm)
require.NoError(t, err)

View file

@ -18,6 +18,7 @@ import (
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/shard"
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/writecache"
cidtest "github.com/nspcc-dev/neofs-sdk-go/container/id/test"
objectSDK "github.com/nspcc-dev/neofs-sdk-go/object"
addressSDK "github.com/nspcc-dev/neofs-sdk-go/object/address"
objecttest "github.com/nspcc-dev/neofs-sdk-go/object/id/test"
"github.com/stretchr/testify/require"
@ -72,7 +73,7 @@ func testDump(t *testing.T, objCount int, hasWriteCache bool) {
// Approximate object header size.
const headerSize = 400
objects := make([]*object.Object, objCount)
objects := make([]*objectSDK.Object, objCount)
for i := 0; i < objCount; i++ {
cid := cidtest.ID()
var size int
@ -88,8 +89,8 @@ func testDump(t *testing.T, objCount int, hasWriteCache bool) {
}
data := make([]byte, size)
rand.Read(data)
obj := generateRawObjectWithPayload(cid, data)
objects[i] = obj.Object()
obj := generateObjectWithPayload(cid, data)
objects[i] = obj
prm := new(shard.PutPrm).WithObject(objects[i])
_, err := sh.Put(prm)
@ -192,11 +193,11 @@ func TestStream(t *testing.T) {
defer releaseShard(sh2, t)
const objCount = 5
objects := make([]*object.Object, objCount)
objects := make([]*objectSDK.Object, objCount)
for i := 0; i < objCount; i++ {
cid := cidtest.ID()
obj := generateRawObjectWithCID(t, cid)
objects[i] = obj.Object()
obj := generateObjectWithCID(t, cid)
objects[i] = obj
prm := new(shard.PutPrm).WithObject(objects[i])
_, err := sh1.Put(prm)
@ -227,13 +228,13 @@ func TestStream(t *testing.T) {
}, time.Second, time.Millisecond)
}
func checkRestore(t *testing.T, sh *shard.Shard, prm *shard.RestorePrm, objects []*object.Object) {
func checkRestore(t *testing.T, sh *shard.Shard, prm *shard.RestorePrm, objects []*objectSDK.Object) {
res, err := sh.Restore(prm)
require.NoError(t, err)
require.Equal(t, len(objects), res.Count())
for i := range objects {
res, err := sh.Get(new(shard.GetPrm).WithAddress(objects[i].Address()))
res, err := sh.Get(new(shard.GetPrm).WithAddress(object.AddressOf(objects[i])))
require.NoError(t, err)
require.Equal(t, objects[i], res.Object())
}
@ -268,11 +269,11 @@ func TestDumpIgnoreErrors(t *testing.T) {
}
sh := newCustomShard(t, dir, true, wcOpts, bsOpts)
objects := make([]*object.Object, objCount)
objects := make([]*objectSDK.Object, objCount)
for i := 0; i < objCount; i++ {
size := (wcSmallObjectSize << (i % 4)) - headerSize
obj := generateRawObjectWithPayload(cidtest.ID(), make([]byte, size))
objects[i] = obj.Object()
obj := generateObjectWithPayload(cidtest.ID(), make([]byte, size))
objects[i] = obj
prm := new(shard.PutPrm).WithObject(objects[i])
_, err := sh.Put(prm)

View file

@ -8,13 +8,14 @@ import (
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/blobovnicza"
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/blobstor"
meta "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/metabase"
objectSDK "github.com/nspcc-dev/neofs-sdk-go/object"
addressSDK "github.com/nspcc-dev/neofs-sdk-go/object/address"
"go.uber.org/zap"
)
// storFetcher is a type to unify object fetching mechanism in `fetchObjectData`
// method. It represents generalization of `getSmall` and `getBig` methods.
type storFetcher = func(stor *blobstor.BlobStor, id *blobovnicza.ID) (*object.Object, error)
type storFetcher = func(stor *blobstor.BlobStor, id *blobovnicza.ID) (*objectSDK.Object, error)
// GetPrm groups the parameters of Get operation.
type GetPrm struct {
@ -24,7 +25,7 @@ type GetPrm struct {
// GetRes groups resulting values of Get operation.
type GetRes struct {
obj *object.Object
obj *objectSDK.Object
hasMeta bool
}
@ -47,7 +48,7 @@ func (p *GetPrm) WithIgnoreMeta(ignore bool) *GetPrm {
}
// Object returns the requested object.
func (r *GetRes) Object() *object.Object {
func (r *GetRes) Object() *objectSDK.Object {
return r.obj
}
@ -65,7 +66,7 @@ func (r *GetRes) HasMeta() bool {
func (s *Shard) Get(prm *GetPrm) (*GetRes, error) {
var big, small storFetcher
big = func(stor *blobstor.BlobStor, _ *blobovnicza.ID) (*object.Object, error) {
big = func(stor *blobstor.BlobStor, _ *blobovnicza.ID) (*objectSDK.Object, error) {
getBigPrm := new(blobstor.GetBigPrm)
getBigPrm.SetAddress(prm.addr)
@ -77,7 +78,7 @@ func (s *Shard) Get(prm *GetPrm) (*GetRes, error) {
return res.Object(), nil
}
small = func(stor *blobstor.BlobStor, id *blobovnicza.ID) (*object.Object, error) {
small = func(stor *blobstor.BlobStor, id *blobovnicza.ID) (*objectSDK.Object, error) {
getSmallPrm := new(blobstor.GetSmallPrm)
getSmallPrm.SetAddress(prm.addr)
getSmallPrm.SetBlobovniczaID(id)
@ -99,10 +100,10 @@ func (s *Shard) Get(prm *GetPrm) (*GetRes, error) {
}
// fetchObjectData looks through writeCache and blobStor to find object.
func (s *Shard) fetchObjectData(addr *addressSDK.Address, skipMeta bool, big, small storFetcher) (*object.Object, bool, error) {
func (s *Shard) fetchObjectData(addr *addressSDK.Address, skipMeta bool, big, small storFetcher) (*objectSDK.Object, bool, error) {
var (
err error
res *object.Object
res *objectSDK.Object
)
if s.hasWriteCache() {

View file

@ -31,67 +31,67 @@ func testShardGet(t *testing.T, hasWriteCache bool) {
getPrm := new(shard.GetPrm)
t.Run("small object", func(t *testing.T) {
obj := generateRawObject(t)
obj := generateObject(t)
addAttribute(obj, "foo", "bar")
addPayload(obj, 1<<5)
putPrm.WithObject(obj.Object())
putPrm.WithObject(obj)
_, err := sh.Put(putPrm)
require.NoError(t, err)
getPrm.WithAddress(obj.Object().Address())
getPrm.WithAddress(object.AddressOf(obj))
res, err := testGet(t, sh, getPrm, hasWriteCache)
require.NoError(t, err)
require.Equal(t, obj.Object(), res.Object())
require.Equal(t, obj, res.Object())
})
t.Run("big object", func(t *testing.T) {
obj := generateRawObject(t)
obj := generateObject(t)
addAttribute(obj, "foo", "bar")
obj.SetID(generateOID())
addPayload(obj, 1<<20) // big obj
putPrm.WithObject(obj.Object())
putPrm.WithObject(obj)
_, err := sh.Put(putPrm)
require.NoError(t, err)
getPrm.WithAddress(obj.Object().Address())
getPrm.WithAddress(object.AddressOf(obj))
res, err := testGet(t, sh, getPrm, hasWriteCache)
require.NoError(t, err)
require.Equal(t, obj.Object(), res.Object())
require.Equal(t, obj, res.Object())
})
t.Run("parent object", func(t *testing.T) {
obj := generateRawObject(t)
obj := generateObject(t)
addAttribute(obj, "foo", "bar")
cid := cidtest.ID()
splitID := objectSDK.NewSplitID()
parent := generateRawObjectWithCID(t, cid)
parent := generateObjectWithCID(t, cid)
addAttribute(parent, "parent", "attribute")
child := generateRawObjectWithCID(t, cid)
child.SetParent(parent.Object().SDK())
child := generateObjectWithCID(t, cid)
child.SetParent(parent)
child.SetParentID(parent.ID())
child.SetSplitID(splitID)
addPayload(child, 1<<5)
putPrm.WithObject(child.Object())
putPrm.WithObject(child)
_, err := sh.Put(putPrm)
require.NoError(t, err)
getPrm.WithAddress(child.Object().Address())
getPrm.WithAddress(object.AddressOf(child))
res, err := testGet(t, sh, getPrm, hasWriteCache)
require.NoError(t, err)
require.True(t, binaryEqual(child.Object(), res.Object()))
require.True(t, binaryEqual(child, res.Object()))
getPrm.WithAddress(parent.Object().Address())
getPrm.WithAddress(object.AddressOf(parent))
_, err = testGet(t, sh, getPrm, hasWriteCache)
@ -121,7 +121,7 @@ func testGet(t *testing.T, sh *shard.Shard, getPrm *shard.GetPrm, hasWriteCache
// binary equal is used when object contains empty lists in the structure and
// requre.Equal fails on comparing <nil> and []{} lists.
func binaryEqual(a, b *object.Object) bool {
func binaryEqual(a, b *objectSDK.Object) bool {
binaryA, err := a.Marshal()
if err != nil {
return false

View file

@ -6,6 +6,7 @@ import (
"github.com/nspcc-dev/neofs-node/pkg/core/object"
meta "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/metabase"
objectSDK "github.com/nspcc-dev/neofs-sdk-go/object"
addressSDK "github.com/nspcc-dev/neofs-sdk-go/object/address"
)
@ -17,7 +18,7 @@ type HeadPrm struct {
// HeadRes groups resulting values of Head operation.
type HeadRes struct {
obj *object.Object
obj *objectSDK.Object
}
// WithAddress is a Head option to set the address of the requested object.
@ -43,7 +44,7 @@ func (p *HeadPrm) WithRaw(raw bool) *HeadPrm {
}
// Object returns the requested object header.
func (r *HeadRes) Object() *object.Object {
func (r *HeadRes) Object() *objectSDK.Object {
return r.obj
}

View file

@ -30,39 +30,39 @@ func testShardHead(t *testing.T, hasWriteCache bool) {
headPrm := new(shard.HeadPrm)
t.Run("regular object", func(t *testing.T) {
obj := generateRawObject(t)
obj := generateObject(t)
addAttribute(obj, "foo", "bar")
putPrm.WithObject(obj.Object())
putPrm.WithObject(obj)
_, err := sh.Put(putPrm)
require.NoError(t, err)
headPrm.WithAddress(obj.Object().Address())
headPrm.WithAddress(object.AddressOf(obj))
res, err := testHead(t, sh, headPrm, hasWriteCache)
require.NoError(t, err)
require.Equal(t, obj.CutPayload().Object(), res.Object())
require.Equal(t, obj.CutPayload(), res.Object())
})
t.Run("virtual object", func(t *testing.T) {
cid := cidtest.ID()
splitID := objectSDK.NewSplitID()
parent := generateRawObjectWithCID(t, cid)
parent := generateObjectWithCID(t, cid)
addAttribute(parent, "foo", "bar")
child := generateRawObjectWithCID(t, cid)
child.SetParent(parent.Object().SDK())
child := generateObjectWithCID(t, cid)
child.SetParent(parent)
child.SetParentID(parent.ID())
child.SetSplitID(splitID)
putPrm.WithObject(child.Object())
putPrm.WithObject(child)
_, err := sh.Put(putPrm)
require.NoError(t, err)
headPrm.WithAddress(parent.Object().Address())
headPrm.WithAddress(object.AddressOf(parent))
headPrm.WithRaw(true)
var siErr *objectSDK.SplitInfoError
@ -70,12 +70,12 @@ func testShardHead(t *testing.T, hasWriteCache bool) {
_, err = testHead(t, sh, headPrm, hasWriteCache)
require.True(t, errors.As(err, &siErr))
headPrm.WithAddress(parent.Object().Address())
headPrm.WithAddress(object.AddressOf(parent))
headPrm.WithRaw(false)
head, err := sh.Head(headPrm)
require.NoError(t, err)
require.Equal(t, parent.CutPayload().Object(), head.Object())
require.Equal(t, parent.CutPayload(), head.Object())
})
}

View file

@ -25,19 +25,19 @@ func testShardInhume(t *testing.T, hasWriteCache bool) {
cid := cidtest.ID()
obj := generateRawObjectWithCID(t, cid)
obj := generateObjectWithCID(t, cid)
addAttribute(obj, "foo", "bar")
ts := generateRawObjectWithCID(t, cid)
ts := generateObjectWithCID(t, cid)
putPrm := new(shard.PutPrm)
putPrm.WithObject(obj.Object())
putPrm.WithObject(obj)
inhPrm := new(shard.InhumePrm)
inhPrm.WithTarget(ts.Object().Address(), obj.Object().Address())
inhPrm.WithTarget(object.AddressOf(ts), object.AddressOf(obj))
getPrm := new(shard.GetPrm)
getPrm.WithAddress(obj.Object().Address())
getPrm.WithAddress(object.AddressOf(obj))
_, err := sh.Put(putPrm)
require.NoError(t, err)

View file

@ -3,6 +3,7 @@ package shard_test
import (
"testing"
"github.com/nspcc-dev/neofs-node/pkg/core/object"
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/shard"
cidtest "github.com/nspcc-dev/neofs-sdk-go/container/id/test"
"github.com/stretchr/testify/require"
@ -37,17 +38,17 @@ func testShardList(t *testing.T, sh *shard.Shard) {
cid := cidtest.ID()
for j := 0; j < N; j++ {
obj := generateRawObjectWithCID(t, cid)
obj := generateObjectWithCID(t, cid)
addPayload(obj, 1<<2)
// add parent as virtual object, it must be ignored in List()
parent := generateRawObjectWithCID(t, cid)
obj.SetParentID(parent.Object().ID())
obj.SetParent(parent.Object().SDK())
parent := generateObjectWithCID(t, cid)
obj.SetParentID(parent.ID())
obj.SetParent(parent)
objs[obj.Object().Address().String()] = 0
objs[object.AddressOf(obj).String()] = 0
putPrm.WithObject(obj.Object())
putPrm.WithObject(obj)
_, err := sh.Put(putPrm)
require.NoError(t, err)

View file

@ -3,9 +3,9 @@ package shard
import (
"fmt"
"github.com/nspcc-dev/neofs-node/pkg/core/object"
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/blobstor"
meta "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/metabase"
"github.com/nspcc-dev/neofs-sdk-go/object"
"go.uber.org/zap"
)

View file

@ -1,10 +1,9 @@
package shard
import (
"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"
objectSDK "github.com/nspcc-dev/neofs-sdk-go/object"
"github.com/nspcc-dev/neofs-sdk-go/object"
addressSDK "github.com/nspcc-dev/neofs-sdk-go/object/address"
)
@ -73,7 +72,7 @@ func (r *RngRes) HasMeta() bool {
func (s *Shard) GetRange(prm *RngPrm) (*RngRes, error) {
var big, small storFetcher
rng := objectSDK.NewRange()
rng := object.NewRange()
rng.SetOffset(prm.off)
rng.SetLength(prm.ln)
@ -87,10 +86,10 @@ func (s *Shard) GetRange(prm *RngPrm) (*RngRes, error) {
return nil, err
}
obj := object.NewRaw()
obj := object.New()
obj.SetPayload(res.RangeData())
return obj.Object(), nil
return obj, nil
}
small = func(stor *blobstor.BlobStor, id *blobovnicza.ID) (*object.Object, error) {
@ -104,10 +103,10 @@ func (s *Shard) GetRange(prm *RngPrm) (*RngRes, error) {
return nil, err
}
obj := object.NewRaw()
obj := object.New()
obj.SetPayload(res.RangeData())
return obj.Object(), nil
return obj, nil
}
obj, hasMeta, err := s.fetchObjectData(prm.addr, prm.skipMeta, big, small)

View file

@ -7,7 +7,7 @@ import (
"io"
"os"
"github.com/nspcc-dev/neofs-node/pkg/core/object"
"github.com/nspcc-dev/neofs-sdk-go/object"
)
// ErrInvalidMagic is returned when dump format is invalid.

View file

@ -5,14 +5,14 @@ import (
meta "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/metabase"
cid "github.com/nspcc-dev/neofs-sdk-go/container/id"
objectSDK "github.com/nspcc-dev/neofs-sdk-go/object"
"github.com/nspcc-dev/neofs-sdk-go/object"
addressSDK "github.com/nspcc-dev/neofs-sdk-go/object/address"
)
// SelectPrm groups the parameters of Select operation.
type SelectPrm struct {
cid *cid.ID
filters objectSDK.SearchFilters
filters object.SearchFilters
}
// SelectRes groups resulting values of Select operation.
@ -30,7 +30,7 @@ func (p *SelectPrm) WithContainerID(cid *cid.ID) *SelectPrm {
}
// WithFilters is a Select option to set the object filters.
func (p *SelectPrm) WithFilters(fs objectSDK.SearchFilters) *SelectPrm {
func (p *SelectPrm) WithFilters(fs object.SearchFilters) *SelectPrm {
if p != nil {
p.filters = fs
}

View file

@ -8,7 +8,6 @@ import (
"strings"
"testing"
"github.com/nspcc-dev/neofs-node/pkg/core/object"
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/blobstor"
meta "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/metabase"
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/shard"
@ -17,7 +16,7 @@ import (
"github.com/nspcc-dev/neofs-sdk-go/checksum"
cid "github.com/nspcc-dev/neofs-sdk-go/container/id"
cidtest "github.com/nspcc-dev/neofs-sdk-go/container/id/test"
objectSDK "github.com/nspcc-dev/neofs-sdk-go/object"
"github.com/nspcc-dev/neofs-sdk-go/object"
oidSDK "github.com/nspcc-dev/neofs-sdk-go/object/id"
"github.com/nspcc-dev/neofs-sdk-go/owner"
ownertest "github.com/nspcc-dev/neofs-sdk-go/owner/test"
@ -73,16 +72,16 @@ func releaseShard(s *shard.Shard, t testing.TB) {
os.RemoveAll(strings.Split(t.Name(), string(os.PathSeparator))[0])
}
func generateRawObject(t *testing.T) *object.RawObject {
return generateRawObjectWithCID(t, cidtest.ID())
func generateObject(t *testing.T) *object.Object {
return generateObjectWithCID(t, cidtest.ID())
}
func generateRawObjectWithCID(t *testing.T, cid *cid.ID) *object.RawObject {
func generateObjectWithCID(t *testing.T, cid *cid.ID) *object.Object {
data := owner.PublicKeyToIDBytes(&test.DecodeKey(-1).PublicKey)
return generateRawObjectWithPayload(cid, data)
return generateObjectWithPayload(cid, data)
}
func generateRawObjectWithPayload(cid *cid.ID, data []byte) *object.RawObject {
func generateObjectWithPayload(cid *cid.ID, data []byte) *object.Object {
version := version.New()
version.SetMajor(2)
version.SetMinor(1)
@ -93,7 +92,7 @@ func generateRawObjectWithPayload(cid *cid.ID, data []byte) *object.RawObject {
csumTZ := new(checksum.Checksum)
csumTZ.SetTillichZemor(tz.Sum(csum.Sum()))
obj := object.NewRaw()
obj := object.New()
obj.SetID(generateOID())
obj.SetOwnerID(ownertest.ID())
obj.SetContainerID(cid)
@ -105,8 +104,8 @@ func generateRawObjectWithPayload(cid *cid.ID, data []byte) *object.RawObject {
return obj
}
func addAttribute(obj *object.RawObject, key, val string) {
attr := objectSDK.NewAttribute()
func addAttribute(obj *object.Object, key, val string) {
attr := object.NewAttribute()
attr.SetKey(key)
attr.SetValue(val)
@ -115,7 +114,7 @@ func addAttribute(obj *object.RawObject, key, val string) {
obj.SetAttributes(attrs...)
}
func addPayload(obj *object.RawObject, size int) {
func addPayload(obj *object.Object, size int) {
buf := make([]byte, size)
_, _ = rand.Read(buf)

View file

@ -8,6 +8,7 @@ import (
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/shard"
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/writecache"
cidtest "github.com/nspcc-dev/neofs-sdk-go/container/id/test"
objectSDK "github.com/nspcc-dev/neofs-sdk-go/object"
"github.com/stretchr/testify/require"
)
@ -17,16 +18,16 @@ func TestWriteCacheObjectLoss(t *testing.T) {
objCount = 100
)
objects := make([]*object.Object, objCount)
objects := make([]*objectSDK.Object, objCount)
for i := range objects {
size := smallSize
//if i%2 == 0 {
// if i%2 == 0 {
size = smallSize / 2
//}
// }
data := make([]byte, size)
rand.Read(data)
objects[i] = generateRawObjectWithPayload(cidtest.ID(), data).Object()
objects[i] = generateObjectWithPayload(cidtest.ID(), data)
}
dir := t.TempDir()
@ -46,7 +47,7 @@ func TestWriteCacheObjectLoss(t *testing.T) {
defer releaseShard(sh, t)
for i := range objects {
_, err := sh.Get(new(shard.GetPrm).WithAddress(objects[i].Address()))
_, err := sh.Get(new(shard.GetPrm).WithAddress(object.AddressOf(objects[i])))
require.NoError(t, err, i)
}
}

View file

@ -1,12 +1,12 @@
package util
import (
objectSDK "github.com/nspcc-dev/neofs-sdk-go/object"
"github.com/nspcc-dev/neofs-sdk-go/object"
)
// MergeSplitInfo ignores conflicts and rewrites `to` with non empty values
// from `from`.
func MergeSplitInfo(from, to *objectSDK.SplitInfo) *objectSDK.SplitInfo {
func MergeSplitInfo(from, to *object.SplitInfo) *object.SplitInfo {
to.SetSplitID(from.SplitID()) // overwrite SplitID and ignore conflicts
if lp := from.LastPart(); lp != nil {

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"
)

View file

@ -9,10 +9,9 @@ import (
"github.com/nspcc-dev/neo-go/pkg/crypto/keys"
objectV2 "github.com/nspcc-dev/neofs-api-go/v2/object"
"github.com/nspcc-dev/neofs-api-go/v2/session"
"github.com/nspcc-dev/neofs-node/pkg/core/object"
cidtest "github.com/nspcc-dev/neofs-sdk-go/container/id/test"
eaclSDK "github.com/nspcc-dev/neofs-sdk-go/eacl"
objectSDK "github.com/nspcc-dev/neofs-sdk-go/object"
"github.com/nspcc-dev/neofs-sdk-go/object"
objectSDKAddress "github.com/nspcc-dev/neofs-sdk-go/object/address"
objectSDKID "github.com/nspcc-dev/neofs-sdk-go/object/id"
"github.com/stretchr/testify/require"
@ -86,11 +85,11 @@ func TestHeadRequest(t *testing.T) {
meta.SetXHeaders(xHdrs)
obj := object.NewRaw()
obj := object.New()
attrKey := "attr_key"
attrVal := "attr_val"
attr := objectSDK.NewAttribute()
attr := object.NewAttribute()
attr.SetKey(attrKey)
attr.SetValue(attrVal)
obj.SetAttributes(attr)
@ -113,7 +112,7 @@ func TestHeadRequest(t *testing.T) {
lStorage := &testLocalStorage{
t: t,
expAddr: addr,
obj: obj.Object(),
obj: obj,
}
cid := addr.ContainerID()

View file

@ -7,9 +7,9 @@ import (
objectV2 "github.com/nspcc-dev/neofs-api-go/v2/object"
"github.com/nspcc-dev/neofs-api-go/v2/refs"
"github.com/nspcc-dev/neofs-api-go/v2/session"
"github.com/nspcc-dev/neofs-node/pkg/core/object"
cid "github.com/nspcc-dev/neofs-sdk-go/container/id"
eaclSDK "github.com/nspcc-dev/neofs-sdk-go/eacl"
"github.com/nspcc-dev/neofs-sdk-go/object"
objectSDKAddress "github.com/nspcc-dev/neofs-sdk-go/object/address"
objectSDKID "github.com/nspcc-dev/neofs-sdk-go/object/id"
sessionSDK "github.com/nspcc-dev/neofs-sdk-go/session"

View file

@ -3,8 +3,8 @@ package v2
import (
"io"
"github.com/nspcc-dev/neofs-node/pkg/core/object"
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/engine"
"github.com/nspcc-dev/neofs-sdk-go/object"
objectSDKAddress "github.com/nspcc-dev/neofs-sdk-go/object/address"
)

View file

@ -4,9 +4,9 @@ import (
"strconv"
"github.com/nspcc-dev/neofs-api-go/v2/acl"
"github.com/nspcc-dev/neofs-node/pkg/core/object"
cid "github.com/nspcc-dev/neofs-sdk-go/container/id"
eaclSDK "github.com/nspcc-dev/neofs-sdk-go/eacl"
"github.com/nspcc-dev/neofs-sdk-go/object"
objectSDKAddress "github.com/nspcc-dev/neofs-sdk-go/object/address"
objectSDKID "github.com/nspcc-dev/neofs-sdk-go/object/id"
"github.com/nspcc-dev/neofs-sdk-go/owner"
@ -42,12 +42,12 @@ func u64Value(v uint64) string {
func headersFromObject(obj *object.Object, addr *objectSDKAddress.Address) []eaclSDK.Header {
var count int
for obj := obj; obj != nil; obj = obj.GetParent() {
for obj := obj; obj != nil; obj = obj.Parent() {
count += 9 + len(obj.Attributes())
}
res := make([]eaclSDK.Header, 0, count)
for ; obj != nil; obj = obj.GetParent() {
for ; obj != nil; obj = obj.Parent() {
res = append(res,
cidHeader(addr.ContainerID()),
// owner ID

View file

@ -5,11 +5,10 @@ import (
"strconv"
objectV2 "github.com/nspcc-dev/neofs-api-go/v2/object"
"github.com/nspcc-dev/neofs-node/pkg/core/object"
"github.com/nspcc-dev/neofs-node/pkg/services/object/util"
"github.com/nspcc-dev/neofs-node/pkg/util/logger"
cid "github.com/nspcc-dev/neofs-sdk-go/container/id"
objectSDK "github.com/nspcc-dev/neofs-sdk-go/object"
"github.com/nspcc-dev/neofs-sdk-go/object"
addressSDK "github.com/nspcc-dev/neofs-sdk-go/object/address"
oidSDK "github.com/nspcc-dev/neofs-sdk-go/object/id"
"go.uber.org/zap"
@ -31,11 +30,11 @@ type execCtx struct {
log *logger.Logger
tombstone *objectSDK.Tombstone
tombstone *object.Tombstone
splitInfo *objectSDK.SplitInfo
splitInfo *object.SplitInfo
tombstoneObj *object.RawObject
tombstoneObj *object.Object
}
const (
@ -240,13 +239,13 @@ func (exec *execCtx) initTombstoneObject() bool {
tombOwnerID = exec.svc.netInfo.LocalNodeID()
}
exec.tombstoneObj = object.NewRaw()
exec.tombstoneObj = object.New()
exec.tombstoneObj.SetContainerID(exec.containerID())
exec.tombstoneObj.SetOwnerID(tombOwnerID)
exec.tombstoneObj.SetType(objectSDK.TypeTombstone)
exec.tombstoneObj.SetType(object.TypeTombstone)
exec.tombstoneObj.SetPayload(payload)
a := objectSDK.NewAttribute()
a := object.NewAttribute()
a.SetKey(objectV2.SysAttributeExpEpoch)
a.SetValue(strconv.FormatUint(exec.tombstone.ExpirationEpoch(), 10))

View file

@ -1,7 +1,7 @@
package deletesvc
import (
objectSDK "github.com/nspcc-dev/neofs-sdk-go/object"
"github.com/nspcc-dev/neofs-sdk-go/object"
oidSDK "github.com/nspcc-dev/neofs-sdk-go/object/id"
"go.uber.org/zap"
)
@ -39,7 +39,7 @@ func (exec *execCtx) formTombstone() (ok bool) {
return false
}
exec.tombstone = objectSDK.NewTombstone()
exec.tombstone = object.NewTombstone()
exec.tombstone.SetExpirationEpoch(
exec.svc.netInfo.CurrentEpoch() + tsLifetime,
)

View file

@ -6,7 +6,7 @@ import (
putsvc "github.com/nspcc-dev/neofs-node/pkg/services/object/put"
searchsvc "github.com/nspcc-dev/neofs-node/pkg/services/object/search"
"github.com/nspcc-dev/neofs-node/pkg/util/logger"
objectSDK "github.com/nspcc-dev/neofs-sdk-go/object"
"github.com/nspcc-dev/neofs-sdk-go/object"
oidSDK "github.com/nspcc-dev/neofs-sdk-go/object/id"
"github.com/nspcc-dev/neofs-sdk-go/owner"
"go.uber.org/zap"
@ -38,7 +38,7 @@ type cfg struct {
header interface {
// must return (nil, nil) for PHY objects
splitInfo(*execCtx) (*objectSDK.SplitInfo, error)
splitInfo(*execCtx) (*object.SplitInfo, error)
children(*execCtx) ([]*oidSDK.ID, error)

View file

@ -3,12 +3,11 @@ package deletesvc
import (
"errors"
"github.com/nspcc-dev/neofs-node/pkg/core/object"
getsvc "github.com/nspcc-dev/neofs-node/pkg/services/object/get"
putsvc "github.com/nspcc-dev/neofs-node/pkg/services/object/put"
searchsvc "github.com/nspcc-dev/neofs-node/pkg/services/object/search"
"github.com/nspcc-dev/neofs-node/pkg/services/object_manager/placement"
objectSDK "github.com/nspcc-dev/neofs-sdk-go/object"
"github.com/nspcc-dev/neofs-sdk-go/object"
addressSDK "github.com/nspcc-dev/neofs-sdk-go/object/address"
oidSDK "github.com/nspcc-dev/neofs-sdk-go/object/id"
)
@ -40,10 +39,10 @@ func (w *headSvcWrapper) headAddress(exec *execCtx, addr *addressSDK.Address) (*
return wr.Object(), nil
}
func (w *headSvcWrapper) splitInfo(exec *execCtx) (*objectSDK.SplitInfo, error) {
func (w *headSvcWrapper) splitInfo(exec *execCtx) (*object.SplitInfo, error) {
_, err := w.headAddress(exec, exec.address())
var errSplitInfo *objectSDK.SplitInfoError
var errSplitInfo *object.SplitInfoError
switch {
case err == nil:
@ -78,8 +77,8 @@ func (w *headSvcWrapper) previous(exec *execCtx, id *oidSDK.ID) (*oidSDK.ID, err
}
func (w *searchSvcWrapper) splitMembers(exec *execCtx) ([]*oidSDK.ID, error) {
fs := objectSDK.SearchFilters{}
fs.AddSplitIDFilter(objectSDK.MatchStringEqual, exec.splitInfo.SplitID())
fs := object.SearchFilters{}
fs.AddSplitIDFilter(object.MatchStringEqual, exec.splitInfo.SplitID())
wr := new(simpleIDWriter)

View file

@ -71,7 +71,7 @@ func (exec *execCtx) initFromChild(id *oidSDK.ID) (prev *oidSDK.ID, children []*
return
}
par := child.GetParent()
par := child.Parent()
if par == nil {
exec.status = statusUndefined
@ -115,7 +115,7 @@ func (exec *execCtx) initFromChild(id *oidSDK.ID) (prev *oidSDK.ID, children []*
payload = child.Payload()
}
object.NewRawFromObject(exec.collectedObject).SetPayload(payload)
exec.collectedObject.SetPayload(payload)
return child.PreviousID(), child.Children()
}

View file

@ -34,7 +34,7 @@ type execCtx struct {
log *logger.Logger
collectedObject *object.Object
collectedObject *objectSDK.Object
curOff uint64
@ -99,9 +99,9 @@ func (exec execCtx) address() *addressSDK.Address {
return exec.prm.addr
}
func (exec execCtx) isChild(obj *object.Object) bool {
par := obj.GetParent()
return par != nil && equalAddresses(exec.address(), par.Address())
func (exec execCtx) isChild(obj *objectSDK.Object) bool {
par := obj.Parent()
return par != nil && equalAddresses(exec.address(), object.AddressOf(par))
}
func (exec execCtx) key() (*ecdsa.PrivateKey, error) {
@ -178,7 +178,7 @@ func (exec *execCtx) generateTraverser(addr *addressSDK.Address) (*placement.Tra
}
}
func (exec *execCtx) getChild(id *oidSDK.ID, rng *objectSDK.Range, withHdr bool) (*object.Object, bool) {
func (exec *execCtx) getChild(id *oidSDK.ID, rng *objectSDK.Range, withHdr bool) (*objectSDK.Object, bool) {
w := NewSimpleObjectWriter()
p := exec.prm
@ -207,7 +207,7 @@ func (exec *execCtx) getChild(id *oidSDK.ID, rng *objectSDK.Range, withHdr bool)
return child, ok
}
func (exec *execCtx) headChild(id *oidSDK.ID) (*object.Object, bool) {
func (exec *execCtx) headChild(id *oidSDK.ID) (*objectSDK.Object, bool) {
childAddr := addressSDK.NewAddress()
childAddr.SetContainerID(exec.containerID())
childAddr.SetObjectID(id)
@ -288,7 +288,7 @@ func (exec *execCtx) writeCollectedHeader() bool {
}
err := exec.prm.objWriter.WriteHeader(
object.NewRawFromObject(exec.collectedObject).CutPayload().Object(),
exec.collectedObject.CutPayload(),
)
switch {
@ -307,7 +307,7 @@ func (exec *execCtx) writeCollectedHeader() bool {
return exec.status == statusOK
}
func (exec *execCtx) writeObjectPayload(obj *object.Object) bool {
func (exec *execCtx) writeObjectPayload(obj *objectSDK.Object) bool {
if exec.headOnly() {
return true
}

View file

@ -4,7 +4,7 @@ import (
"context"
"github.com/nspcc-dev/neofs-node/pkg/util"
objectSDK "github.com/nspcc-dev/neofs-sdk-go/object"
"github.com/nspcc-dev/neofs-sdk-go/object"
"go.uber.org/zap"
)
@ -69,7 +69,7 @@ func (s *Service) get(ctx context.Context, prm commonPrm, opts ...execOption) st
prm: RangePrm{
commonPrm: prm,
},
infoSplit: objectSDK.NewSplitInfo(),
infoSplit: object.NewSplitInfo(),
}
for i := range opts {

View file

@ -30,7 +30,7 @@ type testStorage struct {
virtual map[string]*objectSDK.SplitInfo
phy map[string]*object.Object
phy map[string]*objectSDK.Object
}
type testTraverserGenerator struct {
@ -48,7 +48,7 @@ type testClientCache struct {
type testClient struct {
results map[string]struct {
obj *object.RawObject
obj *objectSDK.Object
err error
}
}
@ -63,7 +63,7 @@ func newTestStorage() *testStorage {
return &testStorage{
inhumed: make(map[string]struct{}),
virtual: make(map[string]*objectSDK.SplitInfo),
phy: make(map[string]*object.Object),
phy: make(map[string]*objectSDK.Object),
}
}
@ -97,7 +97,7 @@ func (c *testClientCache) get(info client.NodeInfo) (getClient, error) {
func newTestClient() *testClient {
return &testClient{
results: map[string]struct {
obj *object.RawObject
obj *objectSDK.Object
err error
}{},
}
@ -113,20 +113,20 @@ func (c *testClient) getObject(exec *execCtx, _ client.NodeInfo) (*objectSDK.Obj
return nil, v.err
}
return cutToRange(v.obj.Object(), exec.ctxRange()).SDK(), nil
return cutToRange(v.obj, exec.ctxRange()), nil
}
func (c *testClient) addResult(addr *addressSDK.Address, obj *object.RawObject, err error) {
func (c *testClient) addResult(addr *addressSDK.Address, obj *objectSDK.Object, err error) {
c.results[addr.String()] = struct {
obj *object.RawObject
obj *objectSDK.Object
err error
}{obj: obj, err: err}
}
func (s *testStorage) get(exec *execCtx) (*object.Object, error) {
func (s *testStorage) get(exec *execCtx) (*objectSDK.Object, error) {
var (
ok bool
obj *object.Object
obj *objectSDK.Object
sAddr = exec.address().String()
)
@ -145,26 +145,24 @@ func (s *testStorage) get(exec *execCtx) (*object.Object, error) {
return nil, object.ErrNotFound
}
func cutToRange(o *object.Object, rng *objectSDK.Range) *object.Object {
obj := object.NewRawFromObject(o)
func cutToRange(o *objectSDK.Object, rng *objectSDK.Range) *objectSDK.Object {
if rng == nil {
return obj.Object()
return o
}
from := rng.GetOffset()
to := from + rng.GetLength()
payload := obj.Payload()
payload := o.Payload()
obj = obj.CutPayload()
obj.SetPayload(payload[from:to])
o = o.CutPayload()
o.SetPayload(payload[from:to])
return obj.Object()
return o
}
func (s *testStorage) addPhy(addr *addressSDK.Address, obj *object.RawObject) {
s.phy[addr.String()] = obj.Object()
func (s *testStorage) addPhy(addr *addressSDK.Address, obj *objectSDK.Object) {
s.phy[addr.String()] = obj
}
func (s *testStorage) addVirtual(addr *addressSDK.Address, info *objectSDK.SplitInfo) {
@ -196,8 +194,8 @@ func generateAddress() *addressSDK.Address {
return addr
}
func generateObject(addr *addressSDK.Address, prev *oidSDK.ID, payload []byte, children ...*oidSDK.ID) *object.RawObject {
obj := object.NewRaw()
func generateObject(addr *addressSDK.Address, prev *oidSDK.ID, payload []byte, children ...*oidSDK.ID) *objectSDK.Object {
obj := objectSDK.New()
obj.SetContainerID(addr.ContainerID())
obj.SetID(addr.ObjectID())
obj.SetPayload(payload)
@ -277,7 +275,7 @@ func TestGetLocalOnly(t *testing.T) {
require.NoError(t, err)
require.Equal(t, obj.Object(), w.Object())
require.Equal(t, obj, w.Object())
w = NewSimpleObjectWriter()
@ -294,7 +292,7 @@ func TestGetLocalOnly(t *testing.T) {
err = svc.Head(ctx, headPrm)
require.NoError(t, err)
require.Equal(t, obj.CutPayload().Object(), w.Object())
require.Equal(t, obj.CutPayload(), w.Object())
})
t.Run("INHUMED", func(t *testing.T) {
@ -429,14 +427,14 @@ func testNodeMatrix(t testing.TB, dim []int) ([]netmap.Nodes, [][]string) {
return mNodes, mAddr
}
func generateChain(ln int, cid *cid.ID) ([]*object.RawObject, []*oidSDK.ID, []byte) {
func generateChain(ln int, cid *cid.ID) ([]*objectSDK.Object, []*oidSDK.ID, []byte) {
curID := generateID()
var prevID *oidSDK.ID
addr := addressSDK.NewAddress()
addr.SetContainerID(cid)
res := make([]*object.RawObject, 0, ln)
res := make([]*objectSDK.Object, 0, ln)
ids := make([]*oidSDK.ID, 0, ln)
payload := make([]byte, 0, ln*10)
@ -560,13 +558,13 @@ func TestGetRemoteSmall(t *testing.T) {
err := svc.Get(ctx, p)
require.NoError(t, err)
require.Equal(t, obj.Object(), w.Object())
require.Equal(t, obj, w.Object())
*c1, *c2 = *c2, *c1
err = svc.Get(ctx, p)
require.NoError(t, err)
require.Equal(t, obj.Object(), w.Object())
require.Equal(t, obj, w.Object())
w = NewSimpleObjectWriter()
rngPrm := newRngPrm(false, w, payloadSz/3, payloadSz/3)
@ -582,7 +580,7 @@ func TestGetRemoteSmall(t *testing.T) {
err = svc.Head(ctx, headPrm)
require.NoError(t, err)
require.Equal(t, obj.CutPayload().Object(), w.Object())
require.Equal(t, obj.CutPayload(), w.Object())
})
t.Run("INHUMED", func(t *testing.T) {
@ -758,7 +756,7 @@ func TestGetRemoteSmall(t *testing.T) {
linkingObj := generateObject(linkAddr, nil, nil, childIDs...)
linkingObj.SetParentID(addr.ObjectID())
linkingObj.SetParent(srcObj.Object().SDK())
linkingObj.SetParent(srcObj)
child1Addr := addressSDK.NewAddress()
child1Addr.SetContainerID(cid)
@ -826,7 +824,7 @@ func TestGetRemoteSmall(t *testing.T) {
children, childIDs, payload := generateChain(2, cid)
srcObj.SetPayload(payload)
srcObj.SetPayloadSize(uint64(len(payload)))
children[len(children)-1].SetParent(srcObj.Object().SDK())
children[len(children)-1].SetParent(srcObj)
linkAddr := addressSDK.NewAddress()
linkAddr.SetContainerID(cid)
@ -834,7 +832,7 @@ func TestGetRemoteSmall(t *testing.T) {
linkingObj := generateObject(linkAddr, nil, nil, childIDs...)
linkingObj.SetParentID(addr.ObjectID())
linkingObj.SetParent(srcObj.Object().SDK())
linkingObj.SetParent(srcObj)
child1Addr := addressSDK.NewAddress()
child1Addr.SetContainerID(cid)
@ -881,7 +879,7 @@ func TestGetRemoteSmall(t *testing.T) {
err := svc.Get(ctx, p)
require.NoError(t, err)
require.Equal(t, srcObj.Object(), w.Object())
require.Equal(t, srcObj, w.Object())
w = NewSimpleObjectWriter()
payloadSz := srcObj.PayloadSize()
@ -972,9 +970,9 @@ func TestGetRemoteSmall(t *testing.T) {
rightObj := children[len(children)-1]
rightObj.SetParentID(addr.ObjectID())
rightObj.SetParent(srcObj.Object().SDK())
rightObj.SetParent(srcObj)
preRightAddr := children[len(children)-2].Object().Address()
preRightAddr := object.AddressOf(children[len(children)-2])
c1 := newTestClient()
c1.addResult(addr, nil, errors.New("any error"))
@ -1037,20 +1035,20 @@ func TestGetRemoteSmall(t *testing.T) {
rightObj.SetID(splitInfo.LastPart())
rightObj.SetParentID(addr.ObjectID())
rightObj.SetParent(srcObj.Object().SDK())
rightObj.SetParent(srcObj)
c1 := newTestClient()
c1.addResult(addr, nil, errors.New("any error"))
for i := range children {
c1.addResult(children[i].Object().Address(), nil, errors.New("any error"))
c1.addResult(object.AddressOf(children[i]), nil, errors.New("any error"))
}
c2 := newTestClient()
c2.addResult(addr, nil, objectSDK.NewSplitInfoError(splitInfo))
for i := range children {
c2.addResult(children[i].Object().Address(), children[i], nil)
c2.addResult(object.AddressOf(children[i]), children[i], nil)
}
builder := &testPlacementBuilder{
@ -1060,7 +1058,7 @@ func TestGetRemoteSmall(t *testing.T) {
builder.vectors[addr.String()] = ns
for i := range children {
builder.vectors[children[i].Object().Address().String()] = ns
builder.vectors[object.AddressOf(children[i]).String()] = ns
}
svc := newSvc(builder, &testClientCache{
@ -1079,7 +1077,7 @@ func TestGetRemoteSmall(t *testing.T) {
err := svc.Get(ctx, p)
require.NoError(t, err)
require.Equal(t, srcObj.Object(), w.Object())
require.Equal(t, srcObj, w.Object())
w = NewSimpleObjectWriter()
payloadSz := srcObj.PayloadSize()
@ -1188,7 +1186,7 @@ func TestGetFromPastEpoch(t *testing.T) {
err = svc.Get(ctx, p)
require.NoError(t, err)
require.Equal(t, obj.Object(), w.Object())
require.Equal(t, obj, w.Object())
rp := RangePrm{}
rp.SetChunkWriter(w)
@ -1230,5 +1228,5 @@ func TestGetFromPastEpoch(t *testing.T) {
err = svc.Head(ctx, hp)
require.NoError(t, err)
require.Equal(t, obj.CutPayload().Object(), w.Object())
require.Equal(t, obj.CutPayload(), w.Object())
}

View file

@ -4,9 +4,8 @@ import (
"hash"
coreclient "github.com/nspcc-dev/neofs-node/pkg/core/client"
"github.com/nspcc-dev/neofs-node/pkg/core/object"
"github.com/nspcc-dev/neofs-node/pkg/services/object/util"
objectSDK "github.com/nspcc-dev/neofs-sdk-go/object"
"github.com/nspcc-dev/neofs-sdk-go/object"
addressSDK "github.com/nspcc-dev/neofs-sdk-go/object/address"
)
@ -19,7 +18,7 @@ type Prm struct {
type RangePrm struct {
commonPrm
rng *objectSDK.Range
rng *object.Range
}
// RangeHashPrm groups parameters of GetRange service call.
@ -28,12 +27,12 @@ type RangeHashPrm struct {
hashGen func() hash.Hash
rngs []*objectSDK.Range
rngs []*object.Range
salt []byte
}
type RequestForwarder func(coreclient.NodeInfo, coreclient.MultiAddressClient) (*objectSDK.Object, error)
type RequestForwarder func(coreclient.NodeInfo, coreclient.MultiAddressClient) (*object.Object, error)
// HeadPrm groups parameters of Head service call.
type HeadPrm struct {
@ -83,12 +82,12 @@ func (p *RangePrm) SetChunkWriter(w ChunkWriter) {
}
// SetRange sets range of the requested payload data.
func (p *RangePrm) SetRange(rng *objectSDK.Range) {
func (p *RangePrm) SetRange(rng *object.Range) {
p.rng = rng
}
// SetRangeList sets list of object payload ranges.
func (p *RangeHashPrm) SetRangeList(rngs []*objectSDK.Range) {
func (p *RangeHashPrm) SetRangeList(rngs []*object.Range) {
p.rngs = rngs
}

View file

@ -33,7 +33,7 @@ func (exec *execCtx) processNode(ctx context.Context, info client.NodeInfo) bool
case err == nil:
exec.status = statusOK
exec.err = nil
exec.collectedObject = object.NewFromSDK(obj)
exec.collectedObject = obj
exec.writeCollectedObject()
case errors.Is(err, object.ErrAlreadyRemoved):
exec.status = statusINHUMED

View file

@ -5,12 +5,11 @@ import (
"github.com/nspcc-dev/neofs-node/pkg/core/client"
"github.com/nspcc-dev/neofs-node/pkg/core/netmap"
"github.com/nspcc-dev/neofs-node/pkg/core/object"
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/engine"
"github.com/nspcc-dev/neofs-node/pkg/services/object/util"
"github.com/nspcc-dev/neofs-node/pkg/services/object_manager/placement"
"github.com/nspcc-dev/neofs-node/pkg/util/logger"
objectSDK "github.com/nspcc-dev/neofs-sdk-go/object"
"github.com/nspcc-dev/neofs-sdk-go/object"
addressSDK "github.com/nspcc-dev/neofs-sdk-go/object/address"
"github.com/nspcc-dev/neofs-sdk-go/session"
"go.uber.org/zap"
@ -25,7 +24,7 @@ type Service struct {
type Option func(*cfg)
type getClient interface {
getObject(*execCtx, client.NodeInfo) (*objectSDK.Object, error)
getObject(*execCtx, client.NodeInfo) (*object.Object, error)
}
type cfg struct {

View file

@ -5,15 +5,14 @@ import (
coreclient "github.com/nspcc-dev/neofs-node/pkg/core/client"
"github.com/nspcc-dev/neofs-node/pkg/core/netmap"
"github.com/nspcc-dev/neofs-node/pkg/core/object"
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/engine"
internal "github.com/nspcc-dev/neofs-node/pkg/services/object/internal/client"
internalclient "github.com/nspcc-dev/neofs-node/pkg/services/object/internal/client"
objectSDK "github.com/nspcc-dev/neofs-sdk-go/object"
"github.com/nspcc-dev/neofs-sdk-go/object"
)
type SimpleObjectWriter struct {
obj *object.RawObject
obj *object.Object
pld []byte
}
@ -48,12 +47,12 @@ type nmSrcWrapper struct {
func NewSimpleObjectWriter() *SimpleObjectWriter {
return &SimpleObjectWriter{
obj: object.NewRaw(),
obj: object.New(),
}
}
func (s *SimpleObjectWriter) WriteHeader(obj *object.Object) error {
s.obj = object.NewRawFromObject(obj)
s.obj = obj
s.pld = make([]byte, 0, obj.PayloadSize())
@ -70,7 +69,7 @@ func (s *SimpleObjectWriter) Object() *object.Object {
s.obj.SetPayload(s.pld)
}
return s.obj.Object()
return s.obj
}
func (c *clientCacheWrapper) get(info coreclient.NodeInfo) (getClient, error) {
@ -84,7 +83,7 @@ func (c *clientCacheWrapper) get(info coreclient.NodeInfo) (getClient, error) {
}, nil
}
func (c *clientWrapper) getObject(exec *execCtx, info coreclient.NodeInfo) (*objectSDK.Object, error) {
func (c *clientWrapper) getObject(exec *execCtx, info coreclient.NodeInfo) (*object.Object, error) {
if exec.isForwardingEnabled() {
return exec.prm.forwarder(info, c.client)
}
@ -211,11 +210,11 @@ func (w *partWriter) WriteHeader(o *object.Object) error {
return w.headWriter.WriteHeader(o)
}
func payloadOnlyObject(payload []byte) *objectSDK.Object {
rawObj := object.NewRaw()
rawObj.SetPayload(payload)
func payloadOnlyObject(payload []byte) *object.Object {
obj := object.New()
obj.SetPayload(payload)
return rawObj.Object().SDK()
return obj
}
func (h *hasherWrapper) WriteChunk(p []byte) error {

View file

@ -2,8 +2,8 @@ package getsvc
import (
objectV2 "github.com/nspcc-dev/neofs-api-go/v2/object"
"github.com/nspcc-dev/neofs-node/pkg/core/object"
objectSvc "github.com/nspcc-dev/neofs-node/pkg/services/object"
"github.com/nspcc-dev/neofs-sdk-go/object"
)
type streamObjectWriter struct {

View file

@ -16,13 +16,12 @@ import (
"github.com/nspcc-dev/neofs-api-go/v2/session"
"github.com/nspcc-dev/neofs-api-go/v2/signature"
"github.com/nspcc-dev/neofs-node/pkg/core/client"
"github.com/nspcc-dev/neofs-node/pkg/core/object"
"github.com/nspcc-dev/neofs-node/pkg/network"
objectSvc "github.com/nspcc-dev/neofs-node/pkg/services/object"
getsvc "github.com/nspcc-dev/neofs-node/pkg/services/object/get"
"github.com/nspcc-dev/neofs-node/pkg/services/object/internal"
"github.com/nspcc-dev/neofs-node/pkg/services/object/util"
objectSDK "github.com/nspcc-dev/neofs-sdk-go/object"
"github.com/nspcc-dev/neofs-sdk-go/object"
addressSDK "github.com/nspcc-dev/neofs-sdk-go/object/address"
signature2 "github.com/nspcc-dev/neofs-sdk-go/util/signature"
"github.com/nspcc-dev/tzhash/tz"
@ -49,7 +48,7 @@ func (s *Service) toPrm(req *objectV2.GetRequest, stream objectSvc.GetObjectStre
if !commonPrm.LocalOnly() {
var onceResign sync.Once
p.SetRequestForwarder(groupAddressRequestForwarder(func(addr network.Address, c client.MultiAddressClient, pubkey []byte) (*objectSDK.Object, error) {
p.SetRequestForwarder(groupAddressRequestForwarder(func(addr network.Address, c client.MultiAddressClient, pubkey []byte) (*object.Object, error) {
var err error
key, err := s.keyStorage.GetKey(nil)
@ -139,15 +138,15 @@ func (s *Service) toPrm(req *objectV2.GetRequest, stream objectSvc.GetObjectStre
payload = append(payload, v.GetChunk()...)
case *objectV2.SplitInfo:
si := objectSDK.NewSplitInfoFromV2(v)
return nil, objectSDK.NewSplitInfoError(si)
si := object.NewSplitInfoFromV2(v)
return nil, object.NewSplitInfoError(si)
}
}
obj.SetPayload(payload)
// convert the object
return objectSDK.NewFromV2(obj), nil
return object.NewFromV2(obj), nil
}))
}
@ -169,7 +168,7 @@ func (s *Service) toRangePrm(req *objectV2.GetRangeRequest, stream objectSvc.Get
p.WithAddress(addressSDK.NewAddressFromV2(body.GetAddress()))
p.WithRawFlag(body.GetRaw())
p.SetChunkWriter(&streamObjectRangeWriter{stream})
p.SetRange(objectSDK.NewRangeFromV2(body.GetRange()))
p.SetRange(object.NewRangeFromV2(body.GetRange()))
if !commonPrm.LocalOnly() {
var onceResign sync.Once
@ -179,7 +178,7 @@ func (s *Service) toRangePrm(req *objectV2.GetRangeRequest, stream objectSvc.Get
return nil, err
}
p.SetRequestForwarder(groupAddressRequestForwarder(func(addr network.Address, c client.MultiAddressClient, pubkey []byte) (*objectSDK.Object, error) {
p.SetRequestForwarder(groupAddressRequestForwarder(func(addr network.Address, c client.MultiAddressClient, pubkey []byte) (*object.Object, error) {
var err error
// once compose and resign forwarding request
@ -239,16 +238,16 @@ func (s *Service) toRangePrm(req *objectV2.GetRangeRequest, stream objectSvc.Get
case *objectV2.GetRangePartChunk:
payload = append(payload, v.GetChunk()...)
case *objectV2.SplitInfo:
si := objectSDK.NewSplitInfoFromV2(v)
si := object.NewSplitInfoFromV2(v)
return nil, objectSDK.NewSplitInfoError(si)
return nil, object.NewSplitInfoError(si)
}
}
obj := objectSDK.NewRaw()
obj := object.New()
obj.SetPayload(payload)
return obj.Object(), nil
return obj, nil
}))
}
@ -268,10 +267,10 @@ func (s *Service) toHashRangePrm(req *objectV2.GetRangeHashRequest) (*getsvc.Ran
p.WithAddress(addressSDK.NewAddressFromV2(body.GetAddress()))
rngsV2 := body.GetRanges()
rngs := make([]*objectSDK.Range, 0, len(rngsV2))
rngs := make([]*object.Range, 0, len(rngsV2))
for i := range rngsV2 {
rngs = append(rngs, objectSDK.NewRangeFromV2(rngsV2[i]))
rngs = append(rngs, object.NewRangeFromV2(rngsV2[i]))
}
p.SetRangeList(rngs)
@ -334,7 +333,7 @@ func (s *Service) toHeadPrm(ctx context.Context, req *objectV2.HeadRequest, resp
if !commonPrm.LocalOnly() {
var onceResign sync.Once
p.SetRequestForwarder(groupAddressRequestForwarder(func(addr network.Address, c client.MultiAddressClient, pubkey []byte) (*objectSDK.Object, error) {
p.SetRequestForwarder(groupAddressRequestForwarder(func(addr network.Address, c client.MultiAddressClient, pubkey []byte) (*object.Object, error) {
var err error
key, err := s.keyStorage.GetKey(nil)
@ -429,27 +428,27 @@ func (s *Service) toHeadPrm(ctx context.Context, req *objectV2.HeadRequest, resp
return nil, fmt.Errorf("incorrect object header signature: %w", err)
}
case *objectV2.SplitInfo:
si := objectSDK.NewSplitInfoFromV2(v)
si := object.NewSplitInfoFromV2(v)
return nil, objectSDK.NewSplitInfoError(si)
return nil, object.NewSplitInfoError(si)
}
obj := new(objectV2.Object)
obj.SetHeader(hdr)
obj.SetSignature(idSig)
objv2 := new(objectV2.Object)
objv2.SetHeader(hdr)
objv2.SetSignature(idSig)
raw := object.NewRawFromV2(obj)
raw.SetID(objAddr.ObjectID())
obj := object.NewFromV2(objv2)
obj.SetID(objAddr.ObjectID())
// convert the object
return raw.Object().SDK(), nil
return obj, nil
}))
}
return p, nil
}
func splitInfoResponse(info *objectSDK.SplitInfo) *objectV2.GetResponse {
func splitInfoResponse(info *object.SplitInfo) *objectV2.GetResponse {
resp := new(objectV2.GetResponse)
body := new(objectV2.GetResponseBody)
@ -460,7 +459,7 @@ func splitInfoResponse(info *objectSDK.SplitInfo) *objectV2.GetResponse {
return resp
}
func splitInfoRangeResponse(info *objectSDK.SplitInfo) *objectV2.GetRangeResponse {
func splitInfoRangeResponse(info *object.SplitInfo) *objectV2.GetRangeResponse {
resp := new(objectV2.GetRangeResponse)
body := new(objectV2.GetRangeResponseBody)
@ -471,7 +470,7 @@ func splitInfoRangeResponse(info *objectSDK.SplitInfo) *objectV2.GetRangeRespons
return resp
}
func setSplitInfoHeadResponse(info *objectSDK.SplitInfo, resp *objectV2.HeadResponse) {
func setSplitInfoHeadResponse(info *object.SplitInfo, resp *objectV2.HeadResponse) {
resp.GetBody().SetHeaderPart(info.ToV2())
}
@ -512,11 +511,11 @@ func toShortObjectHeader(hdr *object.Object) objectV2.GetHeaderPart {
return sh
}
func groupAddressRequestForwarder(f func(network.Address, client.MultiAddressClient, []byte) (*objectSDK.Object, error)) getsvc.RequestForwarder {
return func(info client.NodeInfo, c client.MultiAddressClient) (*objectSDK.Object, error) {
func groupAddressRequestForwarder(f func(network.Address, client.MultiAddressClient, []byte) (*object.Object, error)) getsvc.RequestForwarder {
return func(info client.NodeInfo, c client.MultiAddressClient) (*object.Object, error) {
var (
firstErr error
res *objectSDK.Object
res *object.Object
key = info.PublicKey()
)

View file

@ -6,10 +6,10 @@ import (
"fmt"
clientcore "github.com/nspcc-dev/neofs-node/pkg/core/client"
"github.com/nspcc-dev/neofs-node/pkg/core/object"
internalclient "github.com/nspcc-dev/neofs-node/pkg/services/object/internal/client"
"github.com/nspcc-dev/neofs-node/pkg/services/object/util"
"github.com/nspcc-dev/neofs-sdk-go/netmap"
"github.com/nspcc-dev/neofs-sdk-go/object"
addressSDK "github.com/nspcc-dev/neofs-sdk-go/object/address"
)
@ -94,5 +94,5 @@ func (h *RemoteHeader) Head(ctx context.Context, prm *RemoteHeadPrm) (*object.Ob
return nil, fmt.Errorf("(%T) could not head object in %s: %w", h, info.AddressGroup(), err)
}
return object.NewFromSDK(res.Header()), nil
return res.Header(), nil
}

View file

@ -195,7 +195,7 @@ func GetObject(prm GetObjectPrm) (*GetObjectRes, error) {
// FIXME: #1158 object.ErrAlreadyRemoved never returns
object.NewRawFrom(&obj).SetPayload(buf)
obj.SetPayload(buf)
return &GetObjectRes{
obj: &obj,

View file

@ -11,6 +11,7 @@ import (
"github.com/nspcc-dev/neofs-node/pkg/services/object_manager/transformer"
"github.com/nspcc-dev/neofs-node/pkg/util"
"github.com/nspcc-dev/neofs-node/pkg/util/logger"
objectSDK "github.com/nspcc-dev/neofs-sdk-go/object"
)
type distributedTarget struct {
@ -18,7 +19,7 @@ type distributedTarget struct {
remotePool, localPool util.WorkerPool
obj *object.RawObject
obj *objectSDK.Object
chunks [][]byte
@ -54,7 +55,7 @@ func (x errIncompletePut) Error() string {
return commonMsg
}
func (t *distributedTarget) WriteHeader(obj *object.RawObject) error {
func (t *distributedTarget) WriteHeader(obj *objectSDK.Object) error {
t.obj = obj
return nil
@ -81,7 +82,7 @@ func (t *distributedTarget) Close() (*transformer.AccessIdentifiers, error) {
t.obj.SetPayload(payload)
if err := t.fmt.ValidateContent(t.obj.Object()); err != nil {
if err := t.fmt.ValidateContent(t.obj); err != nil {
return nil, fmt.Errorf("(%T) could not validate payload content: %w", t, err)
}

View file

@ -3,20 +3,20 @@ package putsvc
import (
"fmt"
"github.com/nspcc-dev/neofs-node/pkg/core/object"
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/engine"
"github.com/nspcc-dev/neofs-node/pkg/services/object_manager/transformer"
"github.com/nspcc-dev/neofs-sdk-go/object"
)
type localTarget struct {
storage *engine.StorageEngine
obj *object.RawObject
obj *object.Object
payload []byte
}
func (t *localTarget) WriteHeader(obj *object.RawObject) error {
func (t *localTarget) WriteHeader(obj *object.Object) error {
t.obj = obj
t.payload = make([]byte, 0, obj.PayloadSize())
@ -31,7 +31,7 @@ func (t *localTarget) Write(p []byte) (n int, err error) {
}
func (t *localTarget) Close() (*transformer.AccessIdentifiers, error) {
if err := engine.Put(t.storage, t.obj.Object()); err != nil {
if err := engine.Put(t.storage, t.obj); err != nil {
return nil, fmt.Errorf("(%T) could not put object to local storage: %w", t, err)
}

View file

@ -2,15 +2,15 @@ package putsvc
import (
"github.com/nspcc-dev/neofs-node/pkg/core/client"
"github.com/nspcc-dev/neofs-node/pkg/core/object"
"github.com/nspcc-dev/neofs-node/pkg/services/object/util"
"github.com/nspcc-dev/neofs-node/pkg/services/object_manager/placement"
"github.com/nspcc-dev/neofs-sdk-go/object"
)
type PutInitPrm struct {
common *util.CommonPrm
hdr *object.RawObject
hdr *object.Object
traverseOpts []placement.Option
@ -37,7 +37,7 @@ func (p *PutInitPrm) WithTraverseOption(opt placement.Option) *PutInitPrm {
return p
}
func (p *PutInitPrm) WithObject(v *object.RawObject) *PutInitPrm {
func (p *PutInitPrm) WithObject(v *object.Object) *PutInitPrm {
if p != nil {
p.hdr = v
}

View file

@ -5,11 +5,11 @@ import (
"fmt"
clientcore "github.com/nspcc-dev/neofs-node/pkg/core/client"
"github.com/nspcc-dev/neofs-node/pkg/core/object"
internalclient "github.com/nspcc-dev/neofs-node/pkg/services/object/internal/client"
"github.com/nspcc-dev/neofs-node/pkg/services/object/util"
"github.com/nspcc-dev/neofs-node/pkg/services/object_manager/transformer"
"github.com/nspcc-dev/neofs-sdk-go/netmap"
"github.com/nspcc-dev/neofs-sdk-go/object"
)
type remoteTarget struct {
@ -43,8 +43,8 @@ type RemotePutPrm struct {
obj *object.Object
}
func (t *remoteTarget) WriteHeader(obj *object.RawObject) error {
t.obj = obj.Object()
func (t *remoteTarget) WriteHeader(obj *object.Object) error {
t.obj = obj
return nil
}
@ -68,7 +68,7 @@ func (t *remoteTarget) Close() (*transformer.AccessIdentifiers, error) {
prm.SetSessionToken(t.commonPrm.SessionToken())
prm.SetBearerToken(t.commonPrm.BearerToken())
prm.SetXHeaders(t.commonPrm.XHeaders())
prm.SetObject(t.obj.SDK())
prm.SetObject(t.obj)
res, err := internalclient.PutObject(prm)
if err != nil {
@ -118,7 +118,7 @@ func (s *RemoteSender) PutObject(ctx context.Context, p *RemotePutPrm) error {
return fmt.Errorf("parse client node info: %w", err)
}
if err := t.WriteHeader(object.NewRawFromObject(p.obj)); err != nil {
if err := t.WriteHeader(p.obj); err != nil {
return fmt.Errorf("(%T) could not send object header: %w", s, err)
} else if _, err := t.Close(); err != nil {
return fmt.Errorf("(%T) could not send object: %w", s, err)

View file

@ -2,9 +2,9 @@ package putsvc
import (
objectV2 "github.com/nspcc-dev/neofs-api-go/v2/object"
"github.com/nspcc-dev/neofs-node/pkg/core/object"
putsvc "github.com/nspcc-dev/neofs-node/pkg/services/object/put"
"github.com/nspcc-dev/neofs-node/pkg/services/object/util"
"github.com/nspcc-dev/neofs-sdk-go/object"
)
func (s *streamer) toInitPrm(part *objectV2.PutObjectPartInit, req *objectV2.PutRequest) (*putsvc.PutInitPrm, error) {
@ -20,7 +20,7 @@ func (s *streamer) toInitPrm(part *objectV2.PutObjectPartInit, req *objectV2.Put
return new(putsvc.PutInitPrm).
WithObject(
object.NewRawFromV2(oV2),
object.NewFromV2(oV2),
).
WithRelay(s.relayRequest).
WithCommonPrm(commonPrm), nil

View file

@ -10,6 +10,7 @@ import (
"github.com/nspcc-dev/neofs-node/pkg/core/object"
"github.com/nspcc-dev/neofs-node/pkg/services/object_manager/transformer"
"github.com/nspcc-dev/neofs-sdk-go/checksum"
objectSDK "github.com/nspcc-dev/neofs-sdk-go/object"
"github.com/nspcc-dev/tzhash/tz"
)
@ -35,7 +36,7 @@ var (
ErrWrongPayloadSize = errors.New("wrong payload size")
)
func (t *validatingTarget) WriteHeader(obj *object.RawObject) error {
func (t *validatingTarget) WriteHeader(obj *objectSDK.Object) error {
t.payloadSz = obj.PayloadSize()
chunkLn := uint64(len(obj.Payload()))
@ -61,7 +62,7 @@ func (t *validatingTarget) WriteHeader(obj *object.RawObject) error {
t.checksum = cs.Sum()
if err := t.fmt.Validate(obj.Object()); err != nil {
if err := t.fmt.Validate(obj); err != nil {
return fmt.Errorf("(%T) coult not validate object format: %w", t, err)
}

View file

@ -7,7 +7,7 @@ import (
"github.com/nspcc-dev/neofs-node/pkg/services/object_manager/placement"
"github.com/nspcc-dev/neofs-node/pkg/util/logger"
cid "github.com/nspcc-dev/neofs-sdk-go/container/id"
objectSDK "github.com/nspcc-dev/neofs-sdk-go/object"
"github.com/nspcc-dev/neofs-sdk-go/object"
oidSDK "github.com/nspcc-dev/neofs-sdk-go/object/id"
"go.uber.org/zap"
)
@ -64,7 +64,7 @@ func (exec *execCtx) containerID() *cid.ID {
return exec.prm.cid
}
func (exec *execCtx) searchFilters() objectSDK.SearchFilters {
func (exec *execCtx) searchFilters() object.SearchFilters {
return exec.prm.filters
}

View file

@ -4,7 +4,7 @@ import (
coreclient "github.com/nspcc-dev/neofs-node/pkg/core/client"
"github.com/nspcc-dev/neofs-node/pkg/services/object/util"
cid "github.com/nspcc-dev/neofs-sdk-go/container/id"
objectSDK "github.com/nspcc-dev/neofs-sdk-go/object"
"github.com/nspcc-dev/neofs-sdk-go/object"
oidSDK "github.com/nspcc-dev/neofs-sdk-go/object/id"
)
@ -16,7 +16,7 @@ type Prm struct {
cid *cid.ID
filters objectSDK.SearchFilters
filters object.SearchFilters
forwarder RequestForwarder
}
@ -53,6 +53,6 @@ func (p *Prm) WithContainerID(id *cid.ID) {
}
// WithSearchFilters sets search filters.
func (p *Prm) WithSearchFilters(fs objectSDK.SearchFilters) {
func (p *Prm) WithSearchFilters(fs object.SearchFilters) {
p.filters = fs
}

View file

@ -18,7 +18,7 @@ import (
searchsvc "github.com/nspcc-dev/neofs-node/pkg/services/object/search"
"github.com/nspcc-dev/neofs-node/pkg/services/object/util"
cid "github.com/nspcc-dev/neofs-sdk-go/container/id"
objectSDK "github.com/nspcc-dev/neofs-sdk-go/object"
"github.com/nspcc-dev/neofs-sdk-go/object"
oidSDK "github.com/nspcc-dev/neofs-sdk-go/object/id"
)
@ -110,7 +110,7 @@ func (s *Service) toPrm(req *objectV2.SearchRequest, stream objectSvc.SearchStre
body := req.GetBody()
p.WithContainerID(cid.NewFromV2(body.GetContainerID()))
p.WithSearchFilters(objectSDK.NewSearchFiltersFromV2(body.GetFilters()))
p.WithSearchFilters(object.NewSearchFiltersFromV2(body.GetFilters()))
return p, nil
}

View file

@ -4,11 +4,9 @@ import (
"errors"
"fmt"
objectSDK "github.com/nspcc-dev/neofs-sdk-go/object"
"github.com/nspcc-dev/neofs-sdk-go/object"
addressSDK "github.com/nspcc-dev/neofs-sdk-go/object/address"
oidSDK "github.com/nspcc-dev/neofs-sdk-go/object/id"
"github.com/nspcc-dev/neofs-node/pkg/core/object"
)
// HeadReceiver is an interface of entity that can receive
@ -16,7 +14,7 @@ import (
type HeadReceiver interface {
// Head must return one of:
// * object header (*object.Object);
// * structured information about split-chain (*objectSDK.SplitInfo).
// * structured information about split-chain (*object.SplitInfo).
Head(*addressSDK.Address) (interface{}, error)
}
@ -88,7 +86,7 @@ func traverseSplitChain(r HeadReceiver, addr *addressSDK.Address, h SplitMemberH
panic(fmt.Sprintf("unexpected result of %T: %T", r, v))
case *object.Object:
return h(res, false), nil
case *objectSDK.SplitInfo:
case *object.SplitInfo:
switch {
default:
return false, errors.New("lack of split information")

View file

@ -1,10 +1,10 @@
package storagegroup
import (
"github.com/nspcc-dev/neofs-node/pkg/core/object"
objutil "github.com/nspcc-dev/neofs-node/pkg/services/object/util"
"github.com/nspcc-dev/neofs-sdk-go/checksum"
cid "github.com/nspcc-dev/neofs-sdk-go/container/id"
"github.com/nspcc-dev/neofs-sdk-go/object"
addressSDK "github.com/nspcc-dev/neofs-sdk-go/object/address"
oidSDK "github.com/nspcc-dev/neofs-sdk-go/object/id"
"github.com/nspcc-dev/neofs-sdk-go/storagegroup"

View file

@ -5,8 +5,7 @@ import (
"fmt"
"github.com/nspcc-dev/neofs-node/pkg/core/netmap"
"github.com/nspcc-dev/neofs-node/pkg/core/object"
objectSDK "github.com/nspcc-dev/neofs-sdk-go/object"
"github.com/nspcc-dev/neofs-sdk-go/object"
oidSDK "github.com/nspcc-dev/neofs-sdk-go/object/id"
"github.com/nspcc-dev/neofs-sdk-go/session"
"github.com/nspcc-dev/neofs-sdk-go/version"
@ -15,7 +14,7 @@ import (
type formatter struct {
prm *FormatterParams
obj *object.RawObject
obj *object.Object
sz uint64
}
@ -48,7 +47,7 @@ func NewFormatTarget(p *FormatterParams) ObjectTarget {
}
}
func (f *formatter) WriteHeader(obj *object.RawObject) error {
func (f *formatter) WriteHeader(obj *object.Object) error {
f.obj = obj
return nil
@ -72,26 +71,26 @@ func (f *formatter) Close() (*AccessIdentifiers, error) {
var (
parID *oidSDK.ID
parHdr *objectSDK.Object
parHdr *object.Object
)
if par := f.obj.Parent(); par != nil && par.Signature() == nil {
rawPar := objectSDK.NewRawFromV2(par.ToV2())
rawPar := object.NewFromV2(par.ToV2())
rawPar.SetSessionToken(f.prm.SessionToken)
rawPar.SetCreationEpoch(curEpoch)
if err := objectSDK.SetIDWithSignature(f.prm.Key, rawPar); err != nil {
if err := object.SetIDWithSignature(f.prm.Key, rawPar); err != nil {
return nil, fmt.Errorf("could not finalize parent object: %w", err)
}
parID = rawPar.ID()
parHdr = rawPar.Object()
parHdr = rawPar
f.obj.SetParent(parHdr)
}
if err := objectSDK.SetIDWithSignature(f.prm.Key, f.obj.SDK()); err != nil {
if err := object.SetIDWithSignature(f.prm.Key, f.obj); err != nil {
return nil, fmt.Errorf("could not finalize object: %w", err)
}

View file

@ -6,9 +6,8 @@ import (
"hash"
"io"
"github.com/nspcc-dev/neofs-node/pkg/core/object"
"github.com/nspcc-dev/neofs-sdk-go/checksum"
objectSDK "github.com/nspcc-dev/neofs-sdk-go/object"
"github.com/nspcc-dev/neofs-sdk-go/object"
oidSDK "github.com/nspcc-dev/neofs-sdk-go/object/id"
"github.com/nspcc-dev/tzhash/tz"
)
@ -20,7 +19,7 @@ type payloadSizeLimiter struct {
target ObjectTarget
current, parent *object.RawObject
current, parent *object.Object
currentHashers, parentHashers []*payloadChecksumHasher
@ -28,9 +27,9 @@ type payloadSizeLimiter struct {
chunkWriter io.Writer
splitID *objectSDK.SplitID
splitID *object.SplitID
parAttrs []*objectSDK.Attribute
parAttrs []*object.Attribute
}
type payloadChecksumHasher struct {
@ -47,11 +46,11 @@ func NewPayloadSizeLimiter(maxSize uint64, targetInit TargetInitializer) ObjectT
return &payloadSizeLimiter{
maxSize: maxSize,
targetInit: targetInit,
splitID: objectSDK.NewSplitID(),
splitID: object.NewSplitID(),
}
}
func (s *payloadSizeLimiter) WriteHeader(hdr *object.RawObject) error {
func (s *payloadSizeLimiter) WriteHeader(hdr *object.Object) error {
s.current = fromObject(hdr)
s.initialize()
@ -86,8 +85,8 @@ func (s *payloadSizeLimiter) initialize() {
s.initializeCurrent()
}
func fromObject(obj *object.RawObject) *object.RawObject {
res := object.NewRaw()
func fromObject(obj *object.Object) *object.Object {
res := object.New()
res.SetContainerID(obj.ContainerID())
res.SetOwnerID(obj.OwnerID())
res.SetAttributes(obj.Attributes()...)
@ -125,7 +124,7 @@ func (s *payloadSizeLimiter) initializeCurrent() {
s.chunkWriter = io.MultiWriter(ws...)
}
func payloadHashersForObject(obj *object.RawObject) []*payloadChecksumHasher {
func payloadHashersForObject(obj *object.Object) []*payloadChecksumHasher {
return []*payloadChecksumHasher{
{
hasher: sha256.New(),
@ -171,7 +170,7 @@ func (s *payloadSizeLimiter) release(close bool) (*AccessIdentifiers, error) {
if withParent {
writeHashes(s.parentHashers)
s.parent.SetPayloadSize(s.written)
s.current.SetParent(s.parent.SDK().Object())
s.current.SetParent(s.parent)
}
// release current object
@ -209,7 +208,7 @@ func writeHashes(hashers []*payloadChecksumHasher) {
}
}
func (s *payloadSizeLimiter) initializeLinking(parHdr *objectSDK.Object) {
func (s *payloadSizeLimiter) initializeLinking(parHdr *object.Object) {
s.current = fromObject(s.current)
s.current.SetParent(parHdr)
s.current.SetChildren(s.previous...)

View file

@ -3,8 +3,7 @@ package transformer
import (
"io"
"github.com/nspcc-dev/neofs-node/pkg/core/object"
objectSDK "github.com/nspcc-dev/neofs-sdk-go/object"
"github.com/nspcc-dev/neofs-sdk-go/object"
oidSDK "github.com/nspcc-dev/neofs-sdk-go/object/id"
)
@ -14,7 +13,7 @@ import (
type AccessIdentifiers struct {
par, self *oidSDK.ID
parHdr *objectSDK.Object
parHdr *object.Object
}
// ObjectTarget is an interface of the object writer.
@ -27,7 +26,7 @@ type ObjectTarget interface {
// that depends on the implementation.
//
// Must not be called after Close call.
WriteHeader(*object.RawObject) error
WriteHeader(*object.Object) error
// Write writes object payload chunk.
//
@ -93,7 +92,7 @@ func (a *AccessIdentifiers) WithParentID(v *oidSDK.ID) *AccessIdentifiers {
}
// Parent return identifier of the parent of the written object.
func (a *AccessIdentifiers) Parent() *objectSDK.Object {
func (a *AccessIdentifiers) Parent() *object.Object {
if a != nil {
return a.parHdr
}
@ -102,7 +101,7 @@ func (a *AccessIdentifiers) Parent() *objectSDK.Object {
}
// WithParent returns AccessIdentifiers with passed parent identifier.
func (a *AccessIdentifiers) WithParent(v *objectSDK.Object) *AccessIdentifiers {
func (a *AccessIdentifiers) WithParent(v *object.Object) *AccessIdentifiers {
res := a
if res == nil {
res = new(AccessIdentifiers)