forked from TrueCloudLab/frostfs-node
[#39] service/object: Add query filters to search right child
Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>support/v0.27
parent
df5fb23ba8
commit
39c324bd6d
|
@ -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(),
|
||||
)
|
||||
}
|
|
@ -97,6 +97,10 @@ func headerEqual(obj *object.Object, key, value string) bool {
|
|||
return value == cidValue(obj.GetContainerID())
|
||||
case objectSDK.HdrSysNameOwnerID:
|
||||
return value == ownerIDValue(obj.GetOwnerID())
|
||||
case keyChildrenField:
|
||||
return len(obj.GetChildren()) == 0
|
||||
case keyParentIDField:
|
||||
return idValue(obj.GetParent().GetID()) == value
|
||||
// TODO: add other headers
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue