From f89c848e848f076bd9eb9d6090902d521d8365d7 Mon Sep 17 00:00:00 2001 From: Leonard Lyubich Date: Thu, 1 Oct 2020 14:49:10 +0300 Subject: [PATCH] [#61] object/search: Filter objects by container ID from request Signed-off-by: Leonard Lyubich --- pkg/services/object/search/local.go | 8 +++++++- pkg/services/object/search/streamer.go | 1 + 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/pkg/services/object/search/local.go b/pkg/services/object/search/local.go index 9c09beb13..7384887e5 100644 --- a/pkg/services/object/search/local.go +++ b/pkg/services/object/search/local.go @@ -3,6 +3,7 @@ package searchsvc import ( "context" + "github.com/nspcc-dev/neofs-api-go/pkg/container" objectSDK "github.com/nspcc-dev/neofs-api-go/pkg/object" "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/bucket" "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/localstore" @@ -14,6 +15,8 @@ type localStream struct { query query.Query storage *localstore.Storage + + cid *container.ID } type searchQueryFilter struct { @@ -22,12 +25,15 @@ type searchQueryFilter struct { query query.Query ch chan<- []*objectSDK.ID + + cid *container.ID } func (s *localStream) stream(ctx context.Context, ch chan<- []*objectSDK.ID) error { filter := &searchQueryFilter{ query: s.query, ch: ch, + cid: s.cid, } if err := s.storage.Iterate(filter, func(meta *localstore.ObjectMeta) bool { @@ -47,7 +53,7 @@ func (s *localStream) stream(ctx context.Context, ch chan<- []*objectSDK.ID) err func (f *searchQueryFilter) Pass(ctx context.Context, meta *localstore.ObjectMeta) *localstore.FilterResult { loop: for obj := meta.Head(); obj != nil; obj = obj.GetParent() { - if !f.query.Match(obj) { + if !f.cid.Equal(obj.GetContainerID()) || !f.query.Match(obj) { continue } diff --git a/pkg/services/object/search/streamer.go b/pkg/services/object/search/streamer.go index 0a2f73203..f8934a21c 100644 --- a/pkg/services/object/search/streamer.go +++ b/pkg/services/object/search/streamer.go @@ -157,6 +157,7 @@ loop: streamer = &localStream{ query: prm.query, storage: p.localStore, + cid: prm.cid, } } else { streamer = &remoteStream{