[#39] service/object: Add query filters to search right child

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
Leonard Lyubich 2020-09-23 13:41:09 +03:00 committed by Alex Vanin
parent df5fb23ba8
commit 39c324bd6d
2 changed files with 31 additions and 0 deletions

View file

@ -0,0 +1,27 @@
package query
import (
"github.com/nspcc-dev/neofs-api-go/pkg/object"
"github.com/nspcc-dev/neofs-node/pkg/services/object/search/query"
)
// FIXME: this is a temporary solution for object fields filters
const keyChildrenField = "Object.Header.Split.Children"
const keyParentIDField = "Object.Header.Split.Parent"
func NewEmptyChildrenFilter() *Filter {
return NewFilterEqual(keyChildrenField, "")
}
func NewParentIDFilter(par *object.ID) *Filter {
return NewFilterEqual(keyParentIDField, idValue(par))
}
func NewRightChildQuery(par *object.ID) query.Query {
return New(
NewParentIDFilter(par),
NewEmptyChildrenFilter(),
)
}

View file

@ -97,6 +97,10 @@ func headerEqual(obj *object.Object, key, value string) bool {
return value == cidValue(obj.GetContainerID()) return value == cidValue(obj.GetContainerID())
case objectSDK.HdrSysNameOwnerID: case objectSDK.HdrSysNameOwnerID:
return value == ownerIDValue(obj.GetOwnerID()) return value == ownerIDValue(obj.GetOwnerID())
case keyChildrenField:
return len(obj.GetChildren()) == 0
case keyParentIDField:
return idValue(obj.GetParent().GetID()) == value
// TODO: add other headers // TODO: add other headers
} }
} }