[#61] object/search: Filter objects by container ID from request
Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
parent
1654df4d97
commit
f89c848e84
2 changed files with 8 additions and 1 deletions
|
@ -3,6 +3,7 @@ package searchsvc
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
|
"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"
|
||||||
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/bucket"
|
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/bucket"
|
||||||
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/localstore"
|
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/localstore"
|
||||||
|
@ -14,6 +15,8 @@ type localStream struct {
|
||||||
query query.Query
|
query query.Query
|
||||||
|
|
||||||
storage *localstore.Storage
|
storage *localstore.Storage
|
||||||
|
|
||||||
|
cid *container.ID
|
||||||
}
|
}
|
||||||
|
|
||||||
type searchQueryFilter struct {
|
type searchQueryFilter struct {
|
||||||
|
@ -22,12 +25,15 @@ type searchQueryFilter struct {
|
||||||
query query.Query
|
query query.Query
|
||||||
|
|
||||||
ch chan<- []*objectSDK.ID
|
ch chan<- []*objectSDK.ID
|
||||||
|
|
||||||
|
cid *container.ID
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *localStream) stream(ctx context.Context, ch chan<- []*objectSDK.ID) error {
|
func (s *localStream) stream(ctx context.Context, ch chan<- []*objectSDK.ID) error {
|
||||||
filter := &searchQueryFilter{
|
filter := &searchQueryFilter{
|
||||||
query: s.query,
|
query: s.query,
|
||||||
ch: ch,
|
ch: ch,
|
||||||
|
cid: s.cid,
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := s.storage.Iterate(filter, func(meta *localstore.ObjectMeta) bool {
|
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 {
|
func (f *searchQueryFilter) Pass(ctx context.Context, meta *localstore.ObjectMeta) *localstore.FilterResult {
|
||||||
loop:
|
loop:
|
||||||
for obj := meta.Head(); obj != nil; obj = obj.GetParent() {
|
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
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -157,6 +157,7 @@ loop:
|
||||||
streamer = &localStream{
|
streamer = &localStream{
|
||||||
query: prm.query,
|
query: prm.query,
|
||||||
storage: p.localStore,
|
storage: p.localStore,
|
||||||
|
cid: prm.cid,
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
streamer = &remoteStream{
|
streamer = &remoteStream{
|
||||||
|
|
Loading…
Reference in a new issue