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()
|
filters := object.NewSearchFilters()
|
||||||
|
|
||||||
for i := range lst {
|
for i := range lst {
|
||||||
filters = filters[:0]
|
ids, err := meta.Select(s.metaBase, lst[i], filters) // consider making List in metabase
|
||||||
filters.AddObjectContainerIDFilter(object.MatchStringEqual, lst[i])
|
|
||||||
|
|
||||||
ids, err := meta.Select(s.metaBase, filters) // consider making List in metabase
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
s.log.Debug("can't select all objects",
|
s.log.Debug("can't select all objects",
|
||||||
zap.Stringer("cid", lst[i]),
|
zap.Stringer("cid", lst[i]),
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package shard
|
package shard
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"github.com/nspcc-dev/neofs-api-go/pkg/container"
|
||||||
objectSDK "github.com/nspcc-dev/neofs-api-go/pkg/object"
|
objectSDK "github.com/nspcc-dev/neofs-api-go/pkg/object"
|
||||||
meta "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/metabase"
|
meta "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/metabase"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
|
@ -8,6 +9,7 @@ import (
|
||||||
|
|
||||||
// SelectPrm groups the parameters of Select operation.
|
// SelectPrm groups the parameters of Select operation.
|
||||||
type SelectPrm struct {
|
type SelectPrm struct {
|
||||||
|
cid *container.ID
|
||||||
filters objectSDK.SearchFilters
|
filters objectSDK.SearchFilters
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,6 +18,15 @@ type SelectRes struct {
|
||||||
addrList []*objectSDK.Address
|
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.
|
// WithFilters is a Select option to set the object filters.
|
||||||
func (p *SelectPrm) WithFilters(fs objectSDK.SearchFilters) *SelectPrm {
|
func (p *SelectPrm) WithFilters(fs objectSDK.SearchFilters) *SelectPrm {
|
||||||
if p != nil {
|
if p != nil {
|
||||||
|
@ -35,7 +46,7 @@ func (r *SelectRes) AddressList() []*objectSDK.Address {
|
||||||
// Returns any error encountered that
|
// Returns any error encountered that
|
||||||
// did not allow to completely select the objects.
|
// did not allow to completely select the objects.
|
||||||
func (s *Shard) Select(prm *SelectPrm) (*SelectRes, error) {
|
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 {
|
if err != nil {
|
||||||
return nil, errors.Wrap(err, "could not select objects from metabase")
|
return nil, errors.Wrap(err, "could not select objects from metabase")
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue