forked from TrueCloudLab/frostfs-node
[#176] localstore: Fix Get with non-zero length
GetPrm has WithPayloadRange option to specify the requested payload range. In previous implementation StorageEngine.Get method ignored this option. From now zero length matches full payload request. Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
parent
46e455dcae
commit
73494c4bbc
1 changed files with 8 additions and 3 deletions
|
@ -37,7 +37,7 @@ func (p *GetPrm) WithAddress(addr *objectSDK.Address) *GetPrm {
|
||||||
|
|
||||||
// WithPayloadRange is a Get option to set range of requested payload data.
|
// WithPayloadRange is a Get option to set range of requested payload data.
|
||||||
//
|
//
|
||||||
// Missing an option or calling with zero arguments is equivalent
|
// Missing an option or calling with zero length is equivalent
|
||||||
// to getting the full payload range.
|
// to getting the full payload range.
|
||||||
func (p *GetPrm) WithPayloadRange(off, ln uint64) *GetPrm {
|
func (p *GetPrm) WithPayloadRange(off, ln uint64) *GetPrm {
|
||||||
if p != nil {
|
if p != nil {
|
||||||
|
@ -67,8 +67,13 @@ func (e *StorageEngine) Get(prm *GetPrm) (*GetRes, error) {
|
||||||
var obj *object.Object
|
var obj *object.Object
|
||||||
|
|
||||||
shPrm := new(shard.GetPrm).
|
shPrm := new(shard.GetPrm).
|
||||||
WithAddress(prm.addr).
|
WithAddress(prm.addr)
|
||||||
WithFullRange()
|
|
||||||
|
if prm.ln == 0 {
|
||||||
|
shPrm = shPrm.WithFullRange()
|
||||||
|
} else {
|
||||||
|
shPrm = shPrm.WithRange(prm.off, int64(prm.ln))
|
||||||
|
}
|
||||||
|
|
||||||
e.iterateOverSortedShards(prm.addr, func(sh *shard.Shard) (stop bool) {
|
e.iterateOverSortedShards(prm.addr, func(sh *shard.Shard) (stop bool) {
|
||||||
res, err := sh.Get(shPrm)
|
res, err := sh.Get(shPrm)
|
||||||
|
|
Loading…
Reference in a new issue