[#939] cli/put: Add support buffer pool

Signed-off-by: Alexander Chuprov <a.chuprov@yadro.com>
This commit is contained in:
Alexander Chuprov 2024-02-01 12:07:36 +03:00
parent df055fead5
commit 27fcf868d8
2 changed files with 17 additions and 0 deletions

View file

@ -9,6 +9,7 @@ import (
"sort"
"strings"
buffPool "git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/util/pool"
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/accounting"
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/checksum"
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/client"
@ -356,6 +357,8 @@ type PutObjectPrm struct {
headerCallback func(*objectSDK.Object)
prepareLocally bool
objSize uint64
}
// SetHeader sets object header.
@ -363,6 +366,10 @@ func (x *PutObjectPrm) SetHeader(hdr *objectSDK.Object) {
x.hdr = hdr
}
func (x *PutObjectPrm) SetObjSize(size uint64) {
x.objSize = size
}
// SetPayloadReader sets reader of the object payload.
func (x *PutObjectPrm) SetPayloadReader(rdr io.Reader) {
x.rdr = rdr
@ -402,6 +409,11 @@ func (x *PutObjectPrm) convertToSDKPrm(ctx context.Context) (client.PrmObjectPut
putPrm.MaxSize = res.Info().MaxObjectSize()
putPrm.EpochSource = epochSource(res.Info().CurrentEpoch())
putPrm.WithoutHomomorphHash = res.Info().HomomorphicHashingDisabled()
if x.objSize > 2*res.Info().MaxObjectSize() {
pool := buffPool.NewBufferPool(uint32(res.Info().MaxObjectSize()))
putPrm.Pool = &pool
}
} else {
putPrm.Session = x.sessionToken
}

View file

@ -130,6 +130,11 @@ func putObject(cmd *cobra.Command, _ []string) {
commonCmd.ExitOnErr(cmd, "can't parse object copies numbers information: %w", err)
prm.SetCopiesNumberByVectors(parseCopyNumber(cmd, copyNum))
fi, err := f.Stat()
if err == nil {
prm.SetObjSize(uint64(fi.Size()))
}
res, err := internalclient.PutObject(cmd.Context(), prm)
if p != nil {
p.Finish()