forked from TrueCloudLab/frostfs-node
[#1186] engine: Allow to skip metabase in GetRange
Similarly to `Get`. Also fix a bug where `ErrNotFound` is returned instead of `ErrRangeOutOfBounds`. Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
This commit is contained in:
parent
2b5550ccf6
commit
1fe9cd4d36
6 changed files with 72 additions and 10 deletions
|
@ -15,11 +15,14 @@ type RngPrm struct {
|
|||
off uint64
|
||||
|
||||
addr *addressSDK.Address
|
||||
|
||||
skipMeta bool
|
||||
}
|
||||
|
||||
// RngRes groups resulting values of GetRange operation.
|
||||
type RngRes struct {
|
||||
obj *object.Object
|
||||
obj *object.Object
|
||||
hasMeta bool
|
||||
}
|
||||
|
||||
// WithAddress is a Rng option to set the address of the requested object.
|
||||
|
@ -42,6 +45,13 @@ func (p *RngPrm) WithRange(off uint64, ln uint64) *RngPrm {
|
|||
return p
|
||||
}
|
||||
|
||||
// WithIgnoreMeta is a Get option try to fetch object from blobstor directly,
|
||||
// without accessing metabase.
|
||||
func (p *RngPrm) WithIgnoreMeta(ignore bool) *RngPrm {
|
||||
p.skipMeta = ignore
|
||||
return p
|
||||
}
|
||||
|
||||
// Object returns the requested object part.
|
||||
//
|
||||
// Instance payload contains the requested range of the original object.
|
||||
|
@ -49,6 +59,11 @@ func (r *RngRes) Object() *object.Object {
|
|||
return r.obj
|
||||
}
|
||||
|
||||
// HasMeta returns true if info about the object was found in the metabase.
|
||||
func (r *RngRes) HasMeta() bool {
|
||||
return r.hasMeta
|
||||
}
|
||||
|
||||
// GetRange reads part of an object from shard.
|
||||
//
|
||||
// Returns any error encountered that
|
||||
|
@ -95,9 +110,10 @@ func (s *Shard) GetRange(prm *RngPrm) (*RngRes, error) {
|
|||
return obj.Object(), nil
|
||||
}
|
||||
|
||||
obj, _, err := s.fetchObjectData(prm.addr, false, big, small)
|
||||
obj, hasMeta, err := s.fetchObjectData(prm.addr, prm.skipMeta, big, small)
|
||||
|
||||
return &RngRes{
|
||||
obj: obj,
|
||||
obj: obj,
|
||||
hasMeta: hasMeta,
|
||||
}, err
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue