From 7b882b26d8cfd35e13bf61dc5c63d55903da0840 Mon Sep 17 00:00:00 2001 From: Evgenii Stratonikov Date: Wed, 13 Jul 2022 15:38:03 +0300 Subject: [PATCH] [#1559] shard: Remove public functions Signed-off-by: Evgenii Stratonikov --- pkg/local_object_storage/engine/container.go | 15 ++++++----- pkg/local_object_storage/shard/container.go | 9 ------- pkg/local_object_storage/shard/list.go | 27 -------------------- 3 files changed, 9 insertions(+), 42 deletions(-) diff --git a/pkg/local_object_storage/engine/container.go b/pkg/local_object_storage/engine/container.go index 81acb71a..65a6d4f9 100644 --- a/pkg/local_object_storage/engine/container.go +++ b/pkg/local_object_storage/engine/container.go @@ -71,7 +71,10 @@ func (e *StorageEngine) containerSize(prm ContainerSizePrm) (res ContainerSizeRe } e.iterateOverUnsortedShards(func(sh hashedShard) (stop bool) { - size, err := shard.ContainerSize(sh.Shard, prm.cnr) + var csPrm shard.ContainerSizePrm + csPrm.WithContainerID(prm.cnr) + + csRes, err := sh.Shard.ContainerSize(csPrm) if err != nil { e.reportShardError(sh, "can't get container size", err, zap.Stringer("container_id", prm.cnr), @@ -79,7 +82,7 @@ func (e *StorageEngine) containerSize(prm ContainerSizePrm) (res ContainerSizeRe return false } - res.size += size + res.size += csRes.Size() return false }) @@ -119,16 +122,16 @@ func (e *StorageEngine) listContainers() (ListContainersRes, error) { uniqueIDs := make(map[string]cid.ID) e.iterateOverUnsortedShards(func(sh hashedShard) (stop bool) { - cnrs, err := shard.ListContainers(sh.Shard) + res, err := sh.Shard.ListContainers(shard.ListContainersPrm{}) if err != nil { e.reportShardError(sh, "can't get list of containers", err) return false } - for i := range cnrs { - id := cnrs[i].EncodeToString() + for _, cnr := range res.Containers() { + id := cnr.EncodeToString() if _, ok := uniqueIDs[id]; !ok { - uniqueIDs[id] = cnrs[i] + uniqueIDs[id] = cnr } } diff --git a/pkg/local_object_storage/shard/container.go b/pkg/local_object_storage/shard/container.go index 43e2851d..5204bf50 100644 --- a/pkg/local_object_storage/shard/container.go +++ b/pkg/local_object_storage/shard/container.go @@ -34,12 +34,3 @@ func (s *Shard) ContainerSize(prm ContainerSizePrm) (ContainerSizeRes, error) { size: size, }, nil } - -func ContainerSize(s *Shard, cnr cid.ID) (uint64, error) { - res, err := s.ContainerSize(ContainerSizePrm{cnr: cnr}) - if err != nil { - return 0, err - } - - return res.Size(), nil -} diff --git a/pkg/local_object_storage/shard/list.go b/pkg/local_object_storage/shard/list.go index c899f863..4ac240bc 100644 --- a/pkg/local_object_storage/shard/list.go +++ b/pkg/local_object_storage/shard/list.go @@ -103,15 +103,6 @@ func (s *Shard) ListContainers(_ ListContainersPrm) (ListContainersRes, error) { }, nil } -func ListContainers(s *Shard) ([]cid.ID, error) { - res, err := s.ListContainers(ListContainersPrm{}) - if err != nil { - return nil, err - } - - return res.Containers(), nil -} - // ListWithCursor lists physical objects available in shard starting from // cursor. Includes regular, tombstone and storage group objects. Does not // include inhumed objects. Use cursor value from response for consecutive requests. @@ -132,21 +123,3 @@ func (s *Shard) ListWithCursor(prm ListWithCursorPrm) (ListWithCursorRes, error) cursor: res.Cursor(), }, nil } - -// ListWithCursor lists physical objects available in shard starting from -// cursor. Includes regular, tombstone and storage group objects. Does not -// include inhumed objects. Use cursor value from response for consecutive requests. -// -// Returns ErrEndOfListing if there are no more objects to return or count -// parameter set to zero. -func ListWithCursor(s *Shard, count uint32, cursor *Cursor) ([]oid.Address, *Cursor, error) { - var prm ListWithCursorPrm - prm.WithCount(count) - prm.WithCursor(cursor) - res, err := s.ListWithCursor(prm) - if err != nil { - return nil, nil, err - } - - return res.AddressList(), res.Cursor(), nil -}