WIP: cli/put: Add support buffer pool #939
2 changed files with 17 additions and 0 deletions
|
@ -9,6 +9,7 @@ import (
|
||||||
"sort"
|
"sort"
|
||||||
"strings"
|
"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/accounting"
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/checksum"
|
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/checksum"
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/client"
|
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/client"
|
||||||
|
@ -356,6 +357,8 @@ type PutObjectPrm struct {
|
||||||
headerCallback func(*objectSDK.Object)
|
headerCallback func(*objectSDK.Object)
|
||||||
|
|
||||||
prepareLocally bool
|
prepareLocally bool
|
||||||
|
|
||||||
|
objSize uint64
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetHeader sets object header.
|
// SetHeader sets object header.
|
||||||
|
@ -363,6 +366,10 @@ func (x *PutObjectPrm) SetHeader(hdr *objectSDK.Object) {
|
||||||
x.hdr = hdr
|
x.hdr = hdr
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (x *PutObjectPrm) SetObjSize(size uint64) {
|
||||||
|
x.objSize = size
|
||||||
|
}
|
||||||
|
|
||||||
// SetPayloadReader sets reader of the object payload.
|
// SetPayloadReader sets reader of the object payload.
|
||||||
func (x *PutObjectPrm) SetPayloadReader(rdr io.Reader) {
|
func (x *PutObjectPrm) SetPayloadReader(rdr io.Reader) {
|
||||||
x.rdr = rdr
|
x.rdr = rdr
|
||||||
|
@ -402,6 +409,11 @@ func (x *PutObjectPrm) convertToSDKPrm(ctx context.Context) (client.PrmObjectPut
|
||||||
putPrm.MaxSize = res.Info().MaxObjectSize()
|
putPrm.MaxSize = res.Info().MaxObjectSize()
|
||||||
putPrm.EpochSource = epochSource(res.Info().CurrentEpoch())
|
putPrm.EpochSource = epochSource(res.Info().CurrentEpoch())
|
||||||
putPrm.WithoutHomomorphHash = res.Info().HomomorphicHashingDisabled()
|
putPrm.WithoutHomomorphHash = res.Info().HomomorphicHashingDisabled()
|
||||||
|
|
||||||
|
if x.objSize > 2*res.Info().MaxObjectSize() {
|
||||||
|
pool := buffPool.NewBufferPool(uint32(res.Info().MaxObjectSize()))
|
||||||
|
putPrm.Pool = &pool
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
putPrm.Session = x.sessionToken
|
putPrm.Session = x.sessionToken
|
||||||
}
|
}
|
||||||
|
|
|
@ -130,6 +130,11 @@ func putObject(cmd *cobra.Command, _ []string) {
|
||||||
commonCmd.ExitOnErr(cmd, "can't parse object copies numbers information: %w", err)
|
commonCmd.ExitOnErr(cmd, "can't parse object copies numbers information: %w", err)
|
||||||
prm.SetCopiesNumberByVectors(parseCopyNumber(cmd, copyNum))
|
prm.SetCopiesNumberByVectors(parseCopyNumber(cmd, copyNum))
|
||||||
|
|
||||||
|
fi, err := f.Stat()
|
||||||
|
if err == nil {
|
||||||
|
prm.SetObjSize(uint64(fi.Size()))
|
||||||
|
}
|
||||||
|
|
||||||
res, err := internalclient.PutObject(cmd.Context(), prm)
|
res, err := internalclient.PutObject(cmd.Context(), prm)
|
||||||
if p != nil {
|
if p != nil {
|
||||||
p.Finish()
|
p.Finish()
|
||||||
|
|
Loading…
Reference in a new issue