forked from TrueCloudLab/frostfs-node
[#242] shard: Support ContainerID argument in metabase selects
Signed-off-by: Alex Vanin <alexey@nspcc.ru>
This commit is contained in:
parent
b97f818323
commit
f585772746
2 changed files with 13 additions and 5 deletions
|
@ -18,10 +18,7 @@ func (s *Shard) List() (*SelectRes, error) {
|
|||
filters := object.NewSearchFilters()
|
||||
|
||||
for i := range lst {
|
||||
filters = filters[:0]
|
||||
filters.AddObjectContainerIDFilter(object.MatchStringEqual, lst[i])
|
||||
|
||||
ids, err := meta.Select(s.metaBase, filters) // consider making List in metabase
|
||||
ids, err := meta.Select(s.metaBase, lst[i], filters) // consider making List in metabase
|
||||
if err != nil {
|
||||
s.log.Debug("can't select all objects",
|
||||
zap.Stringer("cid", lst[i]),
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package shard
|
||||
|
||||
import (
|
||||
"github.com/nspcc-dev/neofs-api-go/pkg/container"
|
||||
objectSDK "github.com/nspcc-dev/neofs-api-go/pkg/object"
|
||||
meta "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/metabase"
|
||||
"github.com/pkg/errors"
|
||||
|
@ -8,6 +9,7 @@ import (
|
|||
|
||||
// SelectPrm groups the parameters of Select operation.
|
||||
type SelectPrm struct {
|
||||
cid *container.ID
|
||||
filters objectSDK.SearchFilters
|
||||
}
|
||||
|
||||
|
@ -16,6 +18,15 @@ type SelectRes struct {
|
|||
addrList []*objectSDK.Address
|
||||
}
|
||||
|
||||
// WithContainerID is a Select option to set the container id to search in.
|
||||
func (p *SelectPrm) WithContainerID(cid *container.ID) *SelectPrm {
|
||||
if p != nil {
|
||||
p.cid = cid
|
||||
}
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// WithFilters is a Select option to set the object filters.
|
||||
func (p *SelectPrm) WithFilters(fs objectSDK.SearchFilters) *SelectPrm {
|
||||
if p != nil {
|
||||
|
@ -35,7 +46,7 @@ func (r *SelectRes) AddressList() []*objectSDK.Address {
|
|||
// Returns any error encountered that
|
||||
// did not allow to completely select the objects.
|
||||
func (s *Shard) Select(prm *SelectPrm) (*SelectRes, error) {
|
||||
addrList, err := meta.Select(s.metaBase, prm.filters)
|
||||
addrList, err := meta.Select(s.metaBase, prm.cid, prm.filters)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "could not select objects from metabase")
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue