[#233] object/head: Remove getting the right child header

With the update of the local storage engine, the headers of virtual objects
are directly given. In this regard, the step with obtaining the the right
child header is removed.

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
Leonard Lyubich 2020-12-05 15:29:05 +03:00 committed by Alex Vanin
parent f24daa10ff
commit 869d9e571c
6 changed files with 4 additions and 60 deletions

View file

@ -343,7 +343,6 @@ func initObjectService(c *cfg) {
headsvc.WithContainerSource(c.cfgObject.cnrStorage), headsvc.WithContainerSource(c.cfgObject.cnrStorage),
headsvc.WithNetworkMapSource(c.cfgObject.netMapStorage), headsvc.WithNetworkMapSource(c.cfgObject.netMapStorage),
headsvc.WithLocalAddressSource(c), headsvc.WithLocalAddressSource(c),
headsvc.WithRightChildSearcher(searchsvc.NewRightChildSearcher(sSearch)),
headsvc.WithWorkerPool(c.cfgObject.pool.head), headsvc.WithWorkerPool(c.cfgObject.pool.head),
headsvc.WithLogger(c.log), headsvc.WithLogger(c.log),
headsvc.WithClientOptions( headsvc.WithClientOptions(

View file

@ -133,11 +133,6 @@ func (s *Service) getRelations(ctx context.Context, prm *Prm) ([]*objectSDK.Addr
id := hdr.ID() id := hdr.ID()
prev = hdr.PreviousID() prev = hdr.PreviousID()
if rightChild := headResult.RightChild(); rightChild != nil {
id = rightChild.ID()
prev = rightChild.PreviousID()
}
addr.SetObjectID(id) addr.SetObjectID(id)
res = append(res, addr) res = append(res, addr)

View file

@ -5,13 +5,9 @@ import (
) )
type Response struct { type Response struct {
hdr, rightChild *object.Object hdr *object.Object
} }
func (r *Response) Header() *object.Object { func (r *Response) Header() *object.Object {
return r.hdr return r.hdr
} }
func (r *Response) RightChild() *object.Object {
return r.rightChild
}

View file

@ -36,8 +36,6 @@ type cfg struct {
localAddrSrc network.LocalAddressSource localAddrSrc network.LocalAddressSource
rightChildSearcher RelationSearcher
localHeader localHeader localHeader localHeader
remoteHeader RemoteHeader remoteHeader RemoteHeader
@ -67,37 +65,9 @@ func NewService(opts ...Option) *Service {
} }
func (s *Service) Head(ctx context.Context, prm *Prm) (*Response, error) { func (s *Service) Head(ctx context.Context, prm *Prm) (*Response, error) {
// try to receive header of physically stored return (&distributedHeader{
r, err := (&distributedHeader{
cfg: s.cfg, cfg: s.cfg,
}).head(ctx, prm) }).head(ctx, prm)
if err == nil || prm.common.LocalOnly() {
return r, err
}
// try to find far right child that carries header of desired object
rightChildID, err := s.rightChildSearcher.SearchRelation(ctx, prm.addr, prm.common)
if err != nil {
return nil, errors.Wrapf(err, "(%T) could not find right child", s)
}
addr := objectSDK.NewAddress()
addr.SetContainerID(prm.addr.ContainerID())
addr.SetObjectID(rightChildID)
r, err = s.Head(ctx, new(Prm).WithAddress(addr).WithCommonPrm(prm.common))
if err != nil {
return nil, errors.Wrapf(err, "(%T) could not get right child header", s)
}
rightChild := r.Header()
// TODO: check if received parent has requested address
return &Response{
hdr: rightChild.GetParent(),
rightChild: rightChild,
}, nil
} }
func WithKeyStorage(v *objutil.KeyStorage) Option { func WithKeyStorage(v *objutil.KeyStorage) Option {
@ -136,12 +106,6 @@ func WithLocalAddressSource(v network.LocalAddressSource) Option {
} }
} }
func WithRightChildSearcher(v RelationSearcher) Option {
return func(c *cfg) {
c.rightChildSearcher = v
}
}
func WithClientCache(v *cache.ClientCache) Option { func WithClientCache(v *cache.ClientCache) Option {
return func(c *cfg) { return func(c *cfg) {
c.remoteHeader.clientCache = v c.remoteHeader.clientCache = v

View file

@ -88,12 +88,7 @@ func (s *Service) GetRange(ctx context.Context, prm *Prm) (*Result, error) {
return nil, errors.Errorf("(%T) requested payload range is out-of-bounds", s) return nil, errors.Errorf("(%T) requested payload range is out-of-bounds", s)
} }
right := headResult.RightChild() rngTraverser := objutil.NewRangeTraverser(originSize, origin, prm.rng)
if right == nil {
right = origin
}
rngTraverser := objutil.NewRangeTraverser(originSize, right, prm.rng)
if err := s.fillTraverser(ctx, prm, rngTraverser); err != nil { if err := s.fillTraverser(ctx, prm, rngTraverser); err != nil {
return nil, errors.Wrapf(err, "(%T) could not fill range traverser", s) return nil, errors.Wrapf(err, "(%T) could not fill range traverser", s)
} }

View file

@ -103,16 +103,11 @@ func (s *Service) GetRangeHash(ctx context.Context, prm *Prm) (*Response, error)
} }
} }
right := headResult.RightChild()
if right == nil {
right = origin
}
borderRng := new(object.Range) borderRng := new(object.Range)
borderRng.SetOffset(minLeft) borderRng.SetOffset(minLeft)
borderRng.SetLength(maxRight - minLeft) borderRng.SetLength(maxRight - minLeft)
return s.getHashes(ctx, prm, objutil.NewRangeTraverser(originSize, right, borderRng)) return s.getHashes(ctx, prm, objutil.NewRangeTraverser(originSize, origin, borderRng))
} }
func (s *Service) getHashes(ctx context.Context, prm *Prm, traverser *objutil.RangeTraverser) (*Response, error) { func (s *Service) getHashes(ctx context.Context, prm *Prm, traverser *objutil.RangeTraverser) (*Response, error) {