[#1147] node: Use public fields for shard.ExistsPrm

Signed-off-by: Anton Nikiforov <an.nikiforov@yadro.com>
This commit is contained in:
Anton Nikiforov 2024-05-30 09:26:06 +03:00 committed by Evgenii Stratonikov
parent c1af13b47e
commit 92e19feb57
9 changed files with 26 additions and 30 deletions

View file

@ -83,7 +83,7 @@ func (e *StorageEngine) delete(ctx context.Context, prm DeletePrm) (DeleteRes, e
// 2. Otherwise, search for all objects with a particular SplitID and delete them too.
e.iterateOverSortedShards(prm.addr, func(_ int, sh hashedShard) (stop bool) {
var existsPrm shard.ExistsPrm
existsPrm.SetAddress(prm.addr)
existsPrm.Address = prm.addr
resExists, err := sh.Exists(ctx, existsPrm)
if err != nil {

View file

@ -63,7 +63,10 @@ func benchmarkExists(b *testing.B, shardNum int) {
b.ReportAllocs()
b.ResetTimer()
for i := 0; i < b.N; i++ {
ok, _, err := e.exists(context.Background(), addr, oid.Address{})
var shPrm shard.ExistsPrm
shPrm.Address = addr
shPrm.ParentAddress = oid.Address{}
ok, _, err := e.exists(context.Background(), shPrm)
if err != nil || ok {
b.Fatalf("%t %v", ok, err)
}

View file

@ -8,18 +8,16 @@ import (
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/client"
apistatus "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/client/status"
objectSDK "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object"
oid "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object/id"
)
func (e *StorageEngine) exists(ctx context.Context, addr oid.Address, parentAddr oid.Address) (bool, bool, error) {
var shPrm shard.ExistsPrm
shPrm.SetAddress(addr)
shPrm.SetParentAddress(parentAddr)
// exists return in the first value true if object exists.
// Second return value marks is parent object locked.
func (e *StorageEngine) exists(ctx context.Context, shPrm shard.ExistsPrm) (bool, bool, error) {
alreadyRemoved := false
exists := false
locked := false
e.iterateOverSortedShards(addr, func(_ int, sh hashedShard) (stop bool) {
e.iterateOverSortedShards(shPrm.Address, func(_ int, sh hashedShard) (stop bool) {
res, err := sh.Exists(ctx, shPrm)
if err != nil {
if client.IsErrObjectAlreadyRemoved(err) {

View file

@ -142,7 +142,7 @@ func (e *StorageEngine) inhumeAddr(ctx context.Context, addr oid.Address, prm sh
}()
if checkExists {
existPrm.SetAddress(addr)
existPrm.Address = addr
exRes, err := sh.Exists(ctx, existPrm)
if err != nil {
if client.IsErrObjectAlreadyRemoved(err) || shard.IsErrObjectExpired(err) {

View file

@ -78,7 +78,7 @@ func (e *StorageEngine) lockSingle(ctx context.Context, idCnr cid.ID, locker, lo
if checkExists {
var existsPrm shard.ExistsPrm
existsPrm.SetAddress(addrLocked)
existsPrm.Address = addrLocked
exRes, err := sh.Exists(ctx, existsPrm)
if err != nil {

View file

@ -85,7 +85,10 @@ func (e *StorageEngine) put(ctx context.Context, prm PutPrm) error {
parent.SetObject(prm.obj.ECHeader().Parent())
parent.SetContainer(addr.Container())
}
existed, locked, err := e.exists(ctx, addr, parent)
var shPrm shard.ExistsPrm
shPrm.Address = addr
shPrm.ParentAddress = parent
existed, locked, err := e.exists(ctx, shPrm)
if err != nil {
return err
}
@ -138,7 +141,7 @@ func (e *StorageEngine) putToShard(ctx context.Context, sh hashedShard, pool uti
defer close(exitCh)
var existPrm shard.ExistsPrm
existPrm.SetAddress(addr)
existPrm.Address = addr
exists, err := sh.Exists(ctx, existPrm)
if err != nil {

View file

@ -115,7 +115,7 @@ func (e *StorageEngine) removeObjects(ctx context.Context, ch <-chan oid.Address
found := false
for i := range shards {
var existsPrm shard.ExistsPrm
existsPrm.SetAddress(addr)
existsPrm.Address = addr
res, err := shards[i].Exists(ctx, existsPrm)
if err != nil {