forked from TrueCloudLab/frostfs-node
[#58] object/search: Add object-with-children filter
Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>support/v0.27
parent
624e8cd3cb
commit
16252ad09a
|
@ -7,12 +7,14 @@ import (
|
|||
|
||||
// FIXME: this is a temporary solution for object fields filters
|
||||
|
||||
const keyChildrenField = "Object.Header.Split.Children"
|
||||
const keyParentField = "Object.Header.Split.WithChildren"
|
||||
|
||||
const keyNoChildrenField = "Object.Header.Split.NoChildren"
|
||||
|
||||
const keyParentIDField = "Object.Header.Split.Parent"
|
||||
|
||||
func NewEmptyChildrenFilter() *Filter {
|
||||
return NewFilterEqual(keyChildrenField, "")
|
||||
return NewFilterEqual(keyNoChildrenField, "")
|
||||
}
|
||||
|
||||
func NewParentIDFilter(par *object.ID) *Filter {
|
||||
|
@ -25,3 +27,10 @@ func NewRightChildQuery(par *object.ID) query.Query {
|
|||
NewEmptyChildrenFilter(),
|
||||
)
|
||||
}
|
||||
|
||||
func NewLinkingQuery(par *object.ID) query.Query {
|
||||
return New(
|
||||
NewParentIDFilter(par),
|
||||
NewFilterEqual(keyParentField, ""),
|
||||
)
|
||||
}
|
||||
|
|
|
@ -97,10 +97,12 @@ func headerEqual(obj *object.Object, key, value string) bool {
|
|||
return value == cidValue(obj.GetContainerID())
|
||||
case objectSDK.HdrSysNameOwnerID:
|
||||
return value == ownerIDValue(obj.GetOwnerID())
|
||||
case keyChildrenField:
|
||||
case keyNoChildrenField:
|
||||
return len(obj.GetChildren()) == 0
|
||||
case keyParentIDField:
|
||||
return idValue(obj.GetParent().GetID()) == value
|
||||
case keyParentField:
|
||||
return len(obj.GetChildren()) > 0
|
||||
// TODO: add other headers
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue